Commit 63c5d10b authored by Paul Eggert's avatar Paul Eggert
Browse files

* editfns.c (init_editfns, Fuser_login_name, Fuser_uid):

(Fuser_real_uid, Fuser_full_name): Remove unnecessary casts,
some of which prompt warnings from gcc -Wbad-function-cast.
parent a415e694
2011-03-16 Paul Eggert <eggert@cs.ucla.edu>
* editfns.c (init_editfns, Fuser_login_name, Fuser_uid):
(Fuser_real_uid, Fuser_full_name): Remove unnecessary casts,
some of which prompt warnings from gcc -Wbad-function-cast.
2011-03-15 Paul Eggert <eggert@cs.ucla.edu> 2011-03-15 Paul Eggert <eggert@cs.ucla.edu>
* doc.c (Fdocumentation, Fsnarf_documentation): Move locals to * doc.c (Fdocumentation, Fsnarf_documentation): Move locals to
...@@ -122,7 +122,7 @@ Lisp_Object Qboundary; ...@@ -122,7 +122,7 @@ Lisp_Object Qboundary;
void void
init_editfns (void) init_editfns (void)
{ {
char *user_name; const char *user_name;
register char *p; register char *p;
struct passwd *pw; /* password entry for the current user */ struct passwd *pw; /* password entry for the current user */
Lisp_Object tem; Lisp_Object tem;
...@@ -136,7 +136,7 @@ init_editfns (void) ...@@ -136,7 +136,7 @@ init_editfns (void)
return; return;
#endif /* not CANNOT_DUMP */ #endif /* not CANNOT_DUMP */
pw = (struct passwd *) getpwuid (getuid ()); pw = getpwuid (getuid ());
#ifdef MSDOS #ifdef MSDOS
/* We let the real user name default to "root" because that's quite /* We let the real user name default to "root" because that's quite
accurate on MSDOG and because it lets Emacs find the init file. accurate on MSDOG and because it lets Emacs find the init file.
...@@ -148,17 +148,17 @@ init_editfns (void) ...@@ -148,17 +148,17 @@ init_editfns (void)
/* Get the effective user name, by consulting environment variables, /* Get the effective user name, by consulting environment variables,
or the effective uid if those are unset. */ or the effective uid if those are unset. */
user_name = (char *) getenv ("LOGNAME"); user_name = getenv ("LOGNAME");
if (!user_name) if (!user_name)
#ifdef WINDOWSNT #ifdef WINDOWSNT
user_name = (char *) getenv ("USERNAME"); /* it's USERNAME on NT */ user_name = getenv ("USERNAME"); /* it's USERNAME on NT */
#else /* WINDOWSNT */ #else /* WINDOWSNT */
user_name = (char *) getenv ("USER"); user_name = getenv ("USER");
#endif /* WINDOWSNT */ #endif /* WINDOWSNT */
if (!user_name) if (!user_name)
{ {
pw = (struct passwd *) getpwuid (geteuid ()); pw = getpwuid (geteuid ());
user_name = (char *) (pw ? pw->pw_name : "unknown"); user_name = pw ? pw->pw_name : "unknown";
} }
Vuser_login_name = build_string (user_name); Vuser_login_name = build_string (user_name);
...@@ -1266,9 +1266,9 @@ of the user with that uid, or nil if there is no such user. */) ...@@ -1266,9 +1266,9 @@ of the user with that uid, or nil if there is no such user. */)
if (NILP (uid)) if (NILP (uid))
return Vuser_login_name; return Vuser_login_name;
id = (uid_t)XFLOATINT (uid); id = XFLOATINT (uid);
BLOCK_INPUT; BLOCK_INPUT;
pw = (struct passwd *) getpwuid (id); pw = getpwuid (id);
UNBLOCK_INPUT; UNBLOCK_INPUT;
return (pw ? build_string (pw->pw_name) : Qnil); return (pw ? build_string (pw->pw_name) : Qnil);
} }
...@@ -1300,7 +1300,7 @@ Value is an integer or a float, depending on the value. */) ...@@ -1300,7 +1300,7 @@ Value is an integer or a float, depending on the value. */)
/* Make sure we don't produce a negative UID due to signed integer /* Make sure we don't produce a negative UID due to signed integer
overflow. */ overflow. */
if (euid < 0) if (euid < 0)
return make_float ((double)geteuid ()); return make_float (geteuid ());
return make_fixnum_or_float (euid); return make_fixnum_or_float (euid);
} }
...@@ -1316,7 +1316,7 @@ Value is an integer or a float, depending on the value. */) ...@@ -1316,7 +1316,7 @@ Value is an integer or a float, depending on the value. */)
/* Make sure we don't produce a negative UID due to signed integer /* Make sure we don't produce a negative UID due to signed integer
overflow. */ overflow. */
if (uid < 0) if (uid < 0)
return make_float ((double)getuid ()); return make_float (getuid ());
return make_fixnum_or_float (uid); return make_fixnum_or_float (uid);
} }
...@@ -1339,14 +1339,15 @@ name, or nil if there is no such user. */) ...@@ -1339,14 +1339,15 @@ name, or nil if there is no such user. */)
return Vuser_full_name; return Vuser_full_name;
else if (NUMBERP (uid)) else if (NUMBERP (uid))
{ {
uid_t u = XFLOATINT (uid);
BLOCK_INPUT; BLOCK_INPUT;
pw = (struct passwd *) getpwuid ((uid_t) XFLOATINT (uid)); pw = getpwuid (u);
UNBLOCK_INPUT; UNBLOCK_INPUT;
} }
else if (STRINGP (uid)) else if (STRINGP (uid))
{ {
BLOCK_INPUT; BLOCK_INPUT;
pw = (struct passwd *) getpwnam (SSDATA (uid)); pw = getpwnam (SSDATA (uid));
UNBLOCK_INPUT; UNBLOCK_INPUT;
} }
else else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment