RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: popt/ .splintrc CHANGES findme.c popt.c poptconfig.c popthe...

From: Jeff Johnson <jbj@rpm5.org>
Date: Sun 04 Nov 2007 - 14:15:32 CET
Message-Id: <20071104131532.C7CDB34847A@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: popt                             Date:   04-Nov-2007 14:15:32
  Branch: HEAD                             Handle: 2007110413153200

  Modified files:
    popt                    .splintrc CHANGES findme.c popt.c poptconfig.c
                            popthelp.c poptparse.c test1.c

  Log:
    - jbj: remove splint bounds/branch annotations, little gain, much pain.
    - jbj: revert alloca usage again again.

  Summary:
    Revision    Changes     Path
    1.6         +34 -1      popt/.splintrc
    1.27        +2  -1      popt/CHANGES
    1.18        +0  -2      popt/findme.c
    1.104       +0  -32     popt/popt.c
    1.33        +0  -4      popt/poptconfig.c
    1.67        +7  -33     popt/popthelp.c
    1.27        +0  -6      popt/poptparse.c
    1.28        +0  -2      popt/test1.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: popt/.splintrc
  ============================================================================
  $ cvs diff -u -r1.5 -r1.6 .splintrc
  --- popt/.splintrc	30 May 2007 02:45:46 -0000	1.5
  +++ popt/.splintrc	4 Nov 2007 13:15:32 -0000	1.6
  @@ -12,9 +12,42 @@
   +strict			# lclint level
   
   # --- in progress
  -+bounds
  +#+bounds
   -bufferoverflowhigh
   
  +-bitwisesigned
  +-branchstate
  +-compdef
  +-globuse
  +-internalglobs
  +-modnomods
  +-modobserveruncon
  +-mods
  +-moduncon
  +-modunconnomods
  +-mustmod
  +-noeffectuncon
  +-nullderef
  +-nullpass
  +-nullptrarith
  +-nullret
  +-nullstate
  +-protoparammatch
  +-retalias
  +-retvalint
  +-retvalother
  +-sizeoftype
  +-type
  +-unrecog
  +
  +-temptrans
  +
  ++charint
  +-exportvar
  ++matchanyintegral
  +-loopswitchbreak
  +-varuse
  +
   # --- +partial artifacts
   
   # --- not-yet at strict level
  @@ .
  patch -p0 <<'@@ .'
  Index: popt/CHANGES
  ============================================================================
  $ cvs diff -u -r1.26 -r1.27 CHANGES
  --- popt/CHANGES	3 Nov 2007 22:50:33 -0000	1.26
  +++ popt/CHANGES	4 Nov 2007 13:15:32 -0000	1.27
  @@ -1,6 +1,7 @@
   1.12 -> 1.13:
  +    - jbj: remove splint bounds/branch annotations, little gain, much pain.
  +    - jbj: revert alloca usage again again.
       - jbj: handle Solaris signed character isspace(3) issues consistently.
  -    - bero: include <alloca.h> where necessary.
       - bero: read /etc/popt.d/* files.
       - jbj: don't read /etc/popt twice (#290531).
       - jbj: isspace(3) has i18n encoding signednesss issues on Solaris (#172393).
  @@ .
  patch -p0 <<'@@ .'
  Index: popt/findme.c
  ============================================================================
  $ cvs diff -u -r1.17 -r1.18 findme.c
  --- popt/findme.c	14 Jun 2007 13:31:10 -0000	1.17
  +++ popt/findme.c	4 Nov 2007 13:15:32 -0000	1.18
  @@ -30,7 +30,6 @@
       strcpy(pathbuf, path);
   
       chptr = NULL;
  -/*@-branchstate@*/
       do {
   	if ((chptr = strchr(start, ':')))
   	    *chptr = '\0';
  @@ -46,7 +45,6 @@
   	else
   	    start = NULL;
       } while (start && *start);
  -/*@=branchstate@*/
   
   exit:
       if (pathbuf)
  @@ .
  patch -p0 <<'@@ .'
  Index: popt/popt.c
  ============================================================================
  $ cvs diff -u -r1.103 -r1.104 popt.c
  --- popt/popt.c	22 Jun 2007 00:02:01 -0000	1.103
  +++ popt/popt.c	4 Nov 2007 13:15:32 -0000	1.104
  @@ -70,10 +70,8 @@
   	if (opt->arg == NULL) continue;		/* XXX program error. */
   	if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
   	    void * arg = opt->arg;
  -/*@-branchstate@*/
   	    /* XXX sick hack to preserve pretense of ABI. */
   	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
  -/*@=branchstate@*/
   	    /* Recurse on included sub-tables. */
   	    invokeCallbacksPRE(con, arg);
   	} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
  @@ -98,10 +96,8 @@
   	if (opt->arg == NULL) continue;		/* XXX program error. */
   	if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
   	    void * arg = opt->arg;
  -/*@-branchstate@*/
   	    /* XXX sick hack to preserve pretense of ABI. */
   	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
  -/*@=branchstate@*/
   	    /* Recurse on included sub-tables. */
   	    invokeCallbacksPOST(con, arg);
   	} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
  @@ -130,10 +126,8 @@
       for (; opt->longName || opt->shortName || opt->arg; opt++) {
   	if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
   	    void * arg = opt->arg;
  -/*@-branchstate@*/
   	    /* XXX sick hack to preserve pretense of ABI. */
   	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
  -/*@=branchstate@*/
   	    /* Recurse on included sub-tables. */
   	    if (opt->arg != NULL)	/* XXX program error */
   		invokeCallbacksOPTION(con, opt->arg, myOpt, myData, shorty);
  @@ -222,7 +216,6 @@
       os->argb = PBM_FREE(os->argb);
   }
   
  -/*@-boundswrite@*/
   void poptResetContext(poptContext con)
   {
       int i;
  @@ -255,10 +248,8 @@
       return;
   /*@=nullstate@*/
   }
  -/*@=boundswrite@*/
   
   /* Only one of longName, shortName should be set, not both. */
  -/*@-boundswrite@*/
   static int handleExec(/*@special@*/ poptContext con,
   		/*@null@*/ const char * longName, char shortName)
   	/*@uses con->execs, con->numExecs, con->flags, con->doExec,
  @@ -314,7 +305,6 @@
   
       return 1;
   }
  -/*@=boundswrite@*/
   
   /* Only one of longName, shortName may be set at a time */
   static int handleAlias(/*@special@*/ poptContext con,
  @@ -353,10 +343,8 @@
       if ((con->os - con->optionStack + 1) == POPT_OPTION_DEPTH)
   	return POPT_ERROR_OPTSTOODEEP;
   
  -/*@-boundsread@*/
       if (nextCharArg && *nextCharArg)
   	con->os->nextCharArg = nextCharArg;
  -/*@=boundsread@*/
   
       con->os++;
       con->os->next = 0;
  @@ -371,7 +359,6 @@
       return (rc ? rc : 1);
   }
   
  -/*@-bounds -boundswrite @*/
   static int execCommand(poptContext con)
   	/*@globals internalState @*/
   	/*@modifies internalState @*/
  @@ -469,9 +456,7 @@
       }
       return ec;
   }
  -/*@=bounds =boundswrite @*/
   
  -/*@-boundswrite@*/
   /*@observer@*/ /*@null@*/ static const struct poptOption *
   findOption(const struct poptOption * opt, /*@null@*/ const char * longName, int longNameLen,
   		char shortName,
  @@ -492,10 +477,8 @@
   	    const struct poptOption * opt2;
   	    void * arg = opt->arg;
   
  -/*@-branchstate@*/
   	    /* XXX sick hack to preserve pretense of ABI. */
   	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
  -/*@=branchstate@*/
   	    /* Recurse on included sub-tables. */
   	    if (arg == NULL) continue;	/* XXX program error */
   	    opt2 = findOption(arg, longName, longNameLen, shortName, callback,
  @@ -542,7 +525,6 @@
   
       return opt;
   }
  -/*@=boundswrite@*/
   
   static const char * findNextArg(/*@special@*/ poptContext con,
   		unsigned argx, int delete_arg)
  @@ -581,7 +563,6 @@
       return arg;
   }
   
  -/*@-boundswrite@*/
   static /*@only@*/ /*@null@*/ const char *
   expandNextArg(/*@special@*/ poptContext con, const char * s)
   	/*@uses con->optionStack, con->os,
  @@ -630,7 +611,6 @@
       t = realloc(t, strlen(t) + 1);	/* XXX memory leak, hard to plug */
       return t;
   }
  -/*@=boundswrite@*/
   
   static void poptStripArg(/*@special@*/ poptContext con, int which)
   	/*@uses con->arg_strip, con->optionStack @*/
  @@ -727,7 +707,6 @@
   }
   /*@=bitwisesigned@*/
   
  -/*@-boundswrite@*/
   /* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
   int poptGetNextOpt(poptContext con)
   {
  @@ -848,7 +827,6 @@
   	}
   
   	/* Process next short option */
  -/*@-branchstate@*/		/* FIX: W2DO? */
   	if (con->os->nextCharArg) {
   	    origOptString = con->os->nextCharArg;
   
  @@ -875,7 +853,6 @@
   	    if (*origOptString != '\0')
   		con->os->nextCharArg = origOptString;
   	}
  -/*@=branchstate@*/
   
   	if (opt == NULL) return POPT_ERROR_BADOPT;	/* XXX can't happen */
   	if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE) {
  @@ -1045,17 +1022,14 @@
   
       return (opt ? opt->val : -1);	/* XXX can't happen */
   }
  -/*@=boundswrite@*/
   
   const char * poptGetOptArg(poptContext con)
   {
       const char * ret = NULL;
  -/*@-branchstate@*/
       if (con) {
   	ret = con->os->nextArg;
   	con->os->nextArg = NULL;
       }
  -/*@=branchstate@*/
       return ret;
   }
   
  @@ -1075,7 +1049,6 @@
       return ret;
   }
   
  -/*@-boundswrite@*/
   const char ** poptGetArgs(poptContext con)
   {
       if (con == NULL ||
  @@ -1089,7 +1062,6 @@
       return (con->leftovers + con->nextLeftover);
   /*@=nullret =nullstate @*/
   }
  -/*@=boundswrite@*/
   
   poptContext poptFreeContext(poptContext con)
   {
  @@ -1153,7 +1125,6 @@
       return poptAddItem(con, item, 0);
   }
   
  -/*@-boundswrite@*/
   int poptAddItem(poptContext con, poptItem newItem, int flags)
   {
       poptItem * items, item;
  @@ -1196,7 +1167,6 @@
   
       return 0;
   }
  -/*@=boundswrite@*/
   
   const char * poptBadOption(poptContext con, unsigned int flags)
   {
  @@ -1264,7 +1234,6 @@
       return (con->os->argv ? con->os->argv[0] : "");
   }
   
  -/*@-boundswrite@*/
   int poptStrippedArgv(poptContext con, int argc, char ** argv)
   {
       int numargs = argc;
  @@ -1288,4 +1257,3 @@
       
       return numargs;
   }
  -/*@=boundswrite@*/
  @@ .
  patch -p0 <<'@@ .'
  Index: popt/poptconfig.c
  ============================================================================
  $ cvs diff -u -r1.32 -r1.33 poptconfig.c
  --- popt/poptconfig.c	3 Nov 2007 22:50:33 -0000	1.32
  +++ popt/poptconfig.c	4 Nov 2007 13:15:32 -0000	1.33
  @@ -27,7 +27,6 @@
   	return;
       nameLength = strlen(con->appName);
       
  -/*@-boundswrite@*/
       memset(item, 0, sizeof(*item));
   
       if (strncmp(line, con->appName, nameLength)) return;
  @@ -85,7 +84,6 @@
   	item->argc = j;
       }
   /*@=modobserver@*/
  -/*@=boundswrite@*/
   	
   /*@-nullstate@*/ /* FIX: item->argv[] may be NULL */
       if (!strcmp(entryType, "alias"))
  @@ -128,7 +126,6 @@
   	return POPT_ERROR_ERRNO;
       }
   
  -/*@-boundswrite@*/
       dst = buf = malloc(fileLength + 1);
   
       chptr = file;
  @@ -160,7 +157,6 @@
   	}
       }
   /*@=infloops@*/
  -/*@=boundswrite@*/
   
       free(file);
       free(buf);
  @@ .
  patch -p0 <<'@@ .'
  Index: popt/popthelp.c
  ============================================================================
  $ cvs diff -u -r1.66 -r1.67 popthelp.c
  --- popt/popthelp.c	3 Nov 2007 22:50:33 -0000	1.66
  +++ popt/popthelp.c	4 Nov 2007 13:15:32 -0000	1.67
  @@ -21,9 +21,6 @@
   /*@access mbstate_t @*/
   #endif
   
  -#ifdef HAVE_ALLOCA_H
  -#include <alloca.h>
  -#endif
   
   #include "poptint.h"
   
  @@ -49,6 +46,7 @@
   	poptPrintHelp(con, stdout, 0);
       else
   	poptPrintUsage(con, stdout, 0);
  +
   /*@i@*/ con = poptFreeContext(con);		/* XXX keep valgrind happy */
       exit(0);
   }
  @@ -206,7 +204,6 @@
       char * l = le;
   
       if (le == NULL) return NULL;	/* XXX can't happen */
  -/*@-boundswrite@*/
       *le = '\0';
       *le++ = '(';
       strcpy(le, defstr);	le += strlen(le);
  @@ -256,7 +253,6 @@
       }
       *le++ = ')';
       *le = '\0';
  -/*@=boundswrite@*/
   
       return l;
   }
  @@ -289,7 +285,6 @@
       if (opt->longName)	nb += strlen(opt->longName);
       if (argDescrip)	nb += strlen(argDescrip);
   
  -/*@-boundswrite@*/
       left = malloc(nb);
       if (left == NULL) return;	/* XXX can't happen */
       left[0] = '\0';
  @@ -315,7 +310,6 @@
   	    *le++ = '[';
   
   	/* Choose type of output */
  -/*@-branchstate@*/
   	if (opt->argInfo & POPT_ARGFLAG_SHOW_DEFAULT) {
   	    defs = singleOptionDefaultValue(lineLength, opt, translation_domain);
   	    if (defs) {
  @@ -334,7 +328,6 @@
   		defs = t;
   	    }
   	}
  -/*@=branchstate@*/
   
   	if (opt->argDescrip == NULL) {
   	    switch (opt->argInfo & POPT_ARG_MASK) {
  @@ -409,7 +402,6 @@
   	    *le++ = ']';
   	*le = '\0';
       }
  -/*@=boundswrite@*/
   
       if (help)
   	POPT_fprintf(fp,"  %-*s   ", (int)(maxLeftCol+displaypad), left);
  @@ -419,13 +411,11 @@
       }
   
       left = _free(left);
  -/*@-branchstate@*/
       if (defs) {
   	help = defs;
       }
   
       helpLength = strlen(help);
  -/*@-boundsread@*/
       while (helpLength > lineLength) {
   	const char * ch;
   	char format[16];
  @@ -446,8 +436,6 @@
   	while (_isspaceptr(help) && *help) help++;
   	helpLength = strlen(help);
       }
  -/*@=boundsread@*/
  -/*@=branchstate@*/
   
       if (helpLength) POPT_fprintf(fp, "%s\n", help);
       help = NULL;
  @@ -498,9 +486,7 @@
   		mbstate_t t;
   		size_t n;
   
  -/*@-boundswrite@*/
   		memset ((void *)&t, 0, sizeof (t));	/* In initial state.  */
  -/*@=boundswrite@*/
   		/* Determine number of characters.  */
   		n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
   		len += sizeof("=")-1 + n;
  @@ -607,11 +593,9 @@
   
       fprintf(fp, POPT_("Usage:"));
       if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) {
  -/*@-boundsread@*/
   /*@-type@*/	/* LCL: wazzup? */
   	fn = con->optionStack->argv[0];
   /*@=type@*/
  -/*@=boundsread@*/
   	if (fn == NULL) return len;
   	if (strchr(fn, '/')) fn = strrchr(fn, '/') + 1;
   	fprintf(fp, " %s", fn);
  @@ -623,7 +607,7 @@
   
   void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
   {
  -    columns_t columns = memset(alloca(sizeof(*columns)), 0, sizeof(*columns));
  +    columns_t columns = calloc(1, sizeof(*columns));
   
       (void) showHelpIntro(con, fp);
       if (con->otherHelp)
  @@ -631,9 +615,11 @@
       else
   	fprintf(fp, " %s\n", POPT_("[OPTION...]"));
   
  +assert(columns);
       columns->cur = maxArgWidth(con->options, NULL);
       columns->max = maxColumnWidth(fp);
       singleTableHelp(con, fp, con->options, columns, NULL);
  +    free(columns);
   }
   
   /**
  @@ -681,9 +667,7 @@
   	mbstate_t t;
   	size_t n;
   
  -/*@-boundswrite@*/
   	memset ((void *)&t, 0, sizeof (t));	/* In initial state.  */
  -/*@=boundswrite@*/
   	/* Determine number of characters.  */
   	n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
   	len += sizeof("=")-1 + n;
  @@ -731,7 +715,6 @@
   {
       int i;
   
  -/*@-branchstate@*/		/* FIX: W2DO? */
       if (item != NULL)
       for (i = 0; i < nitems; i++, item++) {
   	const struct poptOption * opt;
  @@ -743,7 +726,6 @@
   	    columns->cur = singleOptionUsage(fp, columns, opt, translation_domain);
   	}
       }
  -/*@=branchstate@*/
   
       return columns->cur;
   }
  @@ -774,7 +756,6 @@
   	/*@globals fileSystem @*/
   	/*@modifies *fp, done, fileSystem @*/
   {
  -/*@-branchstate@*/		/* FIX: W2DO? */
       if (opt != NULL)
       for (; (opt->longName || opt->shortName || opt->arg) ; opt++) {
           if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INTL_DOMAIN) {
  @@ -783,9 +764,7 @@
   	    if (done) {
   		int i = 0;
   		for (i = 0; i < done->nopts; i++) {
  -/*@-boundsread@*/
   		    const void * that = done->opts[i];
  -/*@=boundsread@*/
   		    if (that == NULL || that != opt->arg)
   			/*@innercontinue@*/ continue;
   		    /*@innerbreak@*/ break;
  @@ -793,10 +772,8 @@
   		/* Skip if this table has already been processed. */
   		if (opt->arg == NULL || i < done->nopts)
   		    continue;
  -/*@-boundswrite@*/
   		if (done->nopts < done->maxopts)
   		    done->opts[done->nopts++] = (const void *) opt->arg;
  -/*@=boundswrite@*/
   	    }
   	    columns->cur = singleTableUsage(con, fp, columns, opt->arg,
   			translation_domain, done);
  @@ -805,7 +782,6 @@
   	    columns->cur = singleOptionUsage(fp, columns, opt, translation_domain);
   	}
       }
  -/*@=branchstate@*/
   
       return columns->cur;
   }
  @@ -832,7 +808,6 @@
       if (s == NULL)
   	return 0;
   
  -/*@-boundswrite@*/
       if (opt != NULL)
       for (; (opt->longName || opt->shortName || opt->arg); opt++) {
   	if (opt->shortName && !(opt->argInfo & POPT_ARG_MASK))
  @@ -841,7 +816,6 @@
   	    if (opt->arg)	/* XXX program error */
   		len = showShortOptions(opt->arg, fp, s);
       } 
  -/*@=boundswrite@*/
   
       /* On return to top level, print the short options, return print length. */
       if (s != str && *s != '\0') {
  @@ -855,21 +829,20 @@
   
   void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
   {
  -    columns_t columns = memset(alloca(sizeof(*columns)), 0, sizeof(*columns));
  +    columns_t columns = calloc(1, sizeof(*columns));
       struct poptDone_s done_buf;
       poptDone done = &done_buf;
   
       memset(done, 0, sizeof(*done));
       done->nopts = 0;
       done->maxopts = 64;
  +assert(columns);
       columns->cur = done->maxopts * sizeof(*done->opts);
       columns->max = maxColumnWidth(fp);
  -/*@-boundswrite@*/
       done->opts = calloc(1, columns->cur);
       /*@-keeptrans@*/
       done->opts[done->nopts++] = (const void *) con->options;
       /*@=keeptrans@*/
  -/*@=boundswrite@*/
   
       columns->cur = showHelpIntro(con, fp);
       columns->cur += showShortOptions(con->options, fp, NULL);
  @@ -885,6 +858,7 @@
   
       fprintf(fp, "\n");
       free(done->opts);
  +    free(columns);
   }
   
   void poptSetOtherOptionHelp(poptContext con, const char * text)
  @@ .
  patch -p0 <<'@@ .'
  Index: popt/poptparse.c
  ============================================================================
  $ cvs diff -u -r1.26 -r1.27 poptparse.c
  --- popt/poptparse.c	3 Nov 2007 22:50:33 -0000	1.26
  +++ popt/poptparse.c	4 Nov 2007 13:15:32 -0000	1.27
  @@ -10,7 +10,6 @@
   
   #define POPT_ARGV_ARRAY_GROW_DELTA 5
   
  -/*@-boundswrite@*/
   int poptDupArgv(int argc, const char **argv,
   		int * argcPtr, const char *** argvPtr)
   {
  @@ -33,12 +32,10 @@
       argv2 = (void *) dst;
       dst += (argc + 1) * sizeof(*argv);
   
  -/*@-branchstate@*/
       for (i = 0; i < argc; i++) {
   	argv2[i] = dst;
   	dst += strlen(strcpy(dst, argv[i])) + 1;
       }
  -/*@=branchstate@*/
       argv2[argc] = NULL;
   
       if (argvPtr) {
  @@ -51,9 +48,7 @@
   	*argcPtr = argc;
       return 0;
   }
  -/*@=boundswrite@*/
   
  -/*@-bounds@*/
   int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
   {
       const char * src;
  @@ -125,7 +120,6 @@
       if (argv) free(argv);
       return rc;
   }
  -/*@=bounds@*/
   
   /* still in the dev stage.
    * return values, perhaps 1== file erro
  @@ .
  patch -p0 <<'@@ .'
  Index: popt/test1.c
  ============================================================================
  $ cvs diff -u -r1.27 -r1.28 test1.c
  --- popt/test1.c	14 Jun 2007 08:11:52 -0000	1.27
  +++ popt/test1.c	4 Nov 2007 13:15:32 -0000	1.28
  @@ -254,7 +254,6 @@
       if (singleDash)
   	fprintf(stdout, " -");
   
  -/*@-boundsread@*/
       rest = poptGetArgs(optCon);
       if (rest) {
   	fprintf(stdout, " rest:");
  @@ -263,7 +262,6 @@
   	    rest++;
   	}
       }
  -/*@=boundsread@*/
   
       fprintf(stdout, "\n");
   
  @@ .
Received on Sun Nov 4 14:15:32 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.