RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 05-May-2017 19:43:51 Branch: rpm-5_4 Handle: 2017050517435100 Modified files: (Branch: rpm-5_4) rpm/lib rpmfi.c Log: - splint: RIP. Summary: Revision Changes Path 2.160.4.9 +31 -129 rpm/lib/rpmfi.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/lib/rpmfi.c ============================================================================ $ cvs diff -u -r2.160.4.8 -r2.160.4.9 rpmfi.c --- rpm/lib/rpmfi.c 5 May 2017 17:12:57 -0000 2.160.4.8 +++ rpm/lib/rpmfi.c 5 May 2017 17:43:51 -0000 2.160.4.9 @@ -39,14 +39,6 @@ #include "debug.h" -/*@access IOSM_t @*/ /* XXX cast */ - -/*@access rpmte @*/ -/*@access rpmts @*/ /* XXX cast */ - -/*@access FSM_t @*/ /* XXX fsm->repackaged */ -/*@access DIR @*/ - #ifdef __cplusplus GENfree(int *) GENpair(rpmuint16_t *) @@ -57,13 +49,10 @@ /** */ struct rpmRelocation_s { -/*@only@*/ /*@null@*/ const char * oldPath; /*!< NULL here evals to RPMTAG_DEFAULTPREFIX, */ -/*@only@*/ /*@null@*/ const char * newPath; /*!< NULL means to omit the file completely! */ }; -/*@unchecked@*/ int _rpmfi_debug = 0; /** @@ -72,15 +61,11 @@ * @param c character to strip * @return string */ -static /*@only@*/ -char * stripTrailingChar(/*@only@*/ char * s, char c) - /*@modifies *s */ +static char * stripTrailingChar(char * s, char c) { char * t; -/*@-boundswrite@*/ for (t = s + strlen(s) - 1; *t == c && t >= s; t--) *t = '\0'; -/*@=boundswrite@*/ return s; } @@ -417,10 +402,8 @@ if (fi->ddict != NULL && fddictx >= 0 && (fddictx+fddictn) <= (int)fi->nddict) fddict = fi->ddict + fddictx; } -/*@-dependenttrans -onlytrans @*/ if (fddictp) *fddictp = fddict; -/*@=dependenttrans =onlytrans @*/ return fddictn; } @@ -507,9 +490,7 @@ void * rpmfiBloomFN(const rpmfi fi) { -/*@-assignexpose -retexpose @*/ return (fi != NULL ? fi->_fnbf : NULL); -/*@=assignexpose =retexpose @*/ } void * rpmfiExclude(const rpmfi fi) @@ -561,10 +542,8 @@ } else fi->i = -1; -/*@-modfilesys @*/ if (_rpmfi_debug < 0 && i != -1) fprintf(stderr, "*** fi %p\t%s[%d] %s%s\n", fi, (fi->Type ? fi->Type : "?Type?"), i, (i >= 0 ? fi->dnl[fi->j] : ""), (i >= 0 ? fi->bnl[fi->i] : "")); -/*@=modfilesys @*/ } @@ -580,9 +559,7 @@ } } - /*@-refcounttrans@*/ return fi; - /*@=refcounttrans@*/ } int rpmfiNextD(rpmfi fi) @@ -595,10 +572,8 @@ else fi->j = -1; -/*@-modfilesys @*/ if (_rpmfi_debug < 0 && j != -1) fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, (fi->Type ? fi->Type : "?Type?"), j); -/*@=modfilesys @*/ } @@ -614,9 +589,7 @@ fi = NULL; } - /*@-refcounttrans@*/ return fi; - /*@=refcounttrans@*/ } /** @@ -624,9 +597,7 @@ * @param ft file type * @return string to identify a file type */ -static /*@observer@*/ -const char * rpmfiFtstring (rpmFileTypes ft) - /*@*/ +static const char * rpmfiFtstring (rpmFileTypes ft) { switch (ft) { case XDIR: return "directory"; @@ -638,7 +609,6 @@ case REG: return "file"; default: return "unknown file type"; } - /*@notreached@*/ } /** @@ -647,21 +617,17 @@ * @return file type */ static rpmFileTypes rpmfiWhatis(rpmuint16_t mode) - /*@*/ { if (S_ISDIR(mode)) return XDIR; if (S_ISCHR(mode)) return CDEV; if (S_ISBLK(mode)) return BDEV; if (S_ISLNK(mode)) return LINK; -/*@-unrecog@*/ if (S_ISSOCK(mode)) return SOCK; -/*@=unrecog@*/ if (S_ISFIFO(mode)) return PIPE; return REG; } int rpmfiCompare(const rpmfi afi, const rpmfi bfi) - /*@*/ { rpmFileTypes awhat = rpmfiWhatis(rpmfiFMode(afi)); rpmFileTypes bwhat = rpmfiWhatis(rpmfiFMode(bfi)); @@ -758,11 +724,9 @@ return FA_CREATE; /* unmodified config file, replace. */ } ndigest = rpmfiDigest(nfi, &nalgo, &nlen); -/*@-nullpass@*/ if (odigest && ndigest && oalgo == nalgo && olen == nlen && !memcmp(odigest, ndigest, nlen)) return FA_SKIP; /* identical file, don't bother. */ -/*@=nullpass@*/ } else /* dbWhat == LINK */ { const char * oFLink, * nFLink; oFLink = rpmfiFLink(ofi); @@ -774,10 +738,8 @@ return FA_CREATE; /* unmodified config file, replace. */ } nFLink = rpmfiFLink(nfi); -/*@-nullpass@*/ if (oFLink && nFLink && !strcmp(oFLink, nFLink)) return FA_SKIP; /* identical file, don't bother. */ -/*@=nullpass@*/ } /* @@ -789,7 +751,6 @@ return save; } -/*@observer@*/ const char * rpmfiTypeString(rpmfi fi) { switch(rpmteType((rpmte)fi->te)) { @@ -797,7 +758,6 @@ case TR_REMOVED: return " erase"; default: return "???"; } - /*@noteached@*/ } #define alloca_strdup(_s) strcpy((char *)alloca(strlen(_s)+1), (_s)) @@ -814,10 +774,6 @@ static Header relocateFileList(const rpmts ts, rpmfi fi, Header origH, iosmFileAction * actions) - /*@globals rpmGlobalMacroContext, h_errno, - internalState @*/ - /*@modifies ts, fi, origH, actions, rpmGlobalMacroContext, - internalState @*/ { HE_t he = (HE_t) memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmte p = rpmtsRelocateElement(ts); @@ -881,14 +837,10 @@ validRelocations = _free(validRelocations); } /* XXX FIXME multilib file actions need to be checked. */ -/*@-castexpose@*/ return headerLink(origH); -/*@=castexpose@*/ } -/*@-castexpose@*/ h = headerLink(origH); -/*@=castexpose@*/ { /* XXX coverity 1214105 */ size_t nb = numRelocations * sizeof(*relocations); @@ -921,11 +873,10 @@ ? t : stripTrailingChar(t, '/'); - /*@-nullpass@*/ /* FIX: relocations[i].oldPath == NULL */ /* Verify that the relocation's old path is in the header. */ for (j = 0; j < numValid; j++) { if (!strcmp(validRelocations[j], relocations[i].oldPath)) - /*@innerbreak@*/ break; + break; } /* XXX actions check prevents problem from being appended twice. */ @@ -938,7 +889,6 @@ } del = (int)strlen(relocations[i].newPath) - (int)strlen(relocations[i].oldPath); - /*@=nullpass@*/ if (del > reldel) reldel = del; @@ -956,12 +906,10 @@ if (relocations[j - 1].oldPath == NULL || /* XXX can't happen */ relocations[j ].oldPath == NULL || /* XXX can't happen */ strcmp(relocations[j - 1].oldPath, relocations[j].oldPath) <= 0) - /*@innercontinue@*/ continue; - /*@-usereleased@*/ /* LCL: ??? */ + continue; tmpReloc = relocations[j - 1]; relocations[j - 1] = relocations[j]; relocations[j] = tmpReloc; - /*@=usereleased@*/ madeSwap = 1; } if (!madeSwap) break; @@ -992,13 +940,13 @@ for (j = 0; j < numRelocations; j++) { if (relocations[j].oldPath == NULL || /* XXX can't happen */ strcmp(validRelocations[i], relocations[j].oldPath)) - /*@innercontinue@*/ continue; + continue; /* On install, a relocate to NULL means skip the path. */ if (relocations[j].newPath) { actualRelocations[numActual] = relocations[j].newPath; numActual++; } - /*@innerbreak@*/ break; + break; } if (j == numRelocations) { actualRelocations[numActual] = validRelocations[i]; @@ -1068,7 +1016,7 @@ if (fColors != NULL) { /* XXX pkgs may not have unique dirNames, so color all dirNames that match. */ for (j = 0; j < (int)dirCount; j++) { -if (strcmp(dirNames[dirIndexes[i]], dirNames[j])) /*@innercontinue@*/ continue; +if (strcmp(dirNames[dirIndexes[i]], dirNames[j])) continue; dColors[j] |= fColors[i]; } } @@ -1082,29 +1030,27 @@ */ for (j = numRelocations - 1; j >= 0; j--) { if (relocations[j].oldPath == NULL) /* XXX can't happen */ - /*@innercontinue@*/ continue; + continue; len = strcmp(relocations[j].oldPath, "/") ? strlen(relocations[j].oldPath) : 0; if (fnlen < len) - /*@innercontinue@*/ continue; + continue; /* * Only subdirectories or complete file paths may be relocated. We * don't check for '\0' as our directory names all end in '/'. */ if (!(fn[len] == '/' || fnlen == len)) - /*@innercontinue@*/ continue; + continue; if (strncmp(relocations[j].oldPath, fn, len)) - /*@innercontinue@*/ continue; - /*@innerbreak@*/ break; + continue; + break; } if (j < 0) continue; -/*@-nullderef@*/ /* FIX: fModes may be NULL */ ft = rpmfiWhatis(fModes[i]); -/*@=nullderef@*/ /* On install, a relocate to NULL means skip the path. */ if (relocations[j].newPath == NULL) { @@ -1114,10 +1060,10 @@ len = strlen(dirNames[j]) - 1; while (len > 0 && dirNames[j][len-1] == '/') len--; if (fnlen != len) - /*@innercontinue@*/ continue; + continue; if (strncmp(fn, dirNames[j], fnlen)) - /*@innercontinue@*/ continue; - /*@innerbreak@*/ break; + continue; + break; } } if (actions) { @@ -1143,20 +1089,18 @@ fnlen = te - fn; } else te = fn + strlen(fn); - /*@-nullpass -nullderef@*/ /* LCL: te != NULL here. */ if (strcmp(baseNames[i], te)) /* basename changed too? */ baseNames[i] = alloca_strdup(te); *te = '\0'; /* terminate new directory name */ - /*@=nullpass =nullderef@*/ } /* Does this directory already exist in the directory list? */ for (j = 0; j < (int)dirCount; j++) { if (fnlen != strlen(dirNames[j])) - /*@innercontinue@*/ continue; + continue; if (strncmp(fn, dirNames[j], fnlen)) - /*@innercontinue@*/ continue; - /*@innerbreak@*/ break; + continue; + break; } if (j < (int)dirCount) { @@ -1191,23 +1135,23 @@ /* XXX Don't autorelocate uncolored directories. */ if (j == p->autorelocatex && (dColors[i] == 0 || !(dColors[i] & mydColor))) - /*@innercontinue@*/ continue; + continue; if (relocations[j].oldPath == NULL) /* XXX can't happen */ - /*@innercontinue@*/ continue; + continue; len = strcmp(relocations[j].oldPath, "/") ? strlen(relocations[j].oldPath) : 0; if (len && strncmp(relocations[j].oldPath, dirNames[i], len)) - /*@innercontinue@*/ continue; + continue; /* * Only subdirectories or complete file paths may be relocated. We * don't check for '\0' as our directory names all end in '/'. */ if (dirNames[i][len] != '/') - /*@innercontinue@*/ continue; + continue; if (relocations[j].newPath) { /* Relocate the path */ const char * s = relocations[j].newPath; @@ -1258,9 +1202,7 @@ xx = headerMod(h, he, 0); fi->bnl = _free(fi->bnl); xx = headerGet(h, he, 0); -/*@-dependenttrans@*/ fi->bnl = he->p.argv; -/*@=dependenttrans@*/ fi->fc = he->c; he->tag = RPMTAG_DIRNAMES; @@ -1280,9 +1222,7 @@ xx = headerMod(h, he, 0); fi->dil = _free(fi->dil); xx = headerGet(h, he, 0); -/*@-dependenttrans@*/ fi->dil = he->p.ui32p; -/*@=dependenttrans@*/ } baseNames = _free(baseNames); @@ -1292,13 +1232,9 @@ fColors = _free(fColors); fModes = _free(fModes); -/*@-dependenttrans@*/ fn = _free(fn); -/*@=dependenttrans@*/ -/*@-retalias@*/ return h; -/*@=retalias@*/ } int rpmfiSetHeader(rpmfi fi, Header h) @@ -1306,15 +1242,12 @@ if (fi->h != NULL) (void)headerFree(fi->h); fi->h = NULL; -/*@-assignexpose -castexpose @*/ if (h != NULL) fi->h = headerLink(h); -/*@=assignexpose =castexpose @*/ return 0; } static void rpmfiFini(void * _fi) - /*@modifies *_fi @*/ { rpmfi fi = (rpmfi) _fi; @@ -1358,9 +1291,7 @@ fi->fddictn = _free(fi->fddictn); } -/*@-globs@*/ /* Avoid rpmGlobalMacroContext */ fi->fsm = freeFSM((IOSM_t)fi->fsm); -/*@=globs@*/ fi->_fnbf = rpmbfFree((rpmbf)fi->_fnbf); fi->exclude = (miRE) mireFreeAll(fi->exclude, fi->nexclude); @@ -1391,7 +1322,6 @@ * @return binary nibble */ static inline unsigned char nibble(char c) - /*@*/ { if (c >= '0' && c <= '9') return (c - '0'); @@ -1412,12 +1342,9 @@ xx = headerGet((_h), he, 0); \ _data = (_cast) he->p.ptr; -/*@-strictusereleased@*/ rpmfi rpmfiNew(const void * _ts, Header h, rpmTag tagN, int flags) { -/*@-castexpose@*/ const rpmts ts = (const rpmts) _ts; -/*@=castexpose@*/ int scareMem = (flags & 0x1); HE_t he = (HE_t) memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmte p; @@ -1623,12 +1550,10 @@ i = p->nrelocs; if (newPath != NULL && *newPath != '\0' && p->relocs != NULL) for (i = 0; i < p->nrelocs; i++) { -/*@-nullpass@*/ /* XXX {old,new}Path might be NULL */ if (strcmp(p->relocs[i].oldPath, "/")) continue; if (strcmp(p->relocs[i].newPath, newPath)) continue; -/*@=nullpass@*/ break; } @@ -1649,9 +1574,7 @@ if (fi->actions == NULL) /* XXX DYING */ fi->actions = (int *) xcalloc(fi->fc, sizeof(*fi->actions)); - /*@-compdef@*/ /* FIX: fi->digests undefined */ foo = relocateFileList(ts, fi, h, (iosmFileAction *) fi->actions); - /*@=compdef@*/ (void)headerFree(fi->h); fi->h = NULL; fi->h = headerLink(foo); @@ -1725,23 +1648,16 @@ fi->fperms = 0644; exit: -/*@-modfilesys@*/ if (_rpmfi_debug < 0) fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, Type, (fi ? fi->fc : 0)); -/*@=modfilesys@*/ - /*@-compdef -nullstate@*/ /* FIX: rpmfi null annotations */ return rpmfiLink(fi, (fi ? fi->Type : NULL)); - /*@=compdef =nullstate@*/ } -/*@=strictusereleased@*/ int rpmfiAddRelocation(rpmRelocation * relp, int * nrelp, const char * oldPath, const char * newPath) { -/*@-unqualifiedtrans@*/ *relp = (rpmRelocation) xrealloc(*relp, sizeof(**relp) * ((*nrelp) + 1)); -/*@=unqualifiedtrans@*/ (*relp)[*nrelp].oldPath = (oldPath ? xstrdup(oldPath) : NULL); (*relp)[*nrelp].newPath = (newPath ? xstrdup(newPath) : NULL); (*nrelp)++; @@ -1836,10 +1752,8 @@ break; } -/*@-modfilesys@*/ if (_rpmfi_debug) fprintf(stderr, "*** rpmfiStat(%p, %s, %p) rc %d\n", fi, path, st, rc); -/*@=modfilesys@*/ return rc; } @@ -1880,16 +1794,13 @@ fnames = argvFree(fnames); fmodes = _free(fmodes); -/*@-modfilesys +voidabstract @*/ if (_rpmfi_debug) fprintf(stderr, "*** rpmfiOpendir(%p, %s) dir %p\n", fi, name, dir); -/*@=modfilesys =voidabstract @*/ return (void *)dir; } -void rpmfiBuildFClasses(Header h, - /*@out@*/ const char *** fclassp, /*@out@*/ rpmuint32_t * fcp) +void rpmfiBuildFClasses(Header h, const char *** fclassp, rpmuint32_t * fcp) { int scareMem = 0; rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); @@ -1941,8 +1852,7 @@ } #ifdef DYING -void rpmfiBuildFContexts(Header h, - /*@out@*/ const char *** fcontextp, /*@out@*/ rpmuint32_t * fcp) +void rpmfiBuildFContexts(Header h, const char *** fcontextp, rpmuint32_t * fcp) { int scareMem = 0; rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); @@ -1993,8 +1903,7 @@ if (fcp) *fcp = ac; } -void rpmfiBuildFSContexts(Header h, - /*@out@*/ const char *** fcontextp, /*@out@*/ rpmuint32_t * fcp) +void rpmfiBuildFSContexts(Header h, const char *** fcontextp, rpmuint32_t * fcp) { int scareMem = 0; rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); @@ -2061,8 +1970,7 @@ if (fcp) *fcp = ac; } -void rpmfiBuildREContexts(Header h, - /*@out@*/ const char *** fcontextp, /*@out@*/ rpmuint32_t * fcp) +void rpmfiBuildREContexts(Header h, const char *** fcontextp, rpmuint32_t * fcp) { int scareMem = 0; rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); @@ -2081,10 +1989,8 @@ /* Read security context patterns. */ { const char *fn = rpmGetPath("%{?__file_context_path}", NULL); -/*@-moduncon -noeffectuncon @*/ if (fn != NULL && *fn != '\0') (void)matchpathcon_init(fn); -/*@=moduncon =noeffectuncon @*/ fn = _free(fn); } @@ -2102,7 +2008,6 @@ fn = rpmfiFN(fi); fmode = rpmfiFMode(fi); scon = NULL; -/*@-moduncon@*/ if (matchpathcon(fn, fmode, &scon) == 0 && scon != NULL) { fcnb[ac] = strlen(scon) + 1; if (fcnb[ac] > 0) { @@ -2112,7 +2017,6 @@ } freecon(scon); } -/*@=moduncon@*/ ac++; } @@ -2135,9 +2039,7 @@ av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */ exit: -/*@-moduncon -noeffectuncon @*/ matchpathcon_fini(); -/*@=moduncon =noeffectuncon @*/ fi = rpmfiFree(fi); if (fcontextp) *fcontextp = av; @@ -2148,7 +2050,7 @@ #endif void rpmfiBuildFDeps(Header h, rpmTag tagN, - /*@out@*/ const char *** fdepsp, /*@out@*/ rpmuint32_t * fcp) + const char *** fdepsp, rpmuint32_t * fcp) { int scareMem = 0; rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); @@ -2189,11 +2091,11 @@ ix = *ddict++; mydt = ((ix >> 24) & 0xff); if (mydt != deptype) - /*@innercontinue@*/ continue; + continue; ix &= 0x00ffffff; (void) rpmdsSetIx(ds, ix-1); if (rpmdsNext(ds) < 0) - /*@innercontinue@*/ continue; + continue; DNEVR = rpmdsDNEVR(ds); if (DNEVR != NULL) nb += strlen(DNEVR+2) + 1; @@ -2216,11 +2118,11 @@ ix = *ddict++; mydt = ((ix >> 24) & 0xff); if (mydt != deptype) - /*@innercontinue@*/ continue; + continue; ix &= 0x00ffffff; (void) rpmdsSetIx(ds, ix-1); if (rpmdsNext(ds) < 0) - /*@innercontinue@*/ continue; + continue; DNEVR = rpmdsDNEVR(ds); if (DNEVR != NULL) { t = stpcpy(t, DNEVR+2); @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org