CVS update: /ccvs/src/

[email protected] 9 May 2005 19:50:49 -0000
Newsgroups gmane.comp.version-control.cvs.cvs
Message-ID <[email protected]>
User: dprice  
Date: 05/05/09 12:50:49

Modified:
 /ccvs/src/
  ChangeLog, error.c

Log:
 * error.c (error): Avoid unportable calls to vsyslog.

File Changes:

Directory: /ccvs/src/
=====================

File [changed]: ChangeLog
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/ChangeLog?r1=1.3189&r2=1.3190
Delta lines:  +4 -0
-------------------
--- ChangeLog	9 May 2005 18:26:52 -0000	1.3189
+++ ChangeLog	9 May 2005 19:50:47 -0000	1.3190
@@ -1,5 +1,9 @@
 2005-05-09  Derek Price  <[email protected]>
 
+	* error.c (error): Avoid unportable calls to vsyslog.
+
+2005-05-09  Derek Price  <[email protected]>
+
 	* history.c (history_write): Add FIXME.
 
 2005-05-09  Derek Price  <[email protected]>

File [changed]: error.c
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/error.c?r1=1.43&r2=1.44
Delta lines:  +13 -15
---------------------
--- error.c	5 May 2005 01:29:38 -0000	1.43
+++ error.c	9 May 2005 19:50:47 -0000	1.44
@@ -121,17 +121,9 @@
     char *emptybuf = "";
 
     static const char *last_message = NULL;
-    static va_list last_args;
     static int last_status;
     static int last_errnum;
 
-    if (last_message) goto recursion_error;
-    last_message = message;
-    va_start (args, message);
-    last_args = args;
-    last_status = status;
-    last_errnum = errnum;
-
     /* Initialize these to avoid a lot of special case error handling.  */
     buf = statbuf;
     buf2 = statbuf2;
@@ -139,7 +131,9 @@
 
     /* Expand the message the user passed us.  */
     length = sizeof (statbuf);
+    va_start (args, message);
     buf = vasnprintf (statbuf, &length, message, args);
+    va_end (args);
     if (!buf) goto memerror;
 
     /* Expand the cvs commmand name to <cmd> or [<cmd> aborted].
@@ -168,14 +162,21 @@
                       errnum ? ": " : "", errnum ? strerror (errnum) : "");
     if (!buf2) goto memerror;
 
-    /* Send the final message to the client or log it.  */
+    /* Send the final message to the client or log it.
+     *
+     * Set this recursion blocks first since this is the only function called
+     * here which can cause error() to be caled a second time.
+     */
+    if (last_message) goto recursion_error;
+    last_message = buf2;
+    last_status = status;
+    last_errnum = errnum;
     cvs_outerr (buf2, length);
 
     /* Reset our recursion lock.  This needs to be done before the call to
      * exit() to allow the exit handlers to make calls to error().
      */
     last_message = NULL;
-    va_end (args);
 
     /* Done, if we're exiting.  */
     if (status)
@@ -221,15 +222,13 @@
     syslog (LOG_DAEMON | LOG_EMERG,
 	    "error (%d, %d) called recursively.  Original message was:",
 	    last_status, last_errnum);
-    vsyslog (LOG_DAEMON | LOG_EMERG, last_message, last_args);
+    syslog (LOG_DAEMON | LOG_EMERG, "%s", last_message);
 
 
     syslog (LOG_DAEMON | LOG_EMERG,
             "error (%d, %d) called recursively.  Second message was:",
 	    status, errnum);
-    va_start (args, message);
-    vsyslog (LOG_DAEMON | LOG_EMERG, message, args);
-    va_end (args);
+    vsyslog (LOG_DAEMON | LOG_EMERG, "%s", buf2);
 
     syslog (LOG_DAEMON | LOG_EMERG, "Aborting.");
 #endif /* HAVE_SYSLOG_H */
@@ -239,7 +238,6 @@
      * exit() to allow the exit handlers to make calls to error().
      */
     last_message = NULL;
-    va_end (last_args);
 
     exit (EXIT_FAILURE);
 }