emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master c95270a: Change two _Noreturn functions to return v


From: Paul Eggert
Subject: [Emacs-diffs] master c95270a: Change two _Noreturn functions to return void
Date: Tue, 6 Dec 2016 23:26:17 +0000 (UTC)

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

    Change two _Noreturn functions to return void
    
    This is a bit clearer than _Noreturn functions that (do not)
    return a non-void type.
    * src/callproc.c (call_process) [MSDOS]:
    Use 'status' local to record status.
    (child_setup): Return CHILD_SETUP_TYPE.
    * src/data.c, src/lisp.h (wrong_type_argument): Return void.
    All callers changed.
    * src/lisp.h (CHILD_SETUP_TYPE): New macro.
---
 src/callproc.c |   16 ++++++++--------
 src/data.c     |    4 ++--
 src/lisp.h     |   26 ++++++++++++++++----------
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/src/callproc.c b/src/callproc.c
index dc3ca4a..02db348 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -293,7 +293,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int 
filefd,
   Lisp_Object output_file = Qnil;
 #ifdef MSDOS   /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */
   char *tempfile = NULL;
-  int pid;
 #else
   sigset_t oldset;
   pid_t pid;
@@ -538,11 +537,9 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int 
filefd,
     }
 
 #ifdef MSDOS /* MW, July 1993 */
-  /* Note that on MSDOS `child_setup' actually returns the child process
-     exit status, not its PID, so assign it to status below.  */
-  pid = child_setup (filefd, fd_output, fd_error, new_argv, 0, current_dir);
+  status = child_setup (filefd, fd_output, fd_error, new_argv, 0, current_dir);
 
-  if (pid < 0)
+  if (status < 0)
     {
       child_errno = errno;
       unbind_to (count, Qnil);
@@ -551,7 +548,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int 
filefd,
        code_convert_string_norecord (build_string (strerror (child_errno)),
                                      Vlocale_coding_system, 0);
     }
-  status = pid;
 
   for (i = 0; i < CALLPROC_FDS; i++)
     if (0 <= callproc_fd[i])
@@ -1163,9 +1159,13 @@ exec_failed (char const *name, int err)
    CURRENT_DIR is an elisp string giving the path of the current
    directory the subprocess should have.  Since we can't really signal
    a decent error from within the child, this should be verified as an
-   executable directory by the parent.  */
+   executable directory by the parent.
+
+   On GNUish hosts, either exec or return an error number.
+   On MS-Windows, either return a pid or signal an error.
+   On MS-DOS, either return an exit status or signal an error.  */
 
-int
+CHILD_SETUP_TYPE
 child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
             Lisp_Object current_dir)
 {
diff --git a/src/data.c b/src/data.c
index eee2a52..64cd8b2 100644
--- a/src/data.c
+++ b/src/data.c
@@ -138,7 +138,7 @@ wrong_length_argument (Lisp_Object a1, Lisp_Object a2, 
Lisp_Object a3)
              make_number (bool_vector_size (a3)));
 }
 
-Lisp_Object
+_Noreturn void
 wrong_type_argument (register Lisp_Object predicate, register Lisp_Object 
value)
 {
   /* If VALUE is not even a valid Lisp object, we'd want to abort here
@@ -2924,7 +2924,7 @@ float_arith_driver (double accum, ptrdiff_t argnum, enum 
arithop code,
        case Alogand:
        case Alogior:
        case Alogxor:
-         return wrong_type_argument (Qinteger_or_marker_p, val);
+         wrong_type_argument (Qinteger_or_marker_p, val);
        case Amax:
          if (!argnum || isnan (next) || next > accum)
            accum = next;
diff --git a/src/lisp.h b/src/lisp.h
index 7dd9145..3d39dc4 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -309,7 +309,7 @@ error !;
 #define lisp_h_CHECK_NUMBER(x) CHECK_TYPE (INTEGERP (x), Qintegerp, x)
 #define lisp_h_CHECK_SYMBOL(x) CHECK_TYPE (SYMBOLP (x), Qsymbolp, x)
 #define lisp_h_CHECK_TYPE(ok, predicate, x) \
-   ((ok) ? (void) 0 : (void) wrong_type_argument (predicate, x))
+   ((ok) ? (void) 0 : wrong_type_argument (predicate, x))
 #define lisp_h_CONSP(x) (XTYPE (x) == Lisp_Cons)
 #define lisp_h_EQ(x, y) (XLI (x) == XLI (y))
 #define lisp_h_FLOATP(x) (XTYPE (x) == Lisp_Float)
@@ -599,7 +599,7 @@ extern Lisp_Object char_table_ref (Lisp_Object, int);
 extern void char_table_set (Lisp_Object, int, Lisp_Object);
 
 /* Defined in data.c.  */
-extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object);
+extern _Noreturn void wrong_type_argument (Lisp_Object, Lisp_Object);
 extern _Noreturn void wrong_choice (Lisp_Object, Lisp_Object);
 extern void notify_variable_watchers (Lisp_Object symbol, Lisp_Object newval,
                                       Lisp_Object operation, Lisp_Object 
where);
@@ -1270,16 +1270,20 @@ XSETCDR (Lisp_Object c, Lisp_Object n)
 INLINE Lisp_Object
 CAR (Lisp_Object c)
 {
-  return (CONSP (c) ? XCAR (c)
-         : NILP (c) ? Qnil
-         : wrong_type_argument (Qlistp, c));
+  if (CONSP (c))
+    return XCAR (c);
+  if (!NILP (c))
+    wrong_type_argument (Qlistp, c);
+  return Qnil;
 }
 INLINE Lisp_Object
 CDR (Lisp_Object c)
 {
-  return (CONSP (c) ? XCDR (c)
-         : NILP (c) ? Qnil
-         : wrong_type_argument (Qlistp, c));
+  if (CONSP (c))
+    return XCDR (c);
+  if (!NILP (c))
+    wrong_type_argument (Qlistp, c);
+  return Qnil;
 }
 
 /* Take the car or cdr of something whose type is not known.  */
@@ -4223,9 +4227,11 @@ extern void setup_process_coding_systems (Lisp_Object);
 
 /* Defined in callproc.c.  */
 #ifndef DOS_NT
- _Noreturn
+# define CHILD_SETUP_TYPE _Noreturn void
+#else
+# define CHILD_SETUP_TYPE int
 #endif
-extern int child_setup (int, int, int, char **, bool, Lisp_Object);
+extern CHILD_SETUP_TYPE child_setup (int, int, int, char **, bool, 
Lisp_Object);
 extern void init_callproc_1 (void);
 extern void init_callproc (void);
 extern void set_initial_environment (void);



reply via email to

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