emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 560202f: Fix XFASTINT of non-fixnum in process stat


From: Paul Eggert
Subject: [Emacs-diffs] master 560202f: Fix XFASTINT of non-fixnum in process status
Date: Fri, 10 Jun 2016 04:58:56 +0000 (UTC)

branch: master
commit 560202f67513327f5b262e01ebc709ab6855d6f6
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Fix XFASTINT of non-fixnum in process status
    
    * src/process.c (decode_status): 3rd arg is now Lisp_Object *,
    not int *, and is not decoded.  All uses changed.
    (status_message): Do not assume ‘failed’ code is an integer.
    * src/process.h: Document codes better.
---
 src/process.c |   26 +++++++++++++-------------
 src/process.h |    3 ++-
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/process.c b/src/process.c
index 9ca3e594..5e06ccc 100644
--- a/src/process.c
+++ b/src/process.c
@@ -537,21 +537,22 @@ status_convert (int w)
    and store them individually through the three pointers.  */
 
 static void
-decode_status (Lisp_Object l, Lisp_Object *symbol, int *code, bool *coredump)
+decode_status (Lisp_Object l, Lisp_Object *symbol, Lisp_Object *code,
+              bool *coredump)
 {
   Lisp_Object tem;
 
   if (SYMBOLP (l))
     {
       *symbol = l;
-      *code = 0;
+      *code = make_number (0);
       *coredump = 0;
     }
   else
     {
       *symbol = XCAR (l);
       tem = XCDR (l);
-      *code = XFASTINT (XCAR (tem));
+      *code = XCAR (tem);
       tem = XCDR (tem);
       *coredump = !NILP (tem);
     }
@@ -563,8 +564,7 @@ static Lisp_Object
 status_message (struct Lisp_Process *p)
 {
   Lisp_Object status = p->status;
-  Lisp_Object symbol;
-  int code;
+  Lisp_Object symbol, code;
   bool coredump;
   Lisp_Object string;
 
@@ -574,7 +574,7 @@ status_message (struct Lisp_Process *p)
     {
       char const *signame;
       synchronize_system_messages_locale ();
-      signame = strsignal (code);
+      signame = strsignal (XFASTINT (code));
       if (signame == 0)
        string = build_string ("unknown");
       else
@@ -596,20 +596,20 @@ status_message (struct Lisp_Process *p)
   else if (EQ (symbol, Qexit))
     {
       if (NETCONN1_P (p))
-       return build_string (code == 0 ? "deleted\n" : "connection broken by 
remote peer\n");
-      if (code == 0)
+       return build_string (XFASTINT (code) == 0
+                            ? "deleted\n"
+                            : "connection broken by remote peer\n");
+      if (XFASTINT (code) == 0)
        return build_string ("finished\n");
       AUTO_STRING (prefix, "exited abnormally with code ");
-      string = Fnumber_to_string (make_number (code));
+      string = Fnumber_to_string (code);
       AUTO_STRING (suffix, coredump ? " (core dumped)\n" : "\n");
       return concat3 (prefix, string, suffix);
     }
   else if (EQ (symbol, Qfailed))
     {
-      AUTO_STRING (prefix, "failed with code ");
-      string = Fnumber_to_string (make_number (code));
-      AUTO_STRING (suffix, "\n");
-      return concat3 (prefix, string, suffix);
+      AUTO_STRING (format, "failed with code %s\n");
+      return CALLN (Fformat, format, code);
     }
   else
     return Fcopy_sequence (Fsymbol_name (symbol));
diff --git a/src/process.h b/src/process.h
index a5f690d..4430377 100644
--- a/src/process.h
+++ b/src/process.h
@@ -83,7 +83,8 @@ struct Lisp_Process
     Lisp_Object mark;
 
     /* Symbol indicating status of process.
-       This may be a symbol: run, open, or closed.
+       This may be a symbol: run, open, closed, listen, connect, or failed.
+       Or it may be (failed ERR) where ERR is an integer, string or symbol.
        Or it may be a list, whose car is stop, exit or signal
        and whose cdr is a pair (EXIT_CODE . COREDUMP_FLAG)
        or (SIGNAL_NUMBER . COREDUMP_FLAG).  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]