INN commit: trunk (25 files)

INN Commit rra at isc.org
Sat Nov 25 21:55:43 UTC 2017


    Date: Saturday, November 25, 2017 @ 13:55:43
  Author: iulius
Revision: 10193

Take into account new GCC 7.0 warnings

Modified:
  trunk/backends/inndf.c
  trunk/backends/innxbatch.c
  trunk/backends/innxmit.c
  trunk/configure.ac
  trunk/contrib/newsresp.c
  trunk/history/his.c
  trunk/history/hisv6/hisv6.c
  trunk/include/inn/dbz.h
  trunk/innd/chan.c
  trunk/innd/nc.c
  trunk/innd/perl.c
  trunk/innd/python.c
  trunk/innd/site.c
  trunk/innd/status.c
  trunk/innfeed/configfile.l
  trunk/innfeed/host.c
  trunk/lib/snprintf.c
  trunk/nnrpd/perl.c
  trunk/nnrpd/python.c
  trunk/samples/innwatch.ctl
  trunk/storage/buffindexed/buffindexed.c
  trunk/storage/buffindexed/shmem.c
  trunk/storage/cnfs/cnfs.c
  trunk/storage/ovdb/ovdb.c
  trunk/tests/lib/date-t.c

-----------------------------------+
 backends/inndf.c                  |    2 -
 backends/innxbatch.c              |    3 +
 backends/innxmit.c                |    2 -
 configure.ac                      |   27 +++++++++-----
 contrib/newsresp.c                |   10 ++---
 history/his.c                     |    6 +--
 history/hisv6/hisv6.c             |    4 +-
 include/inn/dbz.h                 |    5 ++
 innd/chan.c                       |    9 ++--
 innd/nc.c                         |    6 +--
 innd/perl.c                       |   10 ++---
 innd/python.c                     |    9 ++--
 innd/site.c                       |    2 -
 innd/status.c                     |   25 ++++++-------
 innfeed/configfile.l              |    4 +-
 innfeed/host.c                    |   25 ++++++-------
 lib/snprintf.c                    |   68 +++++++++++++++++-------------------
 nnrpd/perl.c                      |    4 +-
 nnrpd/python.c                    |   14 +++----
 samples/innwatch.ctl              |    8 ++--
 storage/buffindexed/buffindexed.c |   31 +++++++++-------
 storage/buffindexed/shmem.c       |   23 ++++++------
 storage/cnfs/cnfs.c               |    2 -
 storage/ovdb/ovdb.c               |    2 -
 tests/lib/date-t.c                |   18 +++++----
 25 files changed, 174 insertions(+), 145 deletions(-)

Modified: backends/inndf.c
===================================================================
--- backends/inndf.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ backends/inndf.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -332,7 +332,7 @@
             printf("Space used is meaningless for the %s method\n",
                    innconf->ovmethod);
         else
-            printf("%.2f%% overview space used\n", used);
+            printf("%.2f%% overview space used\n", (double) used);
     }
     if (overview != NULL)
         overview_close(overview);

Modified: backends/innxbatch.c
===================================================================
--- backends/innxbatch.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ backends/innxbatch.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -60,6 +60,9 @@
 */
 static bool		Debug = false;
 static bool		STATprint;
+#ifdef FROMSTDIN
+static bool             FromStdin = false;
+#endif
 static char		*REMhost;
 static double		STATbegin;
 static double		STATend;

Modified: backends/innxmit.c
===================================================================
--- backends/innxmit.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ backends/innxmit.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -602,7 +602,7 @@
 	return false;
     if (HeadersFeed) {
 	struct iovec vec[3];
-	char buf[20];
+        char buf[32];
 	int iscmsg = 0;
 	int len = HeadersLen(art, &iscmsg);
 

Modified: configure.ac
===================================================================
--- configure.ac	2017-11-25 21:12:51 UTC (rev 10192)
+++ configure.ac	2017-11-25 21:55:43 UTC (rev 10193)
@@ -684,7 +684,7 @@
 dnl warnings are *not* included:
 dnl
 dnl   -ansi                 Requires messing with feature test macros.
-dnl   -Wpedantic             Too much noise from embedded Perl.
+dnl   -Wpedantic            Too much noise from embedded Perl.
 dnl   -Wdouble-promotion    Too much noise from using printf with floats.
 dnl   -Wswitch-default      Quite annoying to enforce it.
 dnl   -Wstrict-overflow=2   Gives false positives.
@@ -693,6 +693,9 @@
 dnl                         Warns about problems when upgrading from K&R to
 dnl                         ANSI C, so these aren't interesting.
 dnl   -Wundef               We need portability code.
+dnl   -Wformat-truncation=2 Gives false positives with GCC 7.2.0
+dnl                         https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83011
+dnl   -Wduplicated-branches Gives noise because of SA_LEN
 dnl   -Wunsafe-loop-optimizations
 dnl                         Too much noise.
 dnl   -Wcast-qual           Used for a while, but some casts are unavoidable.
@@ -704,12 +707,13 @@
 dnl   -Wredundant-decls     Too much noise from system headers.
 dnl   -Wlong-long           Too much noise from system headers.
 dnl   -Woverlength-strings  Useless noise.
+dnl   -Wunused-function     Noise from embedded Perl (at least with Perl 5.20).
 dnl
 dnl Some may be worth looking at again once a released version of gcc doesn't
 dnl warn on system headers.  The warnings below are in the same order as
 dnl they're listed in the gcc manual.
 dnl
-dnl Last checked against gcc 6.3.0 (2017-11-04).
+dnl Last checked against gcc 7.2.0 (2017-11-25).
 dnl
 dnl Add -g because when building with warnings, one generally also wants the
 dnl debugging information, and add -O3 because gcc won't find some warnings
@@ -728,17 +732,20 @@
 dnl -Wunreachable-code, -Wstack-protector, -Wdeclaration-after-statement
 m4_foreach_w(
     [flag],
-    [-g -O3 -DDEBUG=1 -Werror -Wall -Wextra -Wformat=2
-     -Wnull-dereference -Winit-self -Wmissing-include-dirs
-     -Wshift-overflow=2
-     -Wsync-nand -Wmissing-format-attribute -Wduplicated-cond
-     -Wtrampolines -Wshadow -Wpointer-arith -Wc99-c11-compat -Wc++-compat
-     -Wbad-function-cast -Wcast-align -Wwrite-strings -Wdate-time
+    [-g -O3 -DDEBUG=1 -Werror -Wall -Wextra -Wdouble-promotion -Wformat=2
+     -Wformat-overflow=2 -Wformat-truncation=1 -Wnull-dereference -Winit-self
+     -Wmissing-include-dirs -Wshift-overflow=2
+     -Wsync-nand -Wstringop-overflow=4 -Wmissing-format-attribute
+     -Walloc-zero -Walloca -Wduplicated-cond
+     -Wtrampolines -Wshadow -Wpointer-arith -Wc99-c11-compat
+     -Wbad-function-cast -Wcast-align -Wwrite-strings
+     -Wdangling-else -Wdate-time
      -Wjump-misses-init -Wstrict-prototypes
      -Wold-style-definition
      -Wmissing-prototypes -Wmissing-declarations
-     -Wnormalized=nfc -Wnested-externs -Winline
-     -Winvalid-pch -Wvla -Wno-unknown-warning-option],
+     -Wnormalized=nfc -Wrestrict -Wnested-externs -Winline
+     -Winvalid-pch -Wvla -Wno-unknown-warning-option
+     -Wno-unused-function],
     [INN_PROG_CC_FLAG(flag, [CC_WARNINGS="${CC_WARNINGS} flag"], [])])
 AC_SUBST([CC_WARNINGS])
 

Modified: contrib/newsresp.c
===================================================================
--- contrib/newsresp.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ contrib/newsresp.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -190,19 +190,19 @@
   diff = elapsed;
   elapsed = do_time(start);
   diff = elapsed - diff;
-  printf("%5.1f %5.1f  ",((float)elapsed)/1000.0,((float)diff)/1000.0);
+  printf("%5.1f %5.1f  ", ((double)elapsed)/1000.0, ((double)diff)/1000.0);
 }
 
 void
-massagebuff(int bread, char *buf)
+massagebuff(int bread, char *buffer)
 {
   char *p;
 
   if ( bread > 55 )
-    strcpy(buf+55," [...]\n");
+    strcpy(buffer+55," [...]\n");
   else
-    buf[bread] = '\0';
-  for ( p = buf; *p != '\0'; )
+    buffer[bread] = '\0';
+  for ( p = buffer; *p != '\0'; )
     if ( *p != '\r' )  /* We like to do it RISC style. */
       p++;
     else {

Modified: history/his.c
===================================================================
--- history/his.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ history/his.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -453,9 +453,9 @@
     if (HISstat_start[code].tv_sec != 0) {
 	fprintf(HISfdlog, "%d/%d/%d %02d:%02d:%02d.%06d: [%d] %s (%.6f)\n",
 		tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
-		tm->tm_min, tm->tm_sec, (int)tv.tv_usec, code, s, (float) tv.tv_sec +
-		(float) tv.tv_usec / 1000000 - (float) HISstat_start[code].tv_sec -
-		(float) HISstat_start[code].tv_usec / 1000000);
+		tm->tm_min, tm->tm_sec, (int)tv.tv_usec, code, s, (double) tv.tv_sec +
+        (double) tv.tv_usec / 1000000 - (double) HISstat_start[code].tv_sec -
+        (double) HISstat_start[code].tv_usec / 1000000);
 	if (tv.tv_usec < HISstat_start[code].tv_usec) {
 	    HISstat_total[code].tv_sec++;
 	    HISstat_total[code].tv_usec +=

Modified: history/hisv6/hisv6.c
===================================================================
--- history/hisv6/hisv6.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ history/hisv6/hisv6.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -79,9 +79,9 @@
 {
     if (offset != -1) {
 	/* really we want an autoconf test for %ll/%L/%I64, sigh */
-	sprintf(s, "@%.0f", (double)offset);
+        snprintf(s, HISV6_MAX_LOCATION, "@%lu", (unsigned long)offset);
     } else {
-	sprintf(s, ":%lu", (unsigned long)line);
+        snprintf(s, HISV6_MAX_LOCATION, ":%lu", (unsigned long)line);
     }
 }
 

Modified: include/inn/dbz.h
===================================================================
--- include/inn/dbz.h	2017-11-25 21:12:51 UTC (rev 10192)
+++ include/inn/dbz.h	2017-11-25 21:55:43 UTC (rev 10193)
@@ -69,6 +69,11 @@
 extern void dbzsetoptions(const dbzoptions options);
 extern void dbzgetoptions(dbzoptions *options);
 
+#ifdef DBZTEST
+extern int timediffms(struct timeval start, struct timeval end);
+extern void RemoveDBZ(char *filename);
+#endif /* DBZTEST */
+
 END_DECLS
 
 #endif /* INN_DBZ_H */

Modified: innd/chan.c
===================================================================
--- innd/chan.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ innd/chan.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -296,14 +296,15 @@
                cp->Refused - cp->Refused_checkpoint,
                cp->Rejected - cp->Rejected_checkpoint,
                cp->Duplicate - cp->Duplicate_checkpoint,
-               cp->Size - cp->Size_checkpoint,
-               cp->DuplicateSize - cp->DuplicateSize_checkpoint,
-               cp->RejectSize - cp->RejectSize_checkpoint);
+               (double) (cp->Size - cp->Size_checkpoint),
+               (double) (cp->DuplicateSize - cp->DuplicateSize_checkpoint),
+               (double) (cp->RejectSize - cp->RejectSize_checkpoint));
         notice("%s closed seconds %ld accepted %ld refused %ld rejected %ld"
                " duplicate %ld accepted size %.0f duplicate size %.0f"
                " rejected size %.0f", name, (long)(Now.tv_sec - cp->Started),
                cp->Received, cp->Refused, cp->Rejected, cp->Duplicate,
-               cp->Size, cp->DuplicateSize, cp->RejectSize);
+               (double) cp->Size, (double) cp->DuplicateSize,
+               (double) cp->RejectSize);
     }
     if (cp->Data.Newsgroups.Data != NULL) {
         free(cp->Data.Newsgroups.Data);

Modified: innd/nc.c
===================================================================
--- innd/nc.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ innd/nc.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -289,9 +289,9 @@
            cp->Refused - cp->Refused_checkpoint,
            cp->Rejected - cp->Rejected_checkpoint,
            cp->Duplicate - cp->Duplicate_checkpoint,
-           cp->Size - cp->Size_checkpoint,
-           cp->DuplicateSize - cp->DuplicateSize_checkpoint,
-           cp->RejectSize - cp->RejectSize_checkpoint);
+           (double) (cp->Size - cp->Size_checkpoint),
+           (double) (cp->DuplicateSize - cp->DuplicateSize_checkpoint),
+           (double) (cp->RejectSize - cp->RejectSize_checkpoint));
     cp->Reported = 0;
     cp->Started_checkpoint = Now.tv_sec;
     cp->Received_checkpoint = cp->Received;

Modified: innd/perl.c
===================================================================
--- innd/perl.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ innd/perl.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -204,7 +204,7 @@
 **  mode and the reason.
 */
 void
-PLmode(OPERATINGMODE Mode, OPERATINGMODE NewMode, char *reason)
+PLmode(OPERATINGMODE CurrentMode, OPERATINGMODE NewMode, char *reason)
 {
     dSP;
     HV          *mode;
@@ -219,13 +219,13 @@
        the reason in $mode{reason}. */
     mode = perl_get_hv("mode", 1);
 
-    if (Mode == OMrunning)
+    if (CurrentMode == OMrunning)
         (void) hv_store(mode, "Mode", 4, newSVpv("running", 7), 0);
-    if (Mode == OMpaused)
+    if (CurrentMode == OMpaused)
         (void) hv_store(mode, "Mode", 4, newSVpv("paused", 6), 0);
-    if (Mode == OMthrottled)
+    if (CurrentMode == OMthrottled)
         (void) hv_store(mode, "Mode", 4, newSVpv("throttled", 9), 0);
-    if (Mode == OMshutdown)
+    if (CurrentMode == OMshutdown)
         (void) hv_store(mode, "Mode", 4, newSVpv("shutdown", 8), 0);
 
     if (NewMode == OMrunning)

Modified: innd/python.c
===================================================================
--- innd/python.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ innd/python.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -196,7 +196,7 @@
 **  Tell the external module about innd's state.
 */
 void
-PYmode(OPERATINGMODE Mode, OPERATINGMODE NewMode, char *reason)
+PYmode(OPERATINGMODE CurrentMode, OPERATINGMODE NewMode, char *reason)
 {
     PyObject	*result;
     char	oldmode[10], newmode[10];
@@ -204,7 +204,7 @@
     if (!PythonFilterActive || PYFilterObject == NULL || mode_method == NULL)
 	return;
 
-    switch (Mode) {
+    switch (CurrentMode) {
     default:		strlcpy(oldmode, "unknown", 10);	break;
     case OMrunning:	strlcpy(oldmode, "running", 10);	break;
     case OMpaused:	strlcpy(oldmode, "paused", 10);		break;
@@ -302,7 +302,7 @@
     char	*msgid;
     Py_ssize_t  msgidlen;
     char	*articlepaths = (char *) "";
-    char	tbuff[12];
+    char	tbuff[32];
     char	*parambuf[6];
 
     if (!PyArg_ParseTuple(args, (char *) "s#", &msgid, &msgidlen))
@@ -512,7 +512,8 @@
 	/* Compress out multiple whitespace in the trimmed string.  We
 	 * do a copy because this is probably an original art
 	 * buffer. */
-	workstring =  memcpy(xmalloc(worksize), wpos, worksize);
+        workstring = xmalloc(worksize + 1);
+        memcpy(workstring, wpos, worksize);
         wasspace = false;
 	p = wpos;
 	q = workstring;

Modified: innd/site.c
===================================================================
--- innd/site.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ innd/site.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -334,7 +334,7 @@
     HDRCONTENT		*hc = Data->HdrContent;
     static char		ITEMSEP[] = " ";
     static char		NL[] = "\n";
-    char		pbuff[12];
+    char		pbuff[32];
     char	        *p;
     bool	        Dirty;
     struct buffer       *bp;

Modified: innd/status.c
===================================================================
--- innd/status.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ innd/status.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -85,12 +85,12 @@
 PrettySize(float size, char *str)
 {
   if (size > 1073741824) /* 1024*1024*1024 */
-    sprintf (str, "%.1fGb", size / 1073741824.);
+    sprintf (str, "%.1fGb", (double) size / 1073741824.);
   else
     if (size > 1048576) /* 1024*1024 */
-      sprintf (str, "%.1fMb", size / 1048576.);
+      sprintf (str, "%.1fMb", (double) size / 1048576.);
     else
-      sprintf (str, "%.1fkb", size / 1024.);
+      sprintf (str, "%.1fkb", (double) size / 1024.);
   return (str);
 }
 
@@ -117,7 +117,7 @@
   char                  other_ip_addr[INET6_ADDRSTRLEN];
   char                  *p;
   STATUS		*head, *status, *tmp;
-  char			str[9];
+  char                  str[315]; /* Maximum buffer size for PrettySize() */
   time_t		now;
  
   if (innconf->htmlstatus) {
@@ -296,18 +296,18 @@
   if (!offered) offered = 1; /* to avoid division by zero */
   if (!size) size = 1; /* avoid divide by zero here too */
   fprintf (F, "        accepted: %-9lu       %%accepted: %.1f%%\n",
-	   accepted, (float) accepted / offered * 100);
+	   accepted, (double) accepted / offered * 100);
   fprintf (F, "         refused: %-9lu        %%refused: %.1f%%\n",
-	   refused, (float) refused / offered * 100);
+	   refused, (double) refused / offered * 100);
   fprintf (F, "        rejected: %-9lu       %%rejected: %.1f%%\n",
-	   rejected, (float) rejected / offered * 100);
+	   rejected, (double) rejected / offered * 100);
   fprintf (F, "      duplicated: %-9lu     %%duplicated: %.1f%%\n",
-	   duplicate, (float) duplicate / offered * 100);
+	   duplicate, (double) duplicate / offered * 100);
   fprintf (F, "           bytes: %-7s\n", PrettySize (size + DuplicateSize + RejectSize, str));
   fprintf (F, " duplicated size: %-7s  %%duplicated size: %.1f%%\n",
-	   PrettySize(DuplicateSize, str), (float) DuplicateSize / size * 100);
+	   PrettySize(DuplicateSize, str), (double) (DuplicateSize / size * 100));
   fprintf (F, "   rejected size: %-7s    %%rejected size: %.1f%%\n",
-	   PrettySize(RejectSize, str), (float) RejectSize / size * 100);
+	   PrettySize(RejectSize, str), (double) (RejectSize / size * 100));
   fputc ('\n', F) ;
 
   if(innconf->logstatus) {
@@ -316,7 +316,7 @@
             "accepted size %.0f duplicate size %.0f rejected size %.0f\n",
                 "ME", (long) seconds, accepted,
                 refused, rejected, duplicate,
-                size, DuplicateSize, RejectSize);
+                (double) size, (double) DuplicateSize, (double) RejectSize);
   }
 
   /* Incoming Feeds */
@@ -370,7 +370,8 @@
               "accepted size %.0f duplicate size %.0f rejected size %.0f\n",
                   status->name, (long) status->seconds, status->accepted,
                   status->refused, status->rejected, status->Duplicate,
-                  status->Size, status->DuplicateSize, status->RejectSize);
+                  (double) status->Size, (double) status->DuplicateSize,
+                  (double) status->RejectSize);
     }
 
     tmp = status->next;

Modified: innfeed/configfile.l
===================================================================
--- innfeed/configfile.l	2017-11-25 21:12:51 UTC (rev 10192)
+++ innfeed/configfile.l	2017-11-25 21:55:43 UTC (rev 10193)
@@ -25,8 +25,10 @@
 
 /* Some versions of flex (such as 2.6.1-1.3 in Debian stretch) declare a
    variable as int that should be size_t.  We can't really do much about
-   that, and it's fixed in current flex, so just suppress the warning. */
+   that, and it's fixed in current flex, so just suppress the warning.
+   Same thing for a possible NULL pointer dereference. */
 #pragma GCC diagnostic ignored "-Wsign-compare"
+#pragma GCC diagnostic ignored "-Wnull-dereference"
 
 #if defined (FLEX_DEBUG)
 #define YY_USER_INIT yy_flex_debug = (getenv ("YYDEBUG") == NULL ? 0 : 1)

Modified: innfeed/host.c
===================================================================
--- innfeed/host.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ innfeed/host.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -2124,7 +2124,7 @@
 
       if (hostsLeft == 0) {
         snprintf(msgstr, sizeof(msgstr), "accsize %.0f rejsize %.0f",
-                 procArtsSizeAccepted, procArtsSizeRejected);
+                 (double) procArtsSizeAccepted, (double) procArtsSizeRejected);
         notice ("ME global seconds %ld offered %ld accepted %ld refused %ld"
                 " rejected %ld missing %ld %s spooled %ld unspooled %ld",
                 (long) (now - start),
@@ -3473,7 +3473,7 @@
   double cnt = (host->blCount) ? (host->blCount) : 1.0;
   double size;
   char *tsize;
-  char buf[]="1.23e+5 TB"; /* usual length is shorter, like "12.3 MB" */
+  char buf[]="1.234e+5 TB"; /* usual length is shorter, like "12.34 MB" */
 
   ASSERT (host != NULL) ;
   ASSERT (fp != NULL) ;
@@ -3614,19 +3614,20 @@
 
 #ifdef        XXX_STATSHACK
   {
-  time_t      now = time(NULL), sec = (long) (now - host->connectTime);
-  float               or, ar, rr, jr;
+  time_t      now2 = time(NULL);
+  time_t      sec2 = (long) (now2 - host->connectTime);
+  double      or, ar, rr, jr;
 
-  if (sec != 0) {
-      or = (float) host->artsOffered / (float) sec;
-      ar = (float) host->artsAccepted / (float) sec;
-      rr = (float) host->artsNotWanted / (float) sec;
-      jr = (float) host->artsRejected / (float) sec;
-      fprintf(fp, "\t\tor %02.2f ar %02.2f rr %02.2f jr %02.2f\n",
+  if (sec2 != 0) {
+      or = (double) host->artsOffered / (double) sec2;
+      ar = (double) host->artsAccepted / (double) sec2;
+      rr = (double) host->artsNotWanted / (double) sec2;
+      jr = (double) host->artsRejected / (double) sec2;
+      fprintf(fp, "   or %02.2f ar %02.2f rr %02.2f jr %02.2f\n",
               or, ar, rr, jr);
   }
-  fprintf(fp, "\tmissing %d spooled %d\n",
-      host->artsMissing,host->backlogSpooled);
+  fprintf(fp, "   missing %u spooled %u\n",
+          host->artsMissing, host->artsToTape);
   }
 #endif        /* XXX_STATSHACK */
   

Modified: lib/snprintf.c
===================================================================
--- lib/snprintf.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ lib/snprintf.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -83,11 +83,21 @@
  *    added explicit casts for double to long long int conversion
  *    fixed various warnings with GCC 7
  *
- *  Hrvoje Niksic <hniksic at arsdigita.com> 2000-11-04
+ *  Hrvoje Niksic <hniksic at xemacs.org> 2000-11-04
+ *    include <config.h> instead of "config.h".
+ *    moved TEST_SNPRINTF stuff out of HAVE_SNPRINTF ifdef.
  *    include <stdio.h> for NULL.
- *    added support for long long.
+ *    added support and test cases for long long.
  *    don't declare argument types to (v)snprintf if stdarg is not used.
+ *    use int instead of short int as 2nd arg to va_arg.
  *
+ *  alexk (INN) 2002-08-21
+ *    use LLONG in fmtfp to handle more characters during floating
+ *    point conversion.
+ *
+ *  herb (Samba) 2002-12-19
+ *    actually print args for %g and %e
+ *
  *  Hrvoje Niksic <hniksic at xemacs.org> 2005-04-15
  *    use the PARAMS macro to handle prototypes.
  *    write function definitions in the ansi2knr-friendly way.
@@ -104,6 +114,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <sys/types.h>
+#include "inn/messages.h"
 
 #ifndef NULL
 # define NULL 0
@@ -112,11 +123,6 @@
 /* varargs declarations: */
 
 #include <stdarg.h>
-#define HAVE_STDARGS    /* let's hope that works everywhere (mj) */
-#define VA_LOCAL_DECL   va_list ap
-#define VA_START(f)     va_start(ap, f)
-#define VA_SHIFT(v,t)  ;   /* no-op for ANSI */
-#define VA_END          va_end(ap)
 
 /* Assume all compilers support long double, per Autoconf documentation. */
 #define LDOUBLE long double
@@ -130,15 +136,15 @@
 int snprintf (char *str, size_t count, const char *fmt, ...);
 int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
 
-static int dopr (char *buffer, size_t maxlen, const char *format, 
+static int dopr (char *buffer, size_t maxlen, const char *format,
                  va_list args);
 static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
-		   const char *value, int flags, int min, int max);
+                   const char *value, int flags, int min, int max);
 static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
-		   LLONG value, int base, int min, int max, int flags);
+                   LLONG value, int base, int min, int max, int flags);
 static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
-		  LDOUBLE fvalue, int min, int max, int flags);
-static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
+                  LDOUBLE fvalue, int min, int max, int flags);
+static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c);
 
 /*
  * dopr(): poor man's version of doprintf
@@ -514,7 +520,7 @@
 /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
 
 static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
-		   LLONG value, int base, int min, int max, int flags)
+                   LLONG value, int base, int min, int max, int flags)
 {
   int signvalue = 0;
   unsigned LLONG uvalue;
@@ -570,8 +576,8 @@
     spadlen = -spadlen; /* Left Justifty */
 
 #ifdef DEBUG_SNPRINTF
-  dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
-      zpadlen, spadlen, min, max, place));
+  debug("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
+        zpadlen, spadlen, min, max, place);
 #endif
 
   /* Spaces */
@@ -652,7 +658,7 @@
 #pragma GCC diagnostic ignored "-Wstrict-overflow"
 
 static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
-		  LDOUBLE fvalue, int min, int max, int flags)
+                  LDOUBLE fvalue, int min, int max, int flags)
 {
   int signvalue = 0;
   LDOUBLE ufvalue;
@@ -760,7 +766,11 @@
       }
 
 #ifdef DEBUG_SNPRINTF
-  dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
+# ifdef HAVE_LONG_LONG_INT
+  debug("fmtfp: %Lf =? %lld.%lld\n", fvalue, intpart, fracpart);
+# else
+  debug("fmtfp: %Lf =? %ld.%ld\n", fvalue, intpart, fracpart);
+# endif
 #endif
 
   /* Convert integer part */
@@ -861,27 +871,14 @@
   return dopr(str, count, fmt, args);
 }
 
-/* VARARGS3 */
-#ifdef HAVE_STDARGS
-int snprintf (char *str,size_t count,const char *fmt,...)
-#else
-int snprintf (va_alist) va_dcl
-#endif
+int snprintf (char *str, size_t count, const char *fmt,...)
 {
-#ifndef HAVE_STDARGS
-  char *str;
-  size_t count;
-  char *fmt;
-#endif
-  VA_LOCAL_DECL;
+  va_list ap;
   int total;
     
-  VA_START (fmt);
-  VA_SHIFT (str, char *);
-  VA_SHIFT (count, size_t );
-  VA_SHIFT (fmt, char *);
+  va_start(ap, fmt);
   total = vsnprintf(str, count, fmt, ap);
-  VA_END;
+  va_end(ap);
   return total;
 }
 
@@ -958,5 +955,6 @@
       num++;
     }
   printf ("%d tests failed out of %d.\n", fail, num);
+  return 0;
 }
-#endif /* SNPRINTF_TEST */
+#endif /* TEST_SNPRINTF */

Modified: nnrpd/perl.c
===================================================================
--- nnrpd/perl.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ nnrpd/perl.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -44,7 +44,7 @@
 /* #define DEBUG_MODIFY only if you want to see verbose output. */
 #ifdef DEBUG_MODIFY
 static FILE *flog;
-void dumpTable(char *msg);
+void dumpTable(const char *msg);
 #endif /* DEBUG_MODIFY */
 
 char *
@@ -434,7 +434,7 @@
 
 #ifdef DEBUG_MODIFY
 void
-dumpTable (char *msg)
+dumpTable (const char *msg)
 {
     HEADER *hp;
     int i;

Modified: nnrpd/python.c
===================================================================
--- nnrpd/python.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ nnrpd/python.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -116,7 +116,7 @@
 **  or -1 if method is not defined.
 */
 void
-PY_authenticate(char* file, char *Username, char *Password, int *code,
+PY_authenticate(char* file, char *User, char *Password, int *code,
                 char *errorstring, char *newUser)
 {
     PyObject    *result, *item, *proc;
@@ -159,10 +159,10 @@
     PyDict_SetItemString(PYauthinfo, PYTHONintport, PYauthitem[authnum++]);
 
     /* Username if known. */
-    if (Username == NULL) {
+    if (User == NULL) {
         PYauthitem[authnum] = Py_None;
     } else {
-        PYauthitem[authnum] = PyBuffer_FromMemory(Username, strlen(Username));
+        PYauthitem[authnum] = PyBuffer_FromMemory(User, strlen(User));
     }
     PyDict_SetItemString(PYauthinfo, PYTHONuser, PYauthitem[authnum++]);
 
@@ -257,7 +257,7 @@
 **  If the access group cannot be generated, the connection is closed.
 */
 void
-PY_access(char* file, struct vector *access_vec, char *Username)
+PY_access(char* file, struct vector *access_vec, char *User)
 {
     PyObject	*result, *key, *value, *proc;
     char        *buffer;
@@ -303,7 +303,7 @@
     PyDict_SetItemString(PYauthinfo, PYTHONintport, PYauthitem[authnum++]);
 
     /* Username. */
-    PYauthitem[authnum] = PyBuffer_FromMemory(Username, strlen(Username));
+    PYauthitem[authnum] = PyBuffer_FromMemory(User, strlen(User));
     PyDict_SetItemString(PYauthinfo, PYTHONuser, PYauthitem[authnum++]);
  
     /* Password is not known. */
@@ -390,7 +390,7 @@
 **  Return negative value if dynamic method is not defined.
 */
 int
-PY_dynamic(char *Username, char *NewsGroup, int PostFlag, char **reply_message)
+PY_dynamic(char *User, char *NewsGroup, int PostFlag, char **reply_message)
 {
     PyObject	*result, *proc;
     char	*string, *temp;
@@ -432,7 +432,7 @@
     PyDict_SetItemString(PYauthinfo, PYTHONintport, PYauthitem[authnum++]);
     
     /* Username. */
-    PYauthitem[authnum] = PyBuffer_FromMemory(Username, strlen(Username));
+    PYauthitem[authnum] = PyBuffer_FromMemory(User, strlen(User));
     PyDict_SetItemString(PYauthinfo, PYTHONuser, PYauthitem[authnum++]);
     
     /* Password is not known. */

Modified: samples/innwatch.ctl
===================================================================
--- samples/innwatch.ctl	2017-11-25 21:12:51 UTC (rev 10192)
+++ samples/innwatch.ctl	2017-11-25 21:55:43 UTC (rev 10193)
@@ -4,13 +4,13 @@
 ##
 ##  Indicates what to run to test the state of the news system, and what
 ##  to do about it.  Format:
-##	!state!when!command!test!limit!command!reason/comment
+##	!state!when!condition!test!limit!command!reason/comment
 ##  where
-##	<!>		Delimiter; pick from [,:@;?!].
+##	<!>		Delimiter; pick from [!,:@;?].
 ##	<state>		State to enter if true.
 ##	<when>		States we must be in to match.
-##	<command>	Command to run to test condition.
-##	<test>		Operator to use in test(1) command.
+##	<condition>	Command to run to test condition.
+##	<test>		Operator to use in test(1) condition.
 ##	<limit>		Value to test against.
 ##	<command>	Command for innwatch to perform; use exit,
 ##			flush, go, pause, shutdown, skip, or throttle.

Modified: storage/buffindexed/buffindexed.c
===================================================================
--- storage/buffindexed/buffindexed.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ storage/buffindexed/buffindexed.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -724,7 +724,7 @@
       ovflushhead(ovbuff);
     }
 #ifdef OV_DEBUG
-    ovbuff->trace = xcalloc(ovbuff->totalblk, sizeof(ov_trace_array));
+    ovbuff->trace = xcalloc(ovbuff->totalblk, sizeof(struct ov_trace_array));
 #endif /* OV_DEBUG */
     ovlock(ovbuff, INN_LOCK_UNLOCK);
   }
@@ -1377,9 +1377,6 @@
   OVBUFF	*ovbuff;
   OVINDEXHEAD	ovindexhead;
   bool		needupdate = false;
-#ifdef OV_DEBUG
-  int		recno;
-#endif /* OV_DEBUG */
 
   Nospace = false;
   if (OV_BLOCKSIZE < len) {
@@ -1867,7 +1864,7 @@
 	    search->gdb.datablk.index = srchov.index;
 	    ovbuff = getovbuff(srchov);
             if (ovbuff == NULL) {
-                warn("buffindexed: ovsearch could not get ovbuff block for new, %d, %d, %ld", srchov.index, srchov.blocknum, *artnum);
+                warn("buffindexed: ovsearch could not get ovbuff block for new, %d, %d", srchov.index, srchov.blocknum);
                 return false;
             }
 	    offset = ovbuff->base + OV_OFFSET(srchov.blocknum);
@@ -2058,15 +2055,18 @@
   void		*handle;
   GROUPENTRY	newge, *ge;
   GROUPLOC	gloc, next;
-  char		*data;
-  int		i, len;
+  char          *data = NULL;
+  int		i;
+  int           len = 0;
   TOKEN		token;
-  ARTNUM	artnum, low, high;
+  ARTNUM        artnum = 0;
+  ARTNUM        low, high;
   ARTHANDLE	*ah;
   char		flag;
   HASH		hash;
-  time_t	arrived, expires;
-  OVSEARCH	search;
+  time_t        arrived = 0;
+  time_t        expires = 0;
+  OVSEARCH      search = { 0 };
 
   if (group == NULL) {
     for (i = 0 ; i < GROUPheader->freelist.recno ; i++) {
@@ -2162,7 +2162,11 @@
         warn("buffindexed: cannot prepare free operation");
         return false;
       }
+#ifdef OV_DEBUG
+      freegroupblock(ge);
+#else
       freegroupblock();
+#endif /* OV_DEBUG */
       ovgroupunmap();
 
       return false;
@@ -2253,7 +2257,8 @@
   FILE		*F = NULL;
   pid_t		pid;
   char		*path = NULL;
-  int		i,j;
+  size_t        i;
+  int           j;
   struct ov_trace_array *trace;
   struct ov_name_table	*ntp;
   size_t length;
@@ -2279,7 +2284,7 @@
 	      break;
 	    }
 	  }
-	  fprintf(F, "%d: % 6d, % 2d: 0x%08x, % 10d, % 10d\n", ovbuff->index, i, j,
+	  fprintf(F, "%d: % 6ld, % 2d: 0x%08x, % 10ld, % 10ld\n", ovbuff->index, i, j,
 	  trace->ov_trace[j].gloc.recno,
 	  trace->ov_trace[j].occupied,
 	  trace->ov_trace[j].freed);
@@ -2292,7 +2297,7 @@
       length = strlen(innconf->pathtmp) + 11;
       path = xmalloc(length);
       pid = getpid();
-      sprintf(path, length, "%s/%d", innconf->pathtmp, pid);
+      snprintf(path, length, "%s/%d", innconf->pathtmp, pid);
       if ((F = fopen(path, "w")) == NULL) {
 	syswarn("buffindexed: could not open %s", path);
       }

Modified: storage/buffindexed/shmem.c
===================================================================
--- storage/buffindexed/shmem.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ storage/buffindexed/shmem.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -18,9 +18,14 @@
 #include "inn/messages.h"
 #include "inn/libinn.h"
 #include "shmem.h"
-  
+
+#ifdef _TEST_
+# include <syslog.h> /* for openlog */
+# include <sys/file.h> /* for flock */
+#endif
+
 #ifndef MAP_FAILED
-  #define MAP_FAILED ((caddr_t)-1)
+# define MAP_FAILED ((caddr_t)-1)
 #endif
 
 static int smcGetSemaphore(const char *name)
@@ -285,10 +290,10 @@
 #ifdef	_TEST_
 
 /* Check if the testfile exists.
-   If the file is absent
-       create one with size 1M, and fill the contents with all zero.
-   for (i=0; i<100; i++)
-       add 1 to the content;
+** If the file is absent, create one with size 1M, and fill the contents
+** with all zero.
+** for (i=0; i<100; i++)
+**   add 1 to the content;
 */
 static const char* testfile = "testfile";
 #define TESTSIZE	( 1024 * 1024 )
@@ -302,13 +307,11 @@
     }
 }
 
-int main( int argc, char** argv )
+int main(int argc UNUSED, char** argv UNUSED)
 {
-    struct stat st;
     int fd, i, k;
     int *x;
     int len, xmin, xmax;
-    struct flock fl;
 
     atexit( myexit );
     openlog( "shmemtest", LOG_PID, LOG_DAEMON );
@@ -352,7 +355,7 @@
         }
         for( i=0; i<len; i++)
             x[i] += 1;
-        if( write(fd, this->addr, this->size) != this->size ) {
+        if( write(fd, this->addr, this->size) != (signed int) this->size ) {
             printf( "cant write" );
             exit(1);
         }

Modified: storage/cnfs/cnfs.c
===================================================================
--- storage/cnfs/cnfs.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ storage/cnfs/cnfs.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -1389,7 +1389,7 @@
 	*(CNFSARTHEADER *)&cahh = cah;
 	if(pread(cycbuff->fd, ((char *)&cahh)+sizeof(CNFSARTHEADER), sizeof(oldCNFSARTHEADER)-sizeof(CNFSARTHEADER), offset+sizeof(cah)) != sizeof(oldCNFSARTHEADER)-sizeof(CNFSARTHEADER)) {
             SMseterror(SMERR_UNDEFINED, "read2 failed");
-            syswarn("CNFS: could not read2 token %s %s:0x%s:%ld: %m",
+            syswarn("CNFS: could not read2 token %s %s:0x%s:%u: %m",
                     TokenToText(token), cycbuffname,
                     CNFSofft2hex(offset, false), cycnum);
             free(art);

Modified: storage/ovdb/ovdb.c
===================================================================
--- storage/ovdb/ovdb.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ storage/ovdb/ovdb.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -599,7 +599,7 @@
 static int open_db_file(int which)
 {
     int ret;
-    char name[10];
+    char name[16];
     DB_TXN *tid;
 
     if(dbs[which] != NULL)

Modified: tests/lib/date-t.c
===================================================================
--- tests/lib/date-t.c	2017-11-25 21:12:51 UTC (rev 10192)
+++ tests/lib/date-t.c	2017-11-25 21:55:43 UTC (rev 10193)
@@ -105,18 +105,20 @@
 
     tmp_tm = localtime(&timestamp);
     tm = *tmp_tm;
-    sprintf(date, "%02d%02d%02d", tm.tm_year % 100, tm.tm_mon + 1,
-            tm.tm_mday);
-    sprintf(hour, "%02d%02d%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
+    snprintf(date, sizeof(date), "%02d%02d%02d",
+             tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday);
+    snprintf(hour, sizeof(hour), "%02d%02d%02d",
+             tm.tm_hour, tm.tm_min, tm.tm_sec);
     ok_nntp((*n)++, timestamp, date, hour, true);
-    sprintf(date, "%04d%02d%02d", tm.tm_year + 1900, tm.tm_mon + 1,
-            tm.tm_mday);
+    snprintf(date, sizeof(date), "%04d%02d%02d",
+            tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
     ok_nntp((*n)++, timestamp, date, hour, true);
     tmp_tm = gmtime(&timestamp);
     tm = *tmp_tm;
-    sprintf(date, "%04d%02d%02d", tm.tm_year + 1900, tm.tm_mon + 1,
-            tm.tm_mday);
-    sprintf(hour, "%02d%02d%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
+    snprintf(date, sizeof(date), "%04d%02d%02d",
+             tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
+    snprintf(hour, sizeof(hour), "%02d%02d%02d",
+             tm.tm_hour, tm.tm_min, tm.tm_sec);
     ok_nntp((*n)++, timestamp, date, hour, false);
 }
 



More information about the inn-committers mailing list