diff options
-rw-r--r-- | .splintrc | 35 | ||||
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | findme.c | 2 | ||||
-rw-r--r-- | popt.c | 32 | ||||
-rw-r--r-- | poptconfig.c | 4 | ||||
-rw-r--r-- | popthelp.c | 40 | ||||
-rw-r--r-- | poptparse.c | 6 | ||||
-rw-r--r-- | test1.c | 2 |
8 files changed, 43 insertions, 81 deletions
@@ -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 @@ -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). @@ -30,7 +30,6 @@ const char * POPT_findProgramPath(const char * argv0) strcpy(pathbuf, path); chptr = NULL; -/*@-branchstate@*/ do { if ((chptr = strchr(start, ':'))) *chptr = '\0'; @@ -46,7 +45,6 @@ const char * POPT_findProgramPath(const char * argv0) else start = NULL; } while (start && *start); -/*@=branchstate@*/ exit: if (pathbuf) @@ -70,10 +70,8 @@ static void invokeCallbacksPRE(poptContext con, const struct poptOption * opt) 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 @@ static void invokeCallbacksPOST(poptContext con, const struct poptOption * opt) 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 @@ static void invokeCallbacksOPTION(poptContext con, 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 @@ static void cleanOSE(/*@special@*/ struct optionStackEntry *os) os->argb = PBM_FREE(os->argb); } -/*@-boundswrite@*/ void poptResetContext(poptContext con) { int i; @@ -255,10 +248,8 @@ void poptResetContext(poptContext con) 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 @@ static int handleExec(/*@special@*/ poptContext con, return 1; } -/*@=boundswrite@*/ /* Only one of longName, shortName may be set at a time */ static int handleAlias(/*@special@*/ poptContext con, @@ -353,10 +343,8 @@ static int handleAlias(/*@special@*/ poptContext con, 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 @@ static int handleAlias(/*@special@*/ poptContext con, return (rc ? rc : 1); } -/*@-bounds -boundswrite @*/ static int execCommand(poptContext con) /*@globals internalState @*/ /*@modifies internalState @*/ @@ -469,9 +456,7 @@ exit: } 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 @@ findOption(const struct poptOption * opt, /*@null@*/ const char * longName, int 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 @@ findOption(const struct poptOption * opt, /*@null@*/ const char * longName, int return opt; } -/*@=boundswrite@*/ static const char * findNextArg(/*@special@*/ poptContext con, unsigned argx, int delete_arg) @@ -581,7 +563,6 @@ static const char * findNextArg(/*@special@*/ poptContext con, return arg; } -/*@-boundswrite@*/ static /*@only@*/ /*@null@*/ const char * expandNextArg(/*@special@*/ poptContext con, const char * s) /*@uses con->optionStack, con->os, @@ -630,7 +611,6 @@ expandNextArg(/*@special@*/ poptContext con, const char * s) 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 @@ int poptSaveInt(/*@null@*/ int * arg, unsigned int argInfo, long aLong) } /*@=bitwisesigned@*/ -/*@-boundswrite@*/ /* returns 'val' element, -1 on last item, POPT_ERROR_* on error */ int poptGetNextOpt(poptContext con) { @@ -848,7 +827,6 @@ int poptGetNextOpt(poptContext con) } /* Process next short option */ -/*@-branchstate@*/ /* FIX: W2DO? */ if (con->os->nextCharArg) { origOptString = con->os->nextCharArg; @@ -875,7 +853,6 @@ int poptGetNextOpt(poptContext con) 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 @@ int poptGetNextOpt(poptContext con) 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 @@ const char * poptPeekArg(poptContext con) return ret; } -/*@-boundswrite@*/ const char ** poptGetArgs(poptContext con) { if (con == NULL || @@ -1089,7 +1062,6 @@ const char ** poptGetArgs(poptContext con) return (con->leftovers + con->nextLeftover); /*@=nullret =nullstate @*/ } -/*@=boundswrite@*/ poptContext poptFreeContext(poptContext con) { @@ -1153,7 +1125,6 @@ int poptAddAlias(poptContext con, struct poptAlias alias, return poptAddItem(con, item, 0); } -/*@-boundswrite@*/ int poptAddItem(poptContext con, poptItem newItem, int flags) { poptItem * items, item; @@ -1196,7 +1167,6 @@ int poptAddItem(poptContext con, poptItem newItem, int flags) return 0; } -/*@=boundswrite@*/ const char * poptBadOption(poptContext con, unsigned int flags) { @@ -1264,7 +1234,6 @@ const char * poptGetInvocationName(poptContext con) return (con->os->argv ? con->os->argv[0] : ""); } -/*@-boundswrite@*/ int poptStrippedArgv(poptContext con, int argc, char ** argv) { int numargs = argc; @@ -1288,4 +1257,3 @@ int poptStrippedArgv(poptContext con, int argc, char ** argv) return numargs; } -/*@=boundswrite@*/ diff --git a/poptconfig.c b/poptconfig.c index 3f60d46..165f534 100644 --- a/poptconfig.c +++ b/poptconfig.c @@ -27,7 +27,6 @@ static void configLine(poptContext con, char * line) return; nameLength = strlen(con->appName); -/*@-boundswrite@*/ memset(item, 0, sizeof(*item)); if (strncmp(line, con->appName, nameLength)) return; @@ -85,7 +84,6 @@ static void configLine(poptContext con, char * line) item->argc = j; } /*@=modobserver@*/ -/*@=boundswrite@*/ /*@-nullstate@*/ /* FIX: item->argv[] may be NULL */ if (!strcmp(entryType, "alias")) @@ -128,7 +126,6 @@ int poptReadConfigFile(poptContext con, const char * fn) return POPT_ERROR_ERRNO; } -/*@-boundswrite@*/ dst = buf = malloc(fileLength + 1); chptr = file; @@ -160,7 +157,6 @@ int poptReadConfigFile(poptContext con, const char * fn) } } /*@=infloops@*/ -/*@=boundswrite@*/ free(file); free(buf); @@ -21,9 +21,6 @@ /*@access mbstate_t @*/ #endif -#ifdef HAVE_ALLOCA_H -#include <alloca.h> -#endif #include "poptint.h" @@ -49,6 +46,7 @@ static void displayArgs(poptContext con, poptPrintHelp(con, stdout, 0); else poptPrintUsage(con, stdout, 0); + /*@i@*/ con = poptFreeContext(con); /* XXX keep valgrind happy */ exit(0); } @@ -206,7 +204,6 @@ singleOptionDefaultValue(size_t lineLength, 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 @@ singleOptionDefaultValue(size_t lineLength, } *le++ = ')'; *le = '\0'; -/*@=boundswrite@*/ return l; } @@ -289,7 +285,6 @@ static void singleOptionHelp(FILE * fp, columns_t columns, 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 @@ static void singleOptionHelp(FILE * fp, columns_t columns, *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 @@ static void singleOptionHelp(FILE * fp, columns_t columns, defs = t; } } -/*@=branchstate@*/ if (opt->argDescrip == NULL) { switch (opt->argInfo & POPT_ARG_MASK) { @@ -409,7 +402,6 @@ static void singleOptionHelp(FILE * fp, columns_t columns, *le++ = ']'; *le = '\0'; } -/*@=boundswrite@*/ if (help) POPT_fprintf(fp," %-*s ", (int)(maxLeftCol+displaypad), left); @@ -419,13 +411,11 @@ static void singleOptionHelp(FILE * fp, columns_t columns, } 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 @@ static void singleOptionHelp(FILE * fp, columns_t columns, while (_isspaceptr(help) && *help) help++; helpLength = strlen(help); } -/*@=boundsread@*/ -/*@=branchstate@*/ if (helpLength) POPT_fprintf(fp, "%s\n", help); help = NULL; @@ -498,9 +486,7 @@ static size_t maxArgWidth(const struct poptOption * opt, 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 @@ static size_t showHelpIntro(poptContext con, FILE * fp) 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 @@ static size_t showHelpIntro(poptContext con, FILE * fp) 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 @@ void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags) 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 @@ static size_t singleOptionUsage(FILE * fp, columns_t columns, 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 @@ static size_t itemUsage(FILE * fp, columns_t columns, { int i; -/*@-branchstate@*/ /* FIX: W2DO? */ if (item != NULL) for (i = 0; i < nitems; i++, item++) { const struct poptOption * opt; @@ -743,7 +726,6 @@ static size_t itemUsage(FILE * fp, columns_t columns, columns->cur = singleOptionUsage(fp, columns, opt, translation_domain); } } -/*@=branchstate@*/ return columns->cur; } @@ -774,7 +756,6 @@ static size_t singleTableUsage(poptContext con, FILE * fp, columns_t columns, /*@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 @@ static size_t singleTableUsage(poptContext con, FILE * fp, columns_t columns, 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 @@ static size_t singleTableUsage(poptContext con, FILE * fp, columns_t columns, /* 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 @@ static size_t singleTableUsage(poptContext con, FILE * fp, columns_t columns, columns->cur = singleOptionUsage(fp, columns, opt, translation_domain); } } -/*@=branchstate@*/ return columns->cur; } @@ -832,7 +808,6 @@ static size_t showShortOptions(const struct poptOption * opt, FILE * fp, 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 @@ static size_t showShortOptions(const struct poptOption * opt, FILE * fp, 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 @@ static size_t showShortOptions(const struct poptOption * opt, FILE * fp, 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 @@ void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags) fprintf(fp, "\n"); free(done->opts); + free(columns); } void poptSetOtherOptionHelp(poptContext con, const char * text) diff --git a/poptparse.c b/poptparse.c index e58bd8d..f577a02 100644 --- a/poptparse.c +++ b/poptparse.c @@ -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 @@ int poptDupArgv(int argc, const char **argv, 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 @@ int poptDupArgv(int argc, const char **argv, *argcPtr = argc; return 0; } -/*@=boundswrite@*/ -/*@-bounds@*/ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr) { const char * src; @@ -125,7 +120,6 @@ exit: if (argv) free(argv); return rc; } -/*@=bounds@*/ /* still in the dev stage. * return values, perhaps 1== file erro @@ -254,7 +254,6 @@ int main(int argc, const char ** argv) if (singleDash) fprintf(stdout, " -"); -/*@-boundsread@*/ rest = poptGetArgs(optCon); if (rest) { fprintf(stdout, " rest:"); @@ -263,7 +262,6 @@ int main(int argc, const char ** argv) rest++; } } -/*@=boundsread@*/ fprintf(stdout, "\n"); |