From 225a2cff910d3fbc2cca2cdef6d3eecfce9e74e5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 25 Oct 2011 22:22:54 -0700 Subject: [PATCH] * sysdep.c (system_process_attributes): Simplify pid_t handling. --- src/ChangeLog | 6 +++--- src/sysdep.c | 20 ++------------------ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 2f825a37971..7d28913b0ce 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,4 @@ -2011-10-25 Paul Eggert +2011-10-26 Paul Eggert Fix integer width and related bugs. * alloc.c (pure_bytes_used_lisp, pure_bytes_used_non_lisp): @@ -627,8 +627,8 @@ Don't assume pid_t fits in int; on 64-bit AIX pid_t is 64-bit. (emacs_read, emacs_write): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. - (system_process_attributes): Don't assume uid_t, gid_t, and - double all fit in int or even EMACS_INT. + (system_process_attributes): Don't assume uid_t, gid_t, EMACS_INT, + and double all fit in int. * term.c (set_tty_color_mode): Check that fixnums are in proper range for system types. * termhooks.h (struct input_event): diff --git a/src/sysdep.c b/src/sysdep.c index efc627e80b7..9b4bd088046 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -2705,15 +2705,7 @@ system_process_attributes (Lisp_Object pid) struct gcpro gcpro1, gcpro2; CHECK_NUMBER_OR_FLOAT (pid); - if (FLOATP (pid)) - { - double v = XFLOAT_DATA (pid); - if (! (TYPE_MINIMUM (pid_t) <= v && v < TYPE_MAXIMUM (pid_t) + 1.0)) - return attrs; - proc_id = v; - } - else - proc_id = XINT (pid); + CONS_TO_INTEGER (pid, pid_t, proc_id); sprintf (procfn, "/proc/%"pMd, proc_id); if (stat (procfn, &st) < 0) return attrs; @@ -2978,15 +2970,7 @@ system_process_attributes (Lisp_Object pid) struct gcpro gcpro1, gcpro2; CHECK_NUMBER_OR_FLOAT (pid); - if (FLOATP (pid)) - { - double v = XFLOAT_DATA (pid); - if (! (TYPE_MINIMUM (pid_t) <= v && v < TYPE_MAXIMUM (pid_t) + 1.0)) - return attrs; - proc_id = v; - } - else - proc_id = XINT (v); + CONS_TO_INTEGER (pid, pid_t, proc_id); sprintf (procfn, "/proc/%"pMd, proc_id); if (stat (procfn, &st) < 0) return attrs; -- 2.39.2