misc small fixes (mostly type pickiness)

Dan Riley dsr at mail.lns.cornell.edu
Thu Sep 28 16:08:51 UTC 2000


Hi Russ et al.,

Enclosed are patches for a variety of small things that showed up when
I compiled 2.3.0 with 'cc -std1' on a DEQ Alpha.  Most of them are
picky points about types that only matter on platforms where
sizeof(int) != sizeof(socklen_t)--the most common change is places
where socket calls are passed an int* instead of an ARGTYPE*.

I believe this bug doesn't actually bite under Tru64 Unix for
complicated reasons...recent versions of Tru64 have 3 versions of most
of the socket calls, taking int*, size_t* and socklen_t* respectively,
where size_t and socklen_t are unsigned long.  The default interface
is the old one that takes int*, so passing an int* is actually correct
unless one of the defines enabling the newer interfaces is set.
Passing a long* also works, but only because the alpha is little
endian!  The defines to get the newer interfaces are somewhat OS
version dependent, so they probably are not worth the trouble as long
as the bug doesn't actually bite.

The other patches are:

innd/perl.c: ok, I just don't like compiler warnings...time_t is an
int on Tru64 UNIX (should have made it long and advertised Y2038
compliance).

innfeed/connection.c: the code that handles NTTPRelay returning 439 to
a "check" used artHolder without setting it.  Somebody who actually
understands the code should check that my fix is correct.

innfeed/misc.c: more I don't like warnings...technically the use of
log() is probably legal C since it doesn't have external linkage,
but it still seems like a bad idea.

nnrpd/commands.c, nnrpd/perm.c: useless assignments generate warnings
about undefined behavior due to multiple modification without an
intervening sequence point.  I very much doubt any compilers actually
do the wrong thing.

-dan

--- ./authprogs/radius.c~	Mon Aug 21 02:14:43 2000
+++ ./authprogs/radius.c	Wed Sep 27 19:36:46 2000
@@ -180,6 +180,7 @@
     int got;
     fd_set rdfds;
     uint32_t nvalue;
+    ARGTYPE slen;
 
     /* first, build the sockaddrs */
     memset(&sinl, '\0', sizeof(sinl));
@@ -357,9 +358,9 @@
 	    tmout.tv_usec = 0;
 	    continue;
 	}
-	jlen = sizeof(sinl);
+	slen = sizeof(sinl);
 	if ((jlen = recvfrom(sock, (char *)&req, sizeof(req)-sizeof(int), 0, 
-	                     (struct sockaddr*) &sinl, &jlen)) < 0) {
+	                     (struct sockaddr*) &sinl, &slen)) < 0) {
 	    fprintf(stderr, "radius: couldnt recvfrom: %s\n", strerror(errno));
 	    break;
 	}
--- ./innd/perl.c~	Mon Aug 21 02:14:43 2000
+++ ./innd/perl.c	Wed Sep 27 18:49:48 2000
@@ -279,7 +279,7 @@
 
     /* If any of the times are missing, they should default to now. */
     if (i < 4) {
-        sprintf(tbuff, "%ld", time((long *) 0));
+        sprintf(tbuff, "%ld", (long) time((time_t *) 0));
         for (; i < 4; i++)
             parambuf[i] = tbuff;
     }
--- ./innfeed/connection.c~	Mon Aug 21 02:14:43 2000
+++ ./innfeed/connection.c	Wed Sep 27 19:22:41 2000
@@ -2744,6 +2744,9 @@
                   hostPeerName (cxn->myHost),cxn->ident,439) ;
           cxnSleepOrDie (cxn) ;
         }
+      else if (msgid == NULL || strlen (msgid) == 0 ||
+	       (artHolder = artHolderByMsgId (msgid, cxn->checkRespHead)) == NULL)
+	noSuchMessageId (cxn,439,msgid,response) ;
       else
         {
           cxn->checksRefused++ ;
--- ./innfeed/misc.c~	Mon Aug 21 02:14:43 2000
+++ ./innfeed/misc.c	Wed Sep 27 19:24:22 2000
@@ -80,7 +80,7 @@
 int debuggingOutput ;
 u_int loggingLevel ;
 char **PointersFreedOnExit ;
-static void log (int level, const char *fmt, va_list args) ;
+static void dolog (int level, const char *fmt, va_list args) ;
 
 
 
@@ -122,7 +122,7 @@
 extern void (*gPrintInfo) (void) ;
 void (*gCleanUp) (void) = 0 ;
 
-static void log (int level, const char *fmt, va_list args)
+static void dolog (int level, const char *fmt, va_list args)
 {
   time_t now = time (NULL) ;
   char timeString [30] ;
@@ -167,7 +167,7 @@
   va_list ap ;
 
   va_start (ap, fmt) ;
-  log (LOG_ERR,fmt,ap) ;
+  dolog (LOG_ERR,fmt,ap) ;
   va_end (ap) ;
 
 #if SNAPSHOT_ON_DIE
@@ -192,7 +192,7 @@
   va_list ap ;
 
   va_start (ap, fmt) ;
-  log (LOG_WARNING,fmt,ap) ;
+  dolog (LOG_WARNING,fmt,ap) ;
   va_end (ap) ;
 }
 
@@ -202,7 +202,7 @@
   va_list ap ;
 
   va_start (ap,fmt) ;
-  log (LOG_CRIT,fmt,ap) ;
+  dolog (LOG_CRIT,fmt,ap) ;
   va_end (ap) ;
 
   exit (exitVal) ;
--- ./nnrpd/commands.c~	Mon Aug 21 02:14:43 2000
+++ ./nnrpd/commands.c	Wed Sep 27 18:53:02 2000
@@ -667,7 +667,7 @@
 	}
 	if (listsize <= numgroups) {
 	    listsize += 1000;
-	    grouplist = RENEW(grouplist, GROUPDATA, listsize);
+	    RENEW(grouplist, GROUPDATA, listsize);
 	}
 
 	grouplist[numgroups].high = hi;
--- ./nnrpd/perm.c~	Mon Aug 21 02:14:43 2000
+++ ./nnrpd/perm.c	Wed Sep 27 19:34:52 2000
@@ -1523,7 +1523,7 @@
     } else {
 	for (i = 0; auth_realms[i]; i++)
 	    ;
-	auth_realms = RENEW(auth_realms, AUTHGROUP*, i+2);
+	RENEW(auth_realms, AUTHGROUP*, i+2);
     }
     auth_realms[i] = group;
     auth_realms[i+1] = 0;
@@ -1539,7 +1539,7 @@
     } else {
 	for (i = 0; access_realms[i]; i++)
 	    ;
-	access_realms = RENEW(access_realms, ACCESSGROUP*, i+2);
+	RENEW(access_realms, ACCESSGROUP*, i+2);
     }
     access_realms[i] = group;
     access_realms[i+1] = 0;
@@ -1665,7 +1665,8 @@
 {
     struct sockaddr_in cli, loc;
     int gotsin;
-    int i, j;
+    int i;
+    ARGTYPE j;
 
     j = sizeof(cli);
     gotsin = (getpeername(0, (struct sockaddr*)&cli, &j) == 0);

--
Dan Riley                                         dsr at mail.lns.cornell.edu
Wilson Lab, Cornell University      <URL:http://www.lns.cornell.edu/~dsr/>
    "History teaches us that days like this are best spent in bed"



More information about the inn-bugs mailing list