summaryrefslogtreecommitdiff
path: root/src/filelock.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-08-03 16:36:11 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-08-03 16:36:11 -0700
commit98c6f1e36ff487925280fa0b0340af9d058632b5 (patch)
tree5601a2ac9433883b753a36f8d9c15f9d9d0b0eec /src/filelock.c
parent8834c57aab03fb7ea9d92f9e995844ff7ce64b7b (diff)
downloademacs-98c6f1e36ff487925280fa0b0340af9d058632b5.tar.gz
Remove unnecessary casts involving pointers.
These casts are no longer needed now that we assume C89 or later, since they involve casting to or from void *. * alloc.c (make_pure_string, make_pure_c_string, pure_cons) (make_pure_float, make_pure_vector): * lisp.h (SAFE_ALLOCA, SAFE_ALLOCA_LISP): * macros.c (Fstart_kbd_macro): * menu.c (find_and_return_menu_selection): * minibuf.c (read_minibuf_noninteractive): * sysdep.c (closedir): * xdisp.c (x_produce_glyphs): * xfaces.c (compare_fonts_by_sort_order): * xfns.c (x_real_positions, select_visual): * xselect.c (x_stop_queuing_selection_requests) (x_get_window_property, x_get_window_property_as_lisp_data): * xterm.c (x_set_frame_alpha, x_find_modifier_meanings): Remove unnecessary pointer casts. * alloc.c (record_xmalloc): New function. * lisp.h (record_xmalloc): New decl. (SAFE_ALLOCA): Now takes just one arg -- the size -- and acts more like a function. This is because the pointer cast is not needed. All uses changed. * print.c (print_string, print_error_message): Avoid length recalc.
Diffstat (limited to 'src/filelock.c')
-rw-r--r--src/filelock.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/filelock.c b/src/filelock.c
index e840d3c5c3b..d21d8e7ba02 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -337,31 +337,22 @@ fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn)
static int
lock_file_1 (char *lfname, int force)
{
- register int err;
- printmax_t boot, pid;
- const char *user_name;
- const char *host_name;
- char *lock_info_str;
- ptrdiff_t lock_info_size;
+ int err;
int symlink_errno;
USE_SAFE_ALLOCA;
/* Call this first because it can GC. */
- boot = get_boot_time ();
-
- if (STRINGP (Fuser_login_name (Qnil)))
- user_name = SSDATA (Fuser_login_name (Qnil));
- else
- user_name = "";
- if (STRINGP (Fsystem_name ()))
- host_name = SSDATA (Fsystem_name ());
- else
- host_name = "";
- lock_info_size = (strlen (user_name) + strlen (host_name)
- + 2 * INT_STRLEN_BOUND (printmax_t)
- + sizeof "@.:");
- SAFE_ALLOCA (lock_info_str, char *, lock_info_size);
- pid = getpid ();
+ printmax_t boot = get_boot_time ();
+
+ Lisp_Object luser_name = Fuser_login_name (Qnil);
+ char const *user_name = STRINGP (luser_name) ? SSDATA (luser_name) : "";
+ Lisp_Object lhost_name = Fsystem_name ();
+ char const *host_name = STRINGP (lhost_name) ? SSDATA (lhost_name) : "";
+ ptrdiff_t lock_info_size = (strlen (user_name) + strlen (host_name)
+ + 2 * INT_STRLEN_BOUND (printmax_t)
+ + sizeof "@.:");
+ char *lock_info_str = SAFE_ALLOCA (lock_info_size);
+ printmax_t pid = getpid ();
esprintf (lock_info_str, boot ? "%s@%s.%"pMd":%"pMd : "%s@%s.%"pMd,
user_name, host_name, pid, boot);
@@ -593,7 +584,7 @@ lock_file (Lisp_Object fn)
locker_size = (strlen (lock_info.user) + strlen (lock_info.host)
+ INT_STRLEN_BOUND (printmax_t)
+ sizeof "@ (pid )");
- SAFE_ALLOCA (locker, char *, locker_size);
+ locker = SAFE_ALLOCA (locker_size);
pid = lock_info.pid;
esprintf (locker, "%s@%s (pid %"pMd")",
lock_info.user, lock_info.host, pid);