# don't-bother-me-yet parameters
#-branchstate
#-immediatetrans
--mustfree
+-mustfree # alloca is painful
#-observertrans
#-statictrans
-type
-# -weak paramaters
+# not-yet -weak paramaters
#+boolint
#-boolops
#+ignorequals
Package pkg;
#if 0
- unlink(spec->specFile);
+ Unlink(spec->specFile);
#endif
for (p = spec->sources; p != NULL; p = p->next) {
if (! (p->flags & RPMBUILD_ISNO)) {
const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
- unlink(fn);
- free((void *)fn);
+ Unlink(fn);
+ fn = _free(fn);
}
}
for (p = pkg->icon; p != NULL; p = p->next) {
if (! (p->flags & RPMBUILD_ISNO)) {
const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
- unlink(fn);
- free((void *)fn);
+ Unlink(fn);
+ fn = _free(fn);
}
}
}
if (scriptName) {
if (!rc)
Unlink(scriptName);
- free((void *)scriptName);
+ scriptName = _free(scriptName);
}
if (u) {
switch (u->urltype) {
break;
}
}
- FREE(argv);
- FREE(buildCmd);
- FREE(buildTemplate);
- FREE(buildPost);
- FREE(buildDirURL);
+ argv = _free(argv);
+ buildCmd = _free(buildCmd);
+ buildTemplate = _free(buildTemplate);
+ buildPost = _free(buildPost);
+ buildDirURL = _free(buildDirURL);
return rc;
}
doRmSource(spec);
if (what & RPMBUILD_RMSPEC)
- unlink(spec->specFile);
+ Unlink(spec->specFile);
exit:
if (rc && rpmlogGetNrecs() > 0) {
static void valueFree( /*@only@*/ Value v)
{
if (v) {
- if (v->type == VALUE_TYPE_STRING) free((void *)v->data.s);
- free(v);
+ if (v->type == VALUE_TYPE_STRING)
+ v->data.s = _free(v->data.s);
+ v = _free(v);
}
}
char *p = state->p;
/* Skip whitespace before the next token. */
- while (*p && isspace(*p)) p++;
+ while (*p && xisspace(*p)) p++;
switch (*p) {
case '\0':
break;
default:
- if (isdigit(*p)) {
+ if (xisdigit(*p)) {
char temp[EXPRBUFSIZ], *t = temp;
- while (*p && isdigit(*p))
+ while (*p && xisdigit(*p))
*t++ = *p++;
*t++ = '\0';
p--;
token = TOK_INTEGER;
v = valueMakeInteger(atoi(temp));
- } else if (isalpha(*p)) {
+ } else if (xisalpha(*p)) {
char temp[EXPRBUFSIZ], *t = temp;
- while (*p && (isalnum(*p) || *p == '_'))
+ while (*p && (xisalnum(*p) || *p == '_'))
*t++ = *p++;
*t++ = '\0';
p--;
/* Parse the expression. */
v = doLogical(&state);
if (!v) {
- free(state.str);
+ state.str = _free(state.str);
return -1;
}
/* If the next token is not TOK_EOF, we have a syntax error. */
if (state.nextToken != TOK_EOF) {
rpmError(RPMERR_BADSPEC, _("syntax error in expression\n"));
- free(state.str);
+ state.str = _free(state.str);
return -1;
}
break;
}
- free(state.str);
+ state.str = _free(state.str);
valueFree(v);
return result;
}
/* Parse the expression. */
v = doLogical(&state);
if (!v) {
- free(state.str);
+ state.str = _free(state.str);
return NULL;
}
/* If the next token is not TOK_EOF, we have a syntax error. */
if (state.nextToken != TOK_EOF) {
rpmError(RPMERR_BADSPEC, _("syntax error in expression\n"));
- free(state.str);
+ state.str = _free(state.str);
return NULL;
}
break;
}
- free(state.str);
+ state.str = _free(state.str);
valueFree(v);
return result;
}
/*@access TFI_t @*/
/*@access FD_t @*/
-#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;}
-#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;}
+#define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
+#define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
#define MAXDOCDIR 1024
extern int _noDirTokens;
-#define SPECD_DEFFILEMODE (1<<0)
-#define SPECD_DEFDIRMODE (1<<1)
-#define SPECD_DEFUID (1<<2)
-#define SPECD_DEFGID (1<<3)
-#define SPECD_DEFVERIFY (1<<4)
-
-#define SPECD_FILEMODE (1<<8)
-#define SPECD_DIRMODE (1<<9)
-#define SPECD_UID (1<<10)
-#define SPECD_GID (1<<11)
-#define SPECD_VERIFY (1<<12)
+/**
+ */
+typedef enum specdFlags_e {
+ SPECD_DEFFILEMODE = (1 << 0),
+ SPECD_DEFDIRMODE = (1 << 1),
+ SPECD_DEFUID = (1 << 2),
+ SPECD_DEFGID = (1 << 3),
+ SPECD_DEFVERIFY = (1 << 4),
+
+ SPECD_FILEMODE = (1 << 8),
+ SPECD_DIRMODE = (1 << 9),
+ SPECD_UID = (1 << 10),
+ SPECD_GID = (1 << 11),
+ SPECD_VERIFY = (1 << 12)
+} specdFlags;
/**
*/
-typedef struct {
+typedef struct FileListRec_s {
struct stat fl_st;
#define fl_dev fl_st.st_dev
#define fl_ino fl_st.st_ino
#define fl_size fl_st.st_size
#define fl_mtime fl_st.st_mtime
- const char *diskURL; /* get file from here */
- const char *fileURL; /* filename in cpio archive */
- /*@observer@*/ const char *uname;
- /*@observer@*/ const char *gname;
+/*@only@*/ const char * diskURL; /* get file from here */
+/*@only@*/ const char * fileURL; /* filename in cpio archive */
+/*@observer@*/ const char * uname;
+/*@observer@*/ const char * gname;
int flags;
- int specdFlags; /* which attributes have been explicitly specified. */
+ specdFlags specdFlags; /* which attributes have been explicitly specified. */
int verifyFlags;
- const char *langs; /* XXX locales separated with | */
-} FileListRec;
+/*@only@*/ const char *langs; /* XXX locales separated with | */
+} * FileListRec;
/**
*/
-typedef struct {
- const char *ar_fmodestr;
- const char *ar_dmodestr;
- const char *ar_user;
- const char *ar_group;
+typedef struct AttrRec_s {
+ const char * ar_fmodestr;
+ const char * ar_dmodestr;
+ const char * ar_user;
+ const char * ar_group;
mode_t ar_fmode;
mode_t ar_dmode;
-} AttrRec;
+} * AttrRec;
/**
*/
/**
* Package file tree walk data.
*/
-struct FileList {
- const char *buildRootURL;
- const char *prefix;
+typedef struct FileList_s {
+/*@only@*/ const char * buildRootURL;
+/*@only@*/ const char * prefix;
int fileCount;
int totalFileSize;
int isDir;
int inFtw;
int currentFlags;
- int currentSpecdFlags;
+ specdFlags currentSpecdFlags;
int currentVerifyFlags;
- AttrRec cur_ar;
- AttrRec def_ar;
- int defSpecdFlags;
+ struct AttrRec_s cur_ar;
+ struct AttrRec_s def_ar;
+ specdFlags defSpecdFlags;
int defVerifyFlags;
int nLangs;
- /*@only@*/ const char **currentLangs;
+/*@only@*/ const char ** currentLangs;
/* Hard coded limit of MAXDOCDIR docdirs. */
/* If you break it you are doing something wrong. */
- const char *docDirs[MAXDOCDIR];
+ const char * docDirs[MAXDOCDIR];
int docDirCount;
- FileListRec *fileList;
+/*@only@*/ FileListRec fileList;
int fileListRecsAlloced;
int fileListRecsUsed;
-};
+} * FileList;
/**
*/
-static void nullAttrRec(/*@out@*/AttrRec *ar)
+static void nullAttrRec(/*@out@*/ AttrRec ar)
{
ar->ar_fmodestr = NULL;
ar->ar_dmodestr = NULL;
/**
*/
-static void freeAttrRec(AttrRec *ar)
+static void freeAttrRec(AttrRec ar)
{
- FREE(ar->ar_fmodestr);
- FREE(ar->ar_dmodestr);
- FREE(ar->ar_user);
- FREE(ar->ar_group);
+ ar->ar_fmodestr = _free(ar->ar_fmodestr);
+ ar->ar_dmodestr = _free(ar->ar_dmodestr);
+ ar->ar_user = _free(ar->ar_user);
+ ar->ar_group = _free(ar->ar_group);
/* XXX doesn't free ar (yet) */
}
/**
*/
-static void dupAttrRec(AttrRec *oar, /*@out@*/ AttrRec *nar)
+static void dupAttrRec(const AttrRec oar, /*@in@*/ /*@out@*/ AttrRec nar)
{
- if (oar == nar) /* XXX pathological paranoia */
+ if (oar == nar)
return;
freeAttrRec(nar);
nar->ar_fmodestr = (oar->ar_fmodestr ? xstrdup(oar->ar_fmodestr) : NULL);
#if 0
/**
*/
-static void dumpAttrRec(const char *msg, AttrRec *ar) {
+static void dumpAttrRec(const char *msg, AttrRec ar) {
if (msg)
fprintf(stderr, "%s:\t", msg);
fprintf(stderr, "(%s, %s, %s, %s)\n",
*/
static void timeCheck(int tc, Header h)
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
int *mtime;
- char **files;
- int count, x, currentTime;
-
- headerGetEntry(h, RPMTAG_OLDFILENAMES, NULL, (void **) &files, &count);
- headerGetEntry(h, RPMTAG_FILEMTIMES, NULL, (void **) &mtime, NULL);
+ const char ** files;
+ int fnt;
+ int count, x;
+ time_t currentTime = time(NULL);
- currentTime = time(NULL);
+ hge(h, RPMTAG_OLDFILENAMES, &fnt, (void **) &files, &count);
+ hge(h, RPMTAG_FILEMTIMES, NULL, (void **) &mtime, NULL);
for (x = 0; x < count; x++) {
- if (currentTime - mtime[x] > tc) {
+ if ((currentTime - mtime[x]) > tc)
rpmMessage(RPMMESS_WARNING, _("TIMECHECK failure: %s\n"), files[x]);
- }
}
- FREE(files);
+ files = hfd(files, fnt);
}
/**
/**
* @param fl package file tree walk data
*/
-static int parseForVerify(char *buf, struct FileList *fl)
+static int parseForVerify(char *buf, FileList fl)
{
char *p, *pe, *q;
const char *name;
int *resultVerify;
int not;
int verifyFlags;
- int *specdFlags;
+ specdFlags * specdFlags;
if ((p = strstr(buf, (name = "%verify"))) != NULL) {
resultVerify = &(fl->currentVerifyFlags);
/**
* @param fl package file tree walk data
*/
-static int parseForAttr(char *buf, struct FileList *fl)
+static int parseForAttr(char *buf, FileList fl)
{
char *p, *pe, *q;
const char *name;
int x;
- AttrRec arbuf, *ar = &arbuf, *ret_ar;
- int *specdFlags = NULL;
+ struct AttrRec_s arbuf;
+ AttrRec ar = &arbuf, ret_ar;
+ specdFlags * specdFlags;
if ((p = strstr(buf, (name = "%attr"))) != NULL) {
ret_ar = &(fl->cur_ar);
/**
* @param fl package file tree walk data
*/
-static int parseForConfig(char *buf, struct FileList *fl)
+static int parseForConfig(char *buf, FileList fl)
{
char *p, *pe, *q;
const char *name;
/**
* @param fl package file tree walk data
*/
-static int parseForLang(char *buf, struct FileList *fl)
+static int parseForLang(char *buf, FileList fl)
{
char *p, *pe, *q;
const char *name;
/**
*/
-static int parseForRegexLang(const char *fileName, /*@out@*/char **lang)
+static int parseForRegexLang(const char * fileName, /*@out@*/ char ** lang)
{
static int initialized = 0;
static int hasRegex = 0;
rc = 1;
else if (regcomp(&compiledPatt, patt, REG_EXTENDED))
rc = -1;
- free((void *)patt);
+ patt = _free(patt);
if (rc)
return rc;
hasRegex = 1;
initialized = 1;
}
+ memset(matches, 0, sizeof(matches));
if (! hasRegex || regexec(&compiledPatt, fileName, 2, matches, REG_NOTEOL))
return 1;
rc = 1;
else if (regcomp(&compiledPatt, patt, REG_EXTENDED | REG_NOSUB))
rc = -1;
- free((void *)patt);
+ patt = _free(patt);
if (rc)
return rc;
hasRegex = 1;
* @param fl package file tree walk data
*/
static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char *buf,
- struct FileList *fl, const char **fileName)
+ FileList fl, const char ** fileName)
{
char *s, *t;
int res, specialDoc = 0;
ddir = rpmGetPath("%{_docdir}/", n, "-", v, NULL);
strcpy(buf, ddir);
- free((void *)ddir);
+ ddir = _free(ddir);
}
/* XXX FIXME: this is easy to do as macro expansion */
*/
static int compareFileListRecs(const void *ap, const void *bp)
{
- const char *a = ((FileListRec *)ap)->fileURL;
- const char *b = ((FileListRec *)bp)->fileURL;
+ const char *a = ((FileListRec)ap)->fileURL;
+ const char *b = ((FileListRec)bp)->fileURL;
return strcmp(a, b);
}
/**
* @param fl package file tree walk data
*/
-static int isDoc(struct FileList *fl, const char *fileName)
+static int isDoc(FileList fl, const char * fileName)
{
int x = fl->docDirCount;
* @todo only %lang for now, finish other attributes later.
* @param fl package file tree walk data
*/
-static void checkHardLinks(struct FileList *fl)
+static void checkHardLinks(FileList fl)
{
char nlangs[BUFSIZ];
- FileListRec *ilp, *jlp;
+ FileListRec ilp, jlp;
int i, j;
for (i = 0; i < fl->fileListRecsUsed; i++) {
if (te == nlangs)
continue;
- free((void *)ilp->langs);
+ ilp->langs = _free(ilp->langs);
ilp->langs = xstrdup(nlangs);
for (j = i + 1; j < fl->fileListRecsUsed; j++) {
jlp = fl->fileList + j;
if (ilp->fl_dev != jlp->fl_dev)
continue;
jlp->flags |= RPMFILE_SPECFILE;
- free((void *)jlp->langs);
+ jlp->langs = _free(jlp->langs);
jlp->langs = xstrdup(nlangs);
}
}
* @todo Remove RPMTAG_OLDFILENAMES, add dirname/basename instead.
* @param fl package file tree walk data
*/
-static void genCpioListAndHeader(struct FileList *fl, TFI_t *cpioList,
- Header h, int isSrc)
+static void genCpioListAndHeader(/*@partial@*/ FileList fl,
+ TFI_t *cpioList, Header h, int isSrc)
{
int _addDotSlash = !(isSrc || rpmExpandNumeric("%{_noPayloadPrefix}"));
uint_32 multiLibMask = 0;
int apathlen = 0;
int dpathlen = 0;
int skipLen = 0;
- FileListRec *flp;
+ FileListRec flp;
char buf[BUFSIZ];
int i;
if (flp->flags & RPMFILE_MULTILIB_MASK)
multiLibMask |=
- (1 << ((flp->flags & RPMFILE_MULTILIB_MASK))
+ (1u << ((flp->flags & RPMFILE_MULTILIB_MASK))
>> RPMFILE_MULTILIB_SHIFT);
/*
fi->type = TR_ADDED;
loadFi(h, fi);
- if (fi->dnl) {
- free((void *)fi->dnl); fi->dnl = NULL;
- }
- if (fi->bnl) {
- free((void *)fi->bnl); fi->bnl = NULL;
- }
+ fi->dnl = _free(fi->dnl);
+ fi->bnl = _free(fi->bnl);
fi->dnl = xmalloc(fi->fc * sizeof(*fi->dnl) + dpathlen);
d = (char *)(fi->dnl + fi->fc);
if (cpioList)
*cpioList = fi;
else
- free(fi);
+ fi = _free(fi);
}
}
/**
*/
-static void freeFileList(FileListRec *fileList, int count)
+static /*@null@*/ FileListRec freeFileList(/*@only@*/ FileListRec fileList, int count)
{
while (count--) {
- FREE(fileList[count].diskURL);
- FREE(fileList[count].fileURL);
- FREE(fileList[count].langs);
+ fileList[count].diskURL = _free(fileList[count].diskURL);
+ fileList[count].fileURL = _free(fileList[count].fileURL);
+ fileList[count].langs = _free(fileList[count].langs);
}
- FREE(fileList);
+ fileList = _free(fileList);
+ return NULL;
}
/**
* @param fl package file tree walk data
*/
-static int addFile(struct FileList *fl, const char * diskURL, struct stat *statp)
+static int addFile(FileList fl, const char * diskURL, struct stat *statp)
{
const char *fileURL = diskURL;
struct stat statbuf;
fl->fileListRecsAlloced * sizeof(*(fl->fileList)));
}
- { FileListRec * flp = &fl->fileList[fl->fileListRecsUsed];
+ { FileListRec flp = &fl->fileList[fl->fileListRecsUsed];
flp->fl_st = *statp; /* structure assignment */
flp->fl_mode = fileMode;
/**
* @param fl package file tree walk data
*/
-static int processBinaryFile(/*@unused@*/Package pkg, struct FileList *fl,
+static int processBinaryFile(/*@unused@*/Package pkg, FileList fl,
const char *fileURL)
{
int doGlob;
if (rc == 0 && argc >= 1 && !myGlobPatternP(argv[0])) {
for (i = 0; i < argc; i++) {
rc = addFile(fl, argv[i], NULL);
- free((void *)argv[i]);
+ argv[i] = _free(argv[i]);
}
- free((void *)argv);
+ argv = _free(argv);
} else {
rpmError(RPMERR_BADSPEC, _("File not found by glob: %s\n"),
diskURL);
}
exit:
- if (diskURL)
- free((void *)diskURL);
+ diskURL = _free(diskURL);
if (rc)
fl->processingFailed = 1;
return rc;
static int processPackageFiles(Spec spec, Package pkg,
int installSpecialDoc, int test)
{
- struct FileList fl;
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ struct FileList_s fl;
char *s, **files, **fp;
const char *fileName;
char buf[BUFSIZ];
- AttrRec specialDocAttrRec;
+ struct AttrRec_s arbuf;
+ AttrRec specialDocAttrRec = &arbuf;
char *specialDoc = NULL;
#ifdef MULTILIB
multiLib = RPMFILE_MULTILIB(multiLib);
#endif /* MULTILIB */
- nullAttrRec(&specialDocAttrRec);
+ nullAttrRec(specialDocAttrRec);
pkg->cpioList = NULL;
if (pkg->fileFile) {
const char *ffn;
+ FILE * f;
FD_t fd;
/* XXX W2DO? urlPath might be useful here. */
ffn, Fstrerror(fd));
return RPMERR_BADFILENAME;
}
- free((void *)ffn);
+ ffn = _free(ffn);
- while (fgets(buf, sizeof(buf), (FILE *)fdGetFp(fd))) {
+ /*@+voidabstract@*/ f = fdGetFp(fd); /*@=voidabstract@*/
+ while (fgets(buf, sizeof(buf), f)) {
handleComments(buf);
if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
rpmError(RPMERR_BADSPEC, _("line: %s\n"), buf);
/* XXX spec->buildRootURL == NULL, then xstrdup("") is returned */
fl.buildRootURL = rpmGenPath(spec->rootURL, spec->buildRootURL, NULL);
- if (headerGetEntry(pkg->header, RPMTAG_DEFAULTPREFIX,
- NULL, (void **)&fl.prefix, NULL)) {
+ if (hge(pkg->header, RPMTAG_DEFAULTPREFIX, NULL, (void **)&fl.prefix, NULL))
fl.prefix = xstrdup(fl.prefix);
- } else {
+ else
fl.prefix = NULL;
- }
fl.fileCount = 0;
fl.totalFileSize = 0;
fl.inFtw = 0;
fl.currentFlags = 0;
/* turn explicit flags into %def'd ones (gosh this is hacky...) */
- fl.currentSpecdFlags = fl.defSpecdFlags>>8;
+ fl.currentSpecdFlags = ((unsigned)fl.defSpecdFlags) >> 8;
fl.currentVerifyFlags = fl.defVerifyFlags;
fl.isSpecialDoc = 0;
if (fl.currentLangs) {
int i;
for (i = 0; i < fl.nLangs; i++)
- free((void *)fl.currentLangs[i]);
- FREE(fl.currentLangs);
+ fl.currentLangs[i] = _free(fl.currentLangs[i]);
+ fl.currentLangs = _free(fl.currentLangs);
}
fl.nLangs = 0;
if (fl.isSpecialDoc) {
/* Save this stuff for last */
- FREE(specialDoc);
+ specialDoc = _free(specialDoc);
specialDoc = xstrdup(fileName);
- dupAttrRec(&fl.cur_ar, &specialDocAttrRec);
+ dupAttrRec(&fl.cur_ar, specialDocAttrRec);
} else {
processBinaryFile(pkg, &fl, fileName);
}
if (fl.currentLangs) {
int i;
for (i = 0; i < fl.nLangs; i++)
- free((void *)fl.currentLangs[i]);
- FREE(fl.currentLangs);
+ fl.currentLangs[i] = _free(fl.currentLangs[i]);
+ fl.currentLangs = _free(fl.currentLangs);
}
fl.nLangs = 0;
- dupAttrRec(&specialDocAttrRec, &fl.cur_ar);
- freeAttrRec(&specialDocAttrRec);
+ dupAttrRec(specialDocAttrRec, &fl.cur_ar);
+ freeAttrRec(specialDocAttrRec);
processBinaryFile(pkg, &fl, specialDoc);
- FREE(specialDoc);
+ specialDoc = _free(specialDoc);
}
freeSplitString(files);
timeCheck(spec->timeCheck, pkg->header);
exit:
- FREE(fl.buildRootURL);
- FREE(fl.prefix);
+ fl.buildRootURL = _free(fl.buildRootURL);
+ fl.prefix = _free(fl.prefix);
freeAttrRec(&fl.cur_ar);
freeAttrRec(&fl.def_ar);
if (fl.currentLangs) {
int i;
for (i = 0; i < fl.nLangs; i++)
- free((void *)fl.currentLangs[i]);
- FREE(fl.currentLangs);
+ fl.currentLangs[i] = _free(fl.currentLangs[i]);
+ fl.currentLangs = _free(fl.currentLangs);
}
- freeFileList(fl.fileList, fl.fileListRecsUsed);
- while (fl.docDirCount--) {
- FREE(fl.docDirs[fl.docDirCount]);
- }
+ fl.fileList = freeFileList(fl.fileList, fl.fileListRecsUsed);
+ while (fl.docDirCount--)
+ fl.docDirs[fl.docDirCount] = _free(fl.docDirs[fl.docDirCount]);
return fl.processingFailed;
}
struct Source *srcPtr;
StringBuf sourceFiles;
int x, isSpec = 1;
- struct FileList fl;
+ struct FileList_s fl;
char *s, **files, **fp;
Package pkg;
}
}
- { const char *s;
- s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
+ { const char * sfn;
+ sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
"%{_sourcedir}/", srcPtr->source, NULL);
- appendLineStringBuf(sourceFiles, s);
- free((void *)s);
+ appendLineStringBuf(sourceFiles, sfn);
+ sfn = _free(sfn);
}
}
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
for (srcPtr = pkg->icon; srcPtr != NULL; srcPtr = srcPtr->next) {
- const char *s;
- s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
+ const char * sfn;
+ sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
"%{_sourcedir}/", srcPtr->source, NULL);
- appendLineStringBuf(sourceFiles, s);
- free((void *)s);
+ appendLineStringBuf(sourceFiles, sfn);
+ sfn = _free(sfn);
}
}
spec->sourceCpioList = NULL;
- fl.fileList = xmalloc((spec->numSources + 1) * sizeof(FileListRec));
+ fl.fileList = xmalloc((spec->numSources + 1) * sizeof(*fl.fileList));
fl.processingFailed = 0;
fl.fileListRecsUsed = 0;
fl.totalFileSize = 0;
x = 0;
for (fp = files; *fp != NULL; fp++) {
const char * diskURL, *diskPath;
- FileListRec *flp;
+ FileListRec flp;
diskURL = *fp;
SKIPSPACE(diskURL);
diskURL++;
}
- urlPath(diskURL, &diskPath);
+ (void) urlPath(diskURL, &diskPath);
flp->diskURL = xstrdup(diskURL);
diskPath = strrchr(diskPath, '/');
}
freeStringBuf(sourceFiles);
- freeFileList(fl.fileList, fl.fileListRecsUsed);
+ fl.fileList = freeFileList(fl.fileList, fl.fileListRecsUsed);
return fl.processingFailed;
}
myargv[0] = (dm->argv[0] ? rpmExpand(dm->argv[0], NULL) : NULL);
if (!(myargv[0] && *myargv[0] != '%')) {
- free(myargv[0]);
+ myargv[0] = _free(myargv[0]);
continue;
}
#if 0
if (*myargv[0] != '/') { /* XXX FIXME: stat script here */
- free(myargv[0]);
- myargv[0] = NULL;
+ myargv[0] = _free(myargv[0]);
continue;
}
#endif
getStringBuf(writeBuf), writeBytes, failnonzero);
/* Free expanded args */
- for (i = 0; i < 4; i++) {
- if (myargv[i] == NULL) continue;
- free(myargv[i]);
- myargv[i] = NULL;
- }
+ for (i = 0; i < 4; i++)
+ myargv[i] = _free(myargv[i]);
if (readBuf == NULL) {
rc = RPMERR_EXEC;
*/
static void printDeps(Header h)
{
- const char **names = NULL;
- const char **versions = NULL;
- int *flags = NULL;
- DepMsg_t *dm;
- int type, count;
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
+ const char ** names = NULL;
+ int dnt = -1;
+ const char ** versions = NULL;
+ int dvt = -1;
+ int * flags = NULL;
+ DepMsg_t * dm;
+ int count;
for (dm = depMsgs; dm->msg != NULL; dm++) {
switch (dm->ntag) {
case 0:
- FREE(names);
+ names = hfd(names, dnt);
break;
case -1:
break;
default:
- FREE(names);
- if (!headerGetEntry(h, dm->ntag, &type, (void **) &names, &count))
+ names = hfd(names, dnt);
+ if (!hge(h, dm->ntag, &dnt, (void **) &names, &count))
continue;
break;
}
switch (dm->vtag) {
case 0:
- FREE(versions);
+ versions = hfd(versions, dvt);
break;
case -1:
break;
default:
- FREE(versions);
- headerGetEntry(h, dm->vtag, NULL, (void **) &versions, NULL);
+ versions = hfd(versions, dvt);
+ hge(h, dm->vtag, &dvt, (void **) &versions, NULL);
break;
}
switch (dm->ftag) {
case -1:
break;
default:
- headerGetEntry(h, dm->ftag, NULL, (void **) &flags, NULL);
+ hge(h, dm->ftag, NULL, (void **) &flags, NULL);
break;
}
printDepMsg(dm, count, names, versions, flags);
}
- FREE(names);
- FREE(versions);
+ names = hfd(names, dnt);
+ versions = hfd(versions, dvt);
}
int processBinaryFiles(Spec spec, int installSpecialDoc, int test)
* XXX However, there is logic in files.c/depends.c that checks for
* XXX existence (rather than value) that will need to change as well.
*/
- if (headerGetEntry(pkg->header, RPMTAG_MULTILIBS, NULL, NULL, NULL)) {
+ if (headerIsEntry(pkg->header, RPMTAG_MULTILIBS)) {
generateDepends(spec, pkg, pkg->cpioList, 1);
generateDepends(spec, pkg, pkg->cpioList, 2);
} else
generateDepends(spec, pkg, pkg->cpioList, 0);
printDeps(pkg->header);
-
}
return res;
{
int x;
for (x = 0; x < uid_used; x++)
- free((void *)unames[x]);
+ unames[x] = _free(unames[x]);
for (x = 0; x < gid_used; x++)
- free((void *)gnames[x]);
+ gnames[x] = _free(gnames[x]);
}
const char *getUname(uid_t uid)
int x;
for (x = 0; x < uid_used; x++) {
- if (uids[x] == uid) {
+ if (uids[x] == uid)
return unames[x];
- }
}
/* XXX - This is the other hard coded limit */
if (x == 1024)
rpmlog(RPMLOG_CRIT, _("getUname: too many uid's\n"));
+ uid_used++;
pw = getpwuid(uid);
uids[x] = uid;
- uid_used++;
- if (pw) {
- unames[x] = xstrdup(pw->pw_name);
- } else {
- unames[x] = NULL;
- }
+ unames[x] = (pw ? xstrdup(pw->pw_name) : NULL);
return unames[x];
}
int x;
for (x = 0; x < uid_used; x++) {
- if (!strcmp(unames[x],uname)) {
+ if (!strcmp(unames[x],uname))
return unames[x];
- }
}
/* XXX - This is the other hard coded limit */
if (x == 1024)
rpmlog(RPMLOG_CRIT, _("getUnameS: too many uid's\n"));
+ uid_used++;
pw = getpwnam(uname);
- uid_used++;
- if (pw) {
- uids[x] = pw->pw_uid;
- unames[x] = xstrdup(pw->pw_name);
- } else {
- uids[x] = -1;
- unames[x] = xstrdup(uname);
- }
+ uids[x] = (pw ? pw->pw_uid : -1);
+ unames[x] = (pw ? xstrdup(pw->pw_name) : xstrdup(uname));
return unames[x];
}
int x;
for (x = 0; x < gid_used; x++) {
- if (gids[x] == gid) {
+ if (gids[x] == gid)
return gnames[x];
- }
}
/* XXX - This is the other hard coded limit */
if (x == 1024)
rpmlog(RPMLOG_CRIT, _("getGname: too many gid's\n"));
+ gid_used++;
gr = getgrgid(gid);
gids[x] = gid;
- gid_used++;
- if (gr) {
- gnames[x] = xstrdup(gr->gr_name);
- } else {
- gnames[x] = NULL;
- }
+ gnames[x] = (gr ? xstrdup(gr->gr_name) : NULL);
return gnames[x];
}
int x;
for (x = 0; x < gid_used; x++) {
- if (!strcmp(gnames[x], gname)) {
+ if (!strcmp(gnames[x], gname))
return gnames[x];
- }
}
/* XXX - This is the other hard coded limit */
if (x == 1024)
rpmlog(RPMLOG_CRIT, _("getGnameS: too many gid's\n"));
+ gid_used++;
gr = getgrnam(gname);
- gid_used++;
- if (gr) {
- gids[x] = gr->gr_gid;
- gnames[x] = xstrdup(gr->gr_name);
- } else {
- gids[x] = -1;
- gnames[x] = xstrdup(gname);
- }
+ gids[x] = (gr ? gr->gr_gid : -1);
+ gnames[x] = (gr ? xstrdup(gr->gr_name) : xstrdup(gname));
return gnames[x];
}
time_t *const getBuildTime(void)
{
- static time_t buildTime = 0;
+ static time_t buildTime[1];
- if (! buildTime)
- buildTime = time(NULL);
- return &buildTime;
+ if (buildTime[0] == 0)
+ buildTime[0] = time(NULL);
+ return buildTime;
}
const char *const buildHost(void)
if (! gotit) {
gethostname(hostname, sizeof(hostname));
- if ((hbn = /*@-unrecog@*/ gethostbyname(hostname) /*@=unrecog@*/ )) {
+ if ((hbn = /*@-unrecog@*/ gethostbyname(hostname) /*@=unrecog@*/ ))
strcpy(hostname, hbn->h_name);
- } else {
- rpmMessage(RPMMESS_WARNING, _("Could not canonicalize hostname: %s\n"),
- hostname);
- }
+ else
+ rpmMessage(RPMMESS_WARNING,
+ _("Could not canonicalize hostname: %s\n"), hostname);
gotit = 1;
}
return(hostname);
/**
* @todo Create transaction set *much* earlier.
*/
-static int cpio_doio(FD_t fdo, Header h, CSA_t * csa, const char * fmodeMacro)
+static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t * csa,
+ const char * fmodeMacro)
{
const char * rootDir = "/";
rpmdb rpmdb = NULL;
rc = 1;
}
- if (failedFile)
- free((void *)failedFile);
- free((void *)fmode);
+ failedFile = _free(failedFile);
+ fmode = _free(fmode);
rpmtransFree(ts);
return rc;
fn = rpmGetPath("%{_builddir}/", spec->buildSubdir, "/", file, NULL);
fd = Fopen(fn, "r.ufdio");
- if (fn != buf) free((void *)fn);
+ if (fn != buf) fn = _free(fn);
if (fd == NULL || Ferror(fd)) {
freeStringBuf(sb);
return NULL;
/**
*/
-static int addFileToTag(Spec spec, const char *file, Header h, int tag)
+static int addFileToTag(Spec spec, const char * file, Header h, int tag)
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
StringBuf sb = newStringBuf();
char *s;
- if (headerGetEntry(h, tag, NULL, (void **)&s, NULL)) {
+ if (hge(h, tag, NULL, (void **)&s, NULL)) {
appendLineStringBuf(sb, s);
headerRemoveEntry(h, tag);
}
/**
*/
-static int addFileToArrayTag(Spec spec, char *file, Header h, int tag)
+static int addFileToArrayTag(Spec spec, const char *file, Header h, int tag)
{
StringBuf sb = newStringBuf();
char *s;
break;
}
if (!(rpmio_flags && *rpmio_flags)) {
- if (rpmio_flags) free((void *)rpmio_flags);
+ rpmio_flags = _free(rpmio_flags);
rpmio_flags = xstrdup("w9.gzdio");
}
s = strchr(rpmio_flags, '.');
rc = RPMERR_BADARG;
}
}
- if (rpmio_flags) free((void *)rpmio_flags);
+ rpmio_flags = _free(rpmio_flags);
if (rc)
goto exit;
* to memory not in the region. <shrug>
*/
if (Fileno(csa->cpioFdIn) < 0) {
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
int_32 * archiveSize;
- if (headerGetEntry(h, RPMTAG_ARCHIVESIZE, NULL, (void *)&archiveSize, NULL))
+ if (hge(h, RPMTAG_ARCHIVESIZE, NULL, (void *)&archiveSize, NULL))
*archiveSize = csa->cpioArchiveSize;
}
}
if (sigtarget) {
Unlink(sigtarget);
- free((void *)sigtarget);
+ sigtarget = _free(sigtarget);
}
if (rc == 0)
{ const char * optflags = rpmExpand("%{optflags}", NULL);
headerAddEntry(pkg->header, RPMTAG_OPTFLAGS, RPM_STRING_TYPE,
optflags, 1);
- free((void *)optflags);
+ optflags = _free(optflags);
}
genSourceRpmName(spec);
char *binRpm, *binDir;
binRpm = headerSprintf(pkg->header, binFormat, rpmTagTable,
rpmHeaderFormats, &errorString);
- free((void *)binFormat);
+ binFormat = _free(binFormat);
if (binRpm == NULL) {
const char *name;
headerNVR(pkg->header, &name, NULL, NULL);
break;
}
}
- free((void *)dn);
+ dn = _free(dn);
}
- free((void *)binRpm);
+ binRpm = _free(binRpm);
}
memset(csa, 0, sizeof(*csa));
rc = writeRPM(&pkg->header, fn, RPMLEAD_BINARY,
csa, spec->passPhrase, NULL);
csa->cpioFdIn = fdFree(csa->cpioFdIn, "init (packageBinaries)");
- free((void *)fn);
+ fn = _free(fn);
if (rc)
return rc;
}
genSourceRpmName(spec);
- FREE(spec->cookie);
+ spec->cookie = _free(spec->cookie);
/* XXX this should be %_srpmdir */
{ const char *fn = rpmGetPath("%{_srcrpmdir}/", spec->sourceRpmName,NULL);
rc = writeRPM(&spec->sourceHeader, fn, RPMLEAD_SOURCE,
csa, spec->passPhrase, &(spec->cookie));
csa->cpioFdIn = fdFree(csa->cpioFdIn, "init (packageSources)");
- free((void *)fn);
+ fn = _free(fn);
}
return rc;
}
/* name */
name = s;
while (*s) s++;
- while (s > name && isspace(*s)) {
+ while (s > name && xisspace(*s)) {
*s-- = '\0';
}
if (s == name) {
s--;
/* backup to end of description */
- while ((s > text) && isspace(*s)) {
+ while ((s > text) && xisspace(*s)) {
*s-- = '\0';
}
spec->lineNum,
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
spec->line);
- FREE(argv);
+ argv = _free(argv);
poptFreeContext(optCon);
return RPMERR_BADSPEC;
}
rpmError(RPMERR_BADSPEC, _("line %d: Too many names: %s\n"),
spec->lineNum,
spec->line);
- FREE(argv);
+ argv = _free(argv);
poptFreeContext(optCon);
return RPMERR_BADSPEC;
}
if (lookupPackage(spec, name, flag, &pkg)) {
rpmError(RPMERR_BADSPEC, _("line %d: Package does not exist: %s\n"),
spec->lineNum, spec->line);
- FREE(argv);
+ argv = _free(argv);
poptFreeContext(optCon);
return RPMERR_BADSPEC;
}
if (headerIsEntry(pkg->header, RPMTAG_DESCRIPTION)) {
rpmError(RPMERR_BADSPEC, _("line %d: Second description\n"),
spec->lineNum);
- FREE(argv);
+ argv = _free(argv);
poptFreeContext(optCon);
return RPMERR_BADSPEC;
}
freeStringBuf(sb);
- FREE(argv);
+ argv = _free(argv);
poptFreeContext(optCon);
return nextPart;
rc = nextPart;
exit:
- if (argv)
- FREE(argv);
+ argv = _free(argv);
if (optCon)
poptFreeContext(optCon);
poptParseArgvString(line, &argc, &argv);
if (argc)
headerAddOrAppendEntry(h, tag, RPM_STRING_ARRAY_TYPE, argv, argc);
- FREE(argv);
+ argv = _free(argv);
}
/* Parse a simple part line that only take -n <pkg> or <pkg> */
? 0 : 1);
}
-struct tokenBits {
+typedef struct tokenBits_s {
const char * name;
- int bits;
-};
+ rpmsenseFlags bits;
+} * tokenBits;
/**
*/
-static struct tokenBits installScriptBits[] = {
+static struct tokenBits_s installScriptBits[] = {
{ "interp", RPMSENSE_INTERP },
{ "prereq", RPMSENSE_PREREQ },
{ "preun", RPMSENSE_SCRIPT_PREUN },
/**
*/
-static struct tokenBits buildScriptBits[] = {
+static struct tokenBits_s buildScriptBits[] = {
{ "prep", RPMSENSE_SCRIPT_PREP },
{ "build", RPMSENSE_SCRIPT_BUILD },
{ "install", RPMSENSE_SCRIPT_INSTALL },
/**
*/
-static int parseBits(const char * s, struct tokenBits * tokbits, int * bp)
+static int parseBits(const char * s, const tokenBits tokbits,
+ /*@out@*/ rpmsenseFlags * bp)
{
- struct tokenBits *tb;
- const char *se;
- int bits = 0;
+ tokenBits tb;
+ const char * se;
+ rpmsenseFlags bits = RPMSENSE_ANY;
int c = 0;
if (s) {
while (*s) {
- while ((c = *s) && isspace(c)) s++;
+ while ((c = *s) && xisspace(c)) s++;
se = s;
- while ((c = *se) && isalpha(c)) se++;
+ while ((c = *se) && xisalpha(c)) se++;
if (s == se)
break;
for (tb = tokbits; tb->name; tb++) {
if (tb->name == NULL)
break;
bits |= tb->bits;
- while ((c = *se) && isspace(c)) se++;
+ while ((c = *se) && xisspace(c)) se++;
if (c != ',')
break;
s = ++se;
char *res = s;
while (*s) {
- if (! isspace(*s))
+ if (! xisspace(*s))
res = s;
s++;
}
*/
static int isMemberInEntry(Header header, const char *name, int tag)
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
const char ** names;
- int count;
+ int type, count;
- if (!headerGetEntry(header, tag, NULL, (void **)&names, &count))
+ if (!hge(header, tag, &type, (void **)&names, &count))
return -1;
while (count--) {
if (!xstrcasecmp(names[count], name))
break;
}
- FREE(names);
+ names = hfd(names, type);
return (count >= 0 ? 1 : 0);
}
const char *val = rpmExpand(ot->ot_mac, NULL);
if (val && *val != '%')
headerAddEntry(h, ot->ot_tag, RPM_STRING_TYPE, (void *)val, 1);
- free((void *)val);
+ val = _free(val);
}
}
}
rc = RPMERR_BADSPEC;
goto exit;
}
- free((void *)icon);
+ icon = _free(icon);
exit:
- FREE(fn);
+ fn = _free(fn);
return rc;
}
struct spectag *
stashSt(Spec spec, Header h, int tag, const char *lang)
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
struct spectag *t = NULL;
if (spec->st) {
t->t_msgid = NULL;
if (!(t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG))) {
char *n;
- if (headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &n, NULL)) {
+ if (hge(h, RPMTAG_NAME, NULL, (void **) &n, NULL)) {
char buf[1024];
sprintf(buf, "%s(%s)", n, tagName(tag));
t->t_msgid = xstrdup(buf);
static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro,
const char *lang)
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
char *field = spec->line;
char *end;
char **array;
int multiToken = 0;
- int tagflags;
+ rpmsenseFlags tagflags;
+ int type;
int len;
int num;
int rc;
} else {
const char * specURL = field;
- free((void *)buildRootURL);
+ buildRootURL = _free(buildRootURL);
(void) urlPath(specURL, (const char **)&field);
if (*field == '\0') field = "/";
buildRootURL = rpmGenPath(spec->rootURL, field, NULL);
if (!strcmp(buildRoot, "/")) {
rpmError(RPMERR_BADSPEC,
_("BuildRoot can not be \"/\": %s\n"), spec->buildRootURL);
- free((void *)buildRootURL);
+ buildRootURL = _free(buildRootURL);
return RPMERR_BADSPEC;
}
- free((void *)buildRootURL);
+ buildRootURL = _free(buildRootURL);
} break;
case RPMTAG_PREFIXES:
addOrAppendListEntry(pkg->header, tag, field);
- headerGetEntry(pkg->header, tag, NULL, (void **)&array, &num);
+ hge(pkg->header, tag, &type, (void **)&array, &num);
while (num--) {
len = strlen(array[num]);
if (array[num][len - 1] == '/' && len > 1) {
rpmError(RPMERR_BADSPEC,
_("line %d: Prefixes must not end with \"/\": %s\n"),
spec->lineNum, spec->line);
- FREE(array);
+ array = hfd(array, type);
return RPMERR_BADSPEC;
}
}
- FREE(array);
+ array = hfd(array, type);
break;
case RPMTAG_DOCDIR:
SINGLE_TOKEN_ONLY;
case RPMTAG_CONFLICTFLAGS:
case RPMTAG_OBSOLETEFLAGS:
case RPMTAG_PROVIDEFLAGS:
- tagflags = 0;
+ tagflags = RPMSENSE_ANY;
if ((rc = parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
return rc;
break;
return RPMERR_BADSPEC;
}
if (!spec->buildArchitectureCount)
- FREE(spec->buildArchitectures);
+ spec->buildArchitectures = _free(spec->buildArchitectures);
break;
default:
if (*s != '(') return 1;
s++;
SKIPSPACE(s);
- while (!isspace(*s) && *s != ')')
+ while (!xisspace(*s) && *s != ')')
*lang++ = *s++;
*lang = '\0';
SKIPSPACE(s);
/* These have to be global to make up for stupid compilers */
static int leaveDirs, skipDefaultAction;
static int createDir, quietly;
- /*@observer@*/ /*@null@*/ static const char * dirName = NULL;
- static struct poptOption optionsTable[] = {
+/*@observer@*/ /*@null@*/ static const char * dirName = NULL;
+/*@observer@*/ static struct poptOption optionsTable[] = {
{ NULL, 'a', POPT_ARG_STRING, NULL, 'a', NULL, NULL},
{ NULL, 'b', POPT_ARG_STRING, NULL, 'b', NULL, NULL},
{ NULL, 'c', 0, &createDir, 0, NULL, NULL},
return NULL;
}
- fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
+ urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
args[0] = '\0';
if (db) {
/* XXX On non-build parse's, file cannot be stat'd or read */
if (!spec->force && (isCompressed(urlfn, &compressed) || checkOwners(urlfn))) {
- free((void *)urlfn);
+ urlfn = _free(urlfn);
return NULL;
}
+ fn = NULL;
urltype = urlPath(urlfn, &fn);
switch (urltype) {
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_UNKNOWN:
break;
case URL_IS_DASH:
- free((void *)urlfn);
+ urlfn = _free(urlfn);
return NULL;
/*@notreached@*/ break;
}
"if [ $STATUS -ne 0 ]; then\n"
" exit $STATUS\n"
"fi",
- c, (const char *) basename(fn),
+ c, /*@-unrecog@*/ (const char *) basename(fn), /*@=unrecog@*/
zipper,
fn, strip, args);
- free((void *)zipper);
+ zipper = _free(zipper);
} else {
sprintf(buf,
"echo \"Patch #%d (%s):\"\n"
strip, args, fn);
}
- free((void *)urlfn);
+ urlfn = _free(urlfn);
return buf;
}
return NULL;
}
- fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
+ urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
taropts = ((rpmIsVerbose() && !quietly) ? "-xvvf" : "-xf");
/* XXX On non-build parse's, file cannot be stat'd or read */
if (!spec->force && (isCompressed(urlfn, &compressed) || checkOwners(urlfn))) {
- free((void *)urlfn);
+ urlfn = _free(urlfn);
return NULL;
}
+ fn = NULL;
urltype = urlPath(urlfn, &fn);
switch (urltype) {
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_UNKNOWN:
break;
case URL_IS_DASH:
- free((void *)urlfn);
+ urlfn = _free(urlfn);
return NULL;
/*@notreached@*/ break;
}
zipper = rpmGetPath(t, NULL);
buf[0] = '\0';
t = stpcpy(buf, zipper);
- free((void *)zipper);
+ zipper = _free(zipper);
*t++ = ' ';
t = stpcpy(t, fn);
if (needtar)
t = stpcpy(t, fn);
}
- free((void *)urlfn);
+ urlfn = _free(urlfn);
return buf;
}
if (parseNum(optArg, &num)) {
rpmError(RPMERR_BADSPEC, _("line %d: Bad arg to %%setup %c: %s\n"),
spec->lineNum, num, optArg);
- free(argv);
freeStringBuf(before);
freeStringBuf(after);
poptFreeContext(optCon);
+ argv = _free(argv);
return RPMERR_BADSPEC;
}
spec->lineNum,
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(arg));
- free(argv);
freeStringBuf(before);
freeStringBuf(after);
poptFreeContext(optCon);
+ argv = _free(argv);
return RPMERR_BADSPEC;
}
}
addMacro(spec->macros, "buildsubdir", NULL, spec->buildSubdir, RMIL_SPEC);
- free(argv);
poptFreeContext(optCon);
+ argv = _free(argv);
/* cd to the build dir */
{ const char * buildDirURL = rpmGenPath(spec->rootURL, "%{_builddir}", "");
(void) urlPath(buildDirURL, &buildDir);
sprintf(buf, "cd %s", buildDir);
appendLineStringBuf(spec->prep, buf);
- free((void *)buildDirURL);
+ buildDirURL = _free(buildDirURL);
}
/* delete any old sources */
const char *fix = rpmExpand(*fm, " .", NULL);
if (fix && *fix != '%')
appendLineStringBuf(spec->prep, fix);
- free((void *)fix);
+ fix = _free(fix);
}
}
for (bp = buf; (s = strtok(bp, " \t\n")) != NULL;) {
if (bp) { /* remove 1st token (%patch) */
- bp = NULL;
- continue;
+ bp = NULL;
+ continue;
}
if (!strcmp(s, "-P")) {
opt_P = 1;
if (! opt_P) {
s = doPatch(spec, 0, opt_p, opt_b, opt_R, opt_E);
- if (s == NULL) {
+ if (s == NULL)
return RPMERR_BADSPEC;
- }
appendLineStringBuf(spec->prep, s);
}
for (x = 0; x < patch_index; x++) {
s = doPatch(spec, patch_nums[x], opt_p, opt_b, opt_R, opt_E);
- if (s == NULL) {
+ if (s == NULL)
return RPMERR_BADSPEC;
- }
appendLineStringBuf(spec->prep, s);
}
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
return PART_NONE;
}
- if (rc) {
+ if (rc)
return rc;
- }
buf = newStringBuf();
nextPart = PART_NONE;
break;
}
- if (rc) {
+ if (rc)
return rc;
- }
}
saveLines = splitString(getStringBuf(buf), strlen(getStringBuf(buf)), '\n');
/**
*/
static struct ReqComp {
- char *token;
- int sense;
+ const char * token;
+ rpmsenseFlags sense;
} ReqComparisons[] = {
{ "<=", RPMSENSE_LESS | RPMSENSE_EQUAL},
{ "=<", RPMSENSE_LESS | RPMSENSE_EQUAL},
{ NULL, 0 },
};
-#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;}
-#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;}
+#define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
+#define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
int parseRCPOT(Spec spec, Package pkg, const char *field, int tag,
- int index, int tagflags)
+ int index, rpmsenseFlags tagflags)
{
const char *r, *re, *v, *ve;
- char *req, *version;
+ char * req, * version;
Header h;
- int flags;
+ rpmsenseFlags flags;
switch (tag) {
case RPMTAG_PROVIDEFLAGS:
flags = (tagflags & ~RPMSENSE_SENSEMASK);
/* Tokens must begin with alphanumeric, _, or / */
- if (!(isalnum(r[0]) || r[0] == '_' || r[0] == '/')) {
+ if (!(xisalnum(r[0]) || r[0] == '_' || r[0] == '/')) {
rpmError(RPMERR_BADSPEC,
_("line %d: Dependency tokens must begin with alpha-numeric, '_' or '/': %s\n"),
spec->lineNum, spec->line);
addReqProv(spec, h, flags, req, version, index);
- if (req) free(req);
- if (version) free(version);
+ req = _free(req);
+ version = _free(version);
}
exit:
if (sb)
freeStringBuf(sb);
- if (progArgv) {
- FREE(progArgv);
- }
- if (argv) {
- FREE(argv);
- }
+ progArgv = _free(progArgv);
+ argv = _free(argv);
if (optCon)
poptFreeContext(optCon);
if (xstrncasecmp(line, p->token, p->len))
continue;
c = *(line + p->len);
- if (c == '\0' || isspace(c))
+ if (c == '\0' || xisspace(c))
break;
}
ch = ' ';
while (*spec->nextline && ch != '\n') {
ch = *spec->nextline++;
- if (!isspace(ch))
+ if (!xisspace(ch))
last = spec->nextline;
}
/* remove this file from the stack */
spec->fileStack = ofi->next;
Fclose(ofi->fd);
- FREE(ofi->fileName);
- free(ofi);
+ ofi->fileName = _free(ofi->fileName);
+ ofi = _free(ofi);
/* only on last file do we signal EOF to caller */
ofi = spec->fileStack;
const char *arch = rpmExpand("%{_target_cpu}", NULL);
s += 7;
match = matchTok(arch, s);
- free((void *)arch);
+ arch = _free(arch);
} else if (! strncmp("%ifnarch", s, sizeof("%ifnarch")-1)) {
const char *arch = rpmExpand("%{_target_cpu}", NULL);
s += 8;
match = !matchTok(arch, s);
- free((void *)arch);
+ arch = _free(arch);
} else if (! strncmp("%ifos", s, sizeof("%ifos")-1)) {
const char *os = rpmExpand("%{_target_os}", NULL);
s += 5;
match = matchTok(os, s);
- free((void *)os);
+ os = _free(os);
} else if (! strncmp("%ifnos", s, sizeof("%ifnos")-1)) {
const char *os = rpmExpand("%{_target_os}", NULL);
s += 6;
match = !matchTok(os, s);
- free((void *)os);
+ os = _free(os);
} else if (! strncmp("%if", s, sizeof("%if")-1)) {
s += 3;
match = parseExpressionBoolean(spec, s);
s += 8;
fileName = s;
- if (! isspace(*fileName)) {
+ if (! xisspace(*fileName)) {
rpmError(RPMERR_BADSPEC, _("malformed %%include statement\n"));
return RPMERR_BADSPEC;
}
ofi = spec->fileStack;
spec->fileStack = spec->fileStack->next;
if (ofi->fd) Fclose(ofi->fd);
- FREE(ofi->fileName);
- free(ofi);
+ ofi->fileName = _free(ofi->fileName);
+ ofi = _free(ofi);
}
}
}
#ifdef DYING
rpmSetMachine(saveArch, NULL);
- free((void *)saveArch);
+ saveArch = _free(saveArch);
#else
delMacro(NULL, "_target_cpu");
#endif
headerAddEntry(pkg->header, RPMTAG_ARCH, RPM_STRING_TYPE, arch, 1);
}
#ifdef DYING
- FREE(myos);
+ myos = _free(myos);
#else
- free((void *)arch);
- free((void *)os);
+ arch = _free(arch);
+ os = _free(os);
#endif
}
#include "debug.h"
int addReqProv(/*@unused@*/ Spec spec, Header h,
- int depFlags, const char *depName, const char *depEVR, int index)
+ rpmsenseFlags depFlags, const char *depName, const char *depEVR,
+ int index)
{
- const char **names;
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
+ const char ** names;
+ int dnt;
int nametag = 0;
int versiontag = 0;
int flagtag = 0;
int indextag = 0;
int len;
- int extra = 0;
+ rpmsenseFlags extra = RPMSENSE_ANY;
if (depFlags & RPMSENSE_PROVIDES) {
nametag = RPMTAG_PROVIDENAME;
depEVR = "";
/* Check for duplicate dependencies. */
- if (headerGetEntry(h, nametag, NULL, (void **) &names, &len)) {
- const char **versions = NULL;
+ if (hge(h, nametag, &dnt, (void **) &names, &len)) {
+ const char ** versions = NULL;
+ int dvt;
int *flags = NULL;
int *indexes = NULL;
int duplicate = 0;
if (flagtag) {
- headerGetEntry(h, versiontag, NULL, (void **) &versions, NULL);
- headerGetEntry(h, flagtag, NULL, (void **) &flags, NULL);
+ hge(h, versiontag, &dvt, (void **) &versions, NULL);
+ hge(h, flagtag, NULL, (void **) &flags, NULL);
}
if (indextag)
- headerGetEntry(h, indextag, NULL, (void **) &indexes, NULL);
+ hge(h, indextag, NULL, (void **) &indexes, NULL);
while (len > 0) {
len--;
break;
}
- FREE(names);
- FREE(versions);
+ names = hfd(names, dnt);
+ versions = hfd(versions, dvt);
if (duplicate)
return 0;
}
* Bit(s) to control buildSpec() operation.
*/
typedef enum rpmBuildFlags_e {
+ RPMBUILD_NONE = 0,
RPMBUILD_PREP = (1 << 0), /*!< Execute %%prep. */
RPMBUILD_BUILD = (1 << 1), /*!< Execute %%build. */
RPMBUILD_INSTALL = (1 << 2), /*!< Execute %%install. */
#include <ctype.h>
-#define FREE(x) { if (x) free((void *)x); x = NULL; }
-#define SKIPSPACE(s) { while (*(s) && isspace(*(s))) (s)++; }
-#define SKIPNONSPACE(s) { while (*(s) && !isspace(*(s))) (s)++; }
+#define SKIPSPACE(s) { while (*(s) && xisspace(*(s))) (s)++; }
+#define SKIPNONSPACE(s) { while (*(s) && !xisspace(*(s))) (s)++; }
#define PART_SUBNAME 0
#define PART_NAME 1
* @return 0 on success, RPMERR_BADSPEC on failure
*/
int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index,
- int flags);
+ rpmsenseFlags flags);
/** \ingroup rpmbuild
* Parse %%pre et al scriptlets from a spec file.
* @return 0 always
*/
int addReqProv(/*@unused@*/Spec spec, Header h,
- int flag, const char *depName, const char *depEVR, int index);
+ rpmsenseFlags flag, const char *depName, const char *depEVR,
+ int index);
/** \ingroup rpmbuild
* Add rpmlib feature dependency.
extern int specedit;
extern MacroContext rpmGlobalMacroContext;
-#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;}
-#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;}
+#define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
+#define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
/*@access Header @*/ /* compared with NULL */
while (q != NULL) {
o = q;
q = q->next;
- FREE(o->fileName);
- FREE(o->script);
- FREE(o->prog);
- free(o);
+ o->fileName = _free(o->fileName);
+ o->script = _free(o->script);
+ o->prog = _free(o->prog);
+ o = _free(o);
}
}
while (t != NULL) {
r = t;
t = t->next;
- FREE(r->fullSource);
- free(r);
+ r->fullSource = _free(r->fullSource);
+ r = _free(r);
}
}
if (p == NULL)
return;
- FREE(p->preInFile);
- FREE(p->postInFile);
- FREE(p->preUnFile);
- FREE(p->postUnFile);
- FREE(p->verifyFile);
+ p->preInFile = _free(p->preInFile);
+ p->postInFile = _free(p->postInFile);
+ p->preUnFile = _free(p->preUnFile);
+ p->postUnFile = _free(p->postUnFile);
+ p->verifyFile = _free(p->verifyFile);
headerFree(p->header);
freeStringBuf(p->fileList);
- FREE(p->fileFile);
+ p->fileFile = _free(p->fileFile);
if (p->cpioList) {
TFI_t fi = p->cpioList;
+ p->cpioList = NULL;
freeFi(fi);
- free((void *)fi);
+ fi = _free(fi);
}
- p->cpioList = NULL;
freeStringBuf(p->specialDoc);
freeTriggerFiles(p->triggerFiles);
- free(p);
+ p = _free(p);
}
void freePackages(Spec spec)
sprintf(buf, "%sURL%d",
(flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num);
addMacro(spec->macros, buf, NULL, p->fullSource, RMIL_SPEC);
- free((void *)body);
+ body = _free(body);
}
return 0;
if (sl == NULL)
return;
for (i = 0; i < sl->sl_nlines; i++)
- FREE(sl->sl_lines[i]);
- FREE(sl->sl_lines);
- free(sl);
+ sl->sl_lines[i] = _free(sl->sl_lines[i]);
+ sl->sl_lines = _free(sl->sl_lines);
+ sl = _free(sl);
}
/**
return;
for (i = 0; i < st->st_ntags; i++) {
struct spectag *t = st->st_t + i;
- FREE(t->t_lang);
- FREE(t->t_msgid);
+ t->t_lang = _free(t->t_lang);
+ t->t_msgid = _free(t->t_msgid);
}
- FREE(st->st_t);
- free(st);
+ st->st_t = _free(st->st_t);
+ st = _free(st);
}
Spec newSpec(void)
{
- Spec spec;
-
- spec = (Spec)xmalloc(sizeof *spec);
+ Spec spec = xcalloc(1, sizeof(*spec));
spec->specFile = NULL;
spec->sourceRpmName = NULL;
spec->nextline = NULL;
spec->nextpeekc = '\0';
spec->lineNum = 0;
- spec->readStack = xmalloc(sizeof(struct ReadLevelEntry));
+ spec->readStack = xcalloc(1, sizeof(*spec->readStack));
spec->readStack->next = NULL;
spec->readStack->reading = 1;
freeStringBuf(spec->install); spec->install = NULL;
freeStringBuf(spec->clean); spec->clean = NULL;
- FREE(spec->buildRootURL);
- FREE(spec->buildSubdir);
- FREE(spec->rootURL);
- FREE(spec->specFile);
- FREE(spec->sourceRpmName);
+ spec->buildRootURL = _free(spec->buildRootURL);
+ spec->buildSubdir = _free(spec->buildSubdir);
+ spec->rootURL = _free(spec->rootURL);
+ spec->specFile = _free(spec->specFile);
+ spec->sourceRpmName = _free(spec->sourceRpmName);
while (spec->fileStack) {
ofi = spec->fileStack;
- spec->fileStack = spec->fileStack->next;
+ spec->fileStack = ofi->next;
ofi->next = NULL;
- FREE(ofi->fileName);
- free(ofi);
+ ofi->fileName = _free(ofi->fileName);
+ ofi = _free(ofi);
}
while (spec->readStack) {
rl = spec->readStack;
- spec->readStack = spec->readStack->next;
+ spec->readStack = rl->next;
rl->next = NULL;
- free(rl);
+ rl = _free(rl);
}
if (spec->sourceHeader != NULL) {
if (spec->sourceCpioList) {
TFI_t fi = spec->sourceCpioList;
+ spec->sourceCpioList = NULL;
freeFi(fi);
- free((void *)fi);
+ fi = _free(fi);
}
- spec->sourceCpioList = NULL;
headerFree(spec->buildRestrictions);
spec->buildRestrictions = NULL;
freeSpec(
spec->buildArchitectureSpecs[spec->buildArchitectureCount]);
}
- FREE(spec->buildArchitectureSpecs);
+ spec->buildArchitectureSpecs = _free(spec->buildArchitectureSpecs);
}
- FREE(spec->buildArchitectures);
+ spec->buildArchitectures = _free(spec->buildArchitectures);
- FREE(spec->passPhrase);
- FREE(spec->cookie);
+ spec->passPhrase = _free(spec->passPhrase);
+ spec->cookie = _free(spec->cookie);
freeSources(spec->sources); spec->sources = NULL;
freePackages(spec);
closeSpec(spec);
- free(spec);
+ spec = _free(spec);
}
/*@only@*/ struct OpenFileInfo * newOpenFileInfo(void)
-unrecogcomments
# don't-bother-me-yet parameters
--branchstate # ~100 occurences, painful
+-branchstate # ~142 occurences, painful
#-immediatetrans
--mustfree # alloca is painful
+-mustfree # ~529 alloca is painful
#-observertrans
#-statictrans
# not-yet normal parameters
-boolops # w->n
--fixedformalarray
+#-fixedformalarray # md5 whines
-null
-predboolint # w->n
--predboolothers # w->n
+#-predboolothers # w->n
-retvalint # w->n
-type
extern int _fsm_debug;
/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
-
-/**
* Convert string to unsigned integer (with buffer size check).
* @param input string
* @retval address of 1st character not processed
buf[num] = '\0';
ret = strtoul(buf, &end, base);
- if (*end)
+ if (*end != '\0')
*endptr = ((char *)str) + (end - buf); /* XXX discards const */
else
*endptr = ((char *)str) + strlen(buf);
#include "debug.h"
+/*@access Header@*/ /* XXX compared with NULL */
/*@access rpmdb@*/
/*@access dbiIndex@*/
/*@access dbiIndexSet@*/
/*@notreached@*/ return DB_HASH;
}
-static /*@observer@*/ const char * db_strerror(int error)
+static /*@observer@*/ char * db_strerror(int error)
{
if (error == 0)
return ("Successful return: 0");
* Note, however, we're no longer thread-safe if it does.
*/
static char ebuf[40];
+ char * t = ebuf;
- (void)snprintf(ebuf, sizeof(ebuf), "Unknown error: %d", error);
+ *t = '\0';
+ t = stpcpy(t, "Unknown error: ");
+ sprintf(t, "%d", error);
return(ebuf);
}
}
compressFilelist(h);
exit:
- if (h) {
+ if (h != NULL) {
uh = headerUnload(h);
headerFree(h);
}
}
db3Free(dbi);
- if (base)
- free((void *)base);
- if (urlfn)
- free((void *)urlfn);
+ base = _free(base);
+ urlfn = _free(urlfn);
return rc;
}
} else
db1close(dbi, 0);
- if (base) {
- free((void *)base);
- base = NULL;
- }
- if (urlfn) {
- free((void *)urlfn);
- urlfn = NULL;
- }
+ base = _free(base);
+ urlfn = _free(urlfn);
return rc;
}
#endif /* __USE_DB2 || __USE_DB3 */
dbi->dbi_db = NULL;
- if (urlfn)
- free((void *)urlfn);
+ urlfn = _free(urlfn);
db3Free(dbi);
} else
db2close(dbi, 0);
- if (urlfn)
- free((void *)urlfn);
+ urlfn = _free(urlfn);
return rc;
}
#endif /* __USE_DB2 || __USE_DB3 */
dbi->dbi_db = NULL;
- if (urlfn)
- free((void *)urlfn);
+ urlfn = _free(urlfn);
db3Free(dbi);
} else
db3close(dbi, 0);
- if (urlfn)
- free((void *)urlfn);
+ urlfn = _free(urlfn);
return rc;
}
void db3Free(dbiIndex dbi) {
if (dbi) {
- if (dbi->dbi_root) free((void *)dbi->dbi_root);
- if (dbi->dbi_home) free((void *)dbi->dbi_home);
- if (dbi->dbi_file) free((void *)dbi->dbi_file);
- if (dbi->dbi_subfile) free((void *)dbi->dbi_subfile);
- if (dbi->dbi_errpfx) free((void *)dbi->dbi_errpfx);
- if (dbi->dbi_re_source) free((void *)dbi->dbi_re_source);
- if (dbi->dbi_dbenv) free(dbi->dbi_dbenv);
- if (dbi->dbi_dbinfo) free(dbi->dbi_dbinfo);
- free((void *)dbi);
+ dbi->dbi_root = _free(dbi->dbi_root);
+ dbi->dbi_home = _free(dbi->dbi_home);
+ dbi->dbi_file = _free(dbi->dbi_file);
+ dbi->dbi_subfile = _free(dbi->dbi_subfile);
+ dbi->dbi_errpfx = _free(dbi->dbi_errpfx);
+ dbi->dbi_re_source = _free(dbi->dbi_re_source);
+ dbi->dbi_dbenv = _free(dbi->dbi_dbenv);
+ dbi->dbi_dbinfo = _free(dbi->dbi_dbinfo);
+ dbi = _free(dbi);
}
}
for (o = dbOpts; o && *o; o = oe) {
struct dbOption *opt;
- while (*o && isspace(*o))
+ while (*o && xisspace(*o))
o++;
for (oe = o; oe && *oe; oe++) {
- if (isspace(*oe))
+ if (xisspace(*oe))
break;
if (oe[0] == ':' && !(oe[1] == '/' && oe[2] == '/'))
break;
break;
case POPT_ARG_STRING:
{ const char ** t = opt->arg;
- if (*t) free((void *)*t);
+ *t = _free(*t);
*t = xstrdup( (p ? p : "") );
} break;
/*@access dbiIndex@*/ /* XXX compared with NULL */
/*@access dbiIndexSet@*/ /* XXX compared with NULL */
/*@access Header@*/ /* XXX compared with NULL */
+/*@access FD_t@*/ /* XXX compared with NULL */
/*@access rpmdb@*/ /* XXX compared with NULL */
+/*@access rpmdbMatchIterator@*/ /* XXX compared with NULL */
/*@access rpmTransactionSet@*/
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
-
int headerNVR(Header h, const char **np, const char **vp, const char **rp)
{
int type, count;
t = tbuf = xmalloc(nb + 1);
if (depend) {
- while(*depend) *t++ = *depend++;
+ while(*depend != '\0') *t++ = *depend++;
*t++ = ' ';
}
if (key)
- while(*key) *t++ = *key++;
+ while(*key != '\0') *t++ = *key++;
if (keyFlags & RPMSENSE_SENSEMASK) {
if (t != tbuf) *t++ = ' ';
if (keyFlags & RPMSENSE_LESS) *t++ = '<';
}
if (keyEVR && *keyEVR) {
if (t != tbuf) *t++ = ' ';
- while(*keyEVR) *t++ = *keyEVR++;
+ while(*keyEVR != '\0') *t++ = *keyEVR++;
}
*t = '\0';
return tbuf;
}
p->relocs = _free(p->relocs);
}
- if (p->fd)
+ if (p->fd != NULL)
p->fd = fdFree(p->fd, "alAddPackage (alFree)");
}
*/
static int dirInfoCompare(const void * one, const void * two) /*@*/
{
- const struct dirInfo * a = one;
- const struct dirInfo * b = two;
+ const dirInfo a = (const dirInfo) one;
+ const dirInfo b = (const dirInfo) two;
int lenchk = a->dirNameLen - b->dirNameLen;
if (lenchk)
const char ** dirNames;
int numDirs, dirNum;
int * dirMapping;
- struct dirInfo dirNeedle;
- struct dirInfo * dirMatch;
+ struct dirInfo_s dirNeedle;
+ dirInfo dirMatch;
int first, last, fileNum;
int origNumDirs;
int pkgNum;
}
p->key = key;
- p->fd = (fd ? fdLink(fd, "alAddPackage") : NULL);
+ p->fd = (fd != NULL ? fdLink(fd, "alAddPackage") : NULL);
if (relocs) {
for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++);
char *s, *se;
s = evr;
- while (*s && isdigit(*s)) s++; /* s points to epoch terminator */
+ while (*s && xisdigit(*s)) s++; /* s points to epoch terminator */
se = strrchr(s, '-'); /* se points to version terminator */
if (*s == ':') {
*p = '\0';
if (hge(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) {
sprintf(p, "%d:", *epoch);
- while (*p)
+ while (*p != '\0')
p++;
}
(void) stpcpy( stpcpy( stpcpy(p, version) , "-") , release);
ts->di = _free(ts->di);
ts->removedPackages = _free(ts->removedPackages);
ts->order = _free(ts->order);
- if (ts->scriptFd)
+ if (ts->scriptFd != NULL)
ts->scriptFd = fdFree(ts->scriptFd, "rpmtransSetScriptFd (rpmtransFree");
ts->rootDir = _free(ts->rootDir);
ts->currDir = _free(ts->currDir);
int i;
const char * dirName;
const char * baseName;
- struct dirInfo dirNeedle;
- struct dirInfo * dirMatch;
+ struct dirInfo_s dirNeedle;
+ dirInfo dirMatch;
if (al->numDirs == 0) /* Solaris 2.6 bsearch sucks down on this. */
return NULL;
(rcProvidesString = rpmGetVar(RPMVAR_PROVIDES))) {
i = strlen(keyName);
while ((start = strstr(rcProvidesString, keyName))) {
- if (isspace(start[i]) || start[i] == '\0' || start[i] == ',') {
+ if (xisspace(start[i]) || start[i] == '\0' || start[i] == ',') {
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (rpmrc provides)\n"),
keyType, keyDepend+2);
goto exit;
if (!hge(h, RPMTAG_REQUIRENAME, &rnt, (void **) &requires, &requiresCount))
{
requiresCount = 0;
+ rvt = RPM_STRING_ARRAY_TYPE;
} else {
hge(h, RPMTAG_REQUIREFLAGS, &type, (void **) &requireFlags,
&requiresCount);
if (!hge(h, RPMTAG_CONFLICTNAME, &cnt, (void **)&conflicts, &conflictsCount))
{
conflictsCount = 0;
+ cvt = RPM_STRING_ARRAY_TYPE;
} else {
hge(h, RPMTAG_CONFLICTFLAGS, &type,
(void **) &conflictFlags, &conflictsCount);
/* Avoid redundant relations. */
/* XXX FIXME: add control bit. */
matchNum = q - ts->addedPackages.list;
- if (selected[matchNum])
+ if (selected[matchNum] != 0)
return 0;
selected[matchNum] = 1;
* @retval rp address of last element
*/
static void addQ(/*@kept@*/ struct availablePackage * p,
- /*@out@*/ struct availablePackage ** qp,
- /*@out@*/ struct availablePackage ** rp)
+ struct availablePackage ** qp,
+ struct availablePackage ** rp)
{
struct availablePackage *q, *qprev;
sprintf(buf, "%s-%s-%s", p->name, p->version, p->release);
rpmMessage(RPMMESS_WARNING, " %-40s %s\n", buf, dp);
- dp = _free((void *)dp);
+ dp = _free(dp);
}
/* Walk (and erase) linear part of predecessor chain as well. */
rc = 0;
exit:
- if (mi)
+ if (mi != NULL)
rpmdbFreeIterator(mi);
ps.problems = _free(ps.problems);
return rc;
/** \ingroup rpmdep
* A directory to be installed/removed.
*/
-struct dirInfo {
+typedef struct dirInfo_s {
/*@owned@*/ const char * dirName; /*!< Directory path (+ trailing '/'). */
int dirNameLen; /*!< No. bytes in directory path. */
/*@owned@*/ struct fileIndexEntry * files; /*!< Array of files in directory. */
int numFiles; /*!< No. files in directory. */
-} ;
+} * dirInfo ;
/** \ingroup rpmdep
* Set of available packages, items, and directories.
int size; /*!< No. of pkgs in list. */
int alloced; /*!< No. of pkgs allocated for list. */
int numDirs; /*!< No. of directories. */
-/*@owned@*/ struct dirInfo * dirs; /*!< Set of directories. */
+/*@owned@*/ dirInfo dirs; /*!< Set of directories. */
} ;
/** \ingroup rpmdep
/*!< Packages sorted by dependencies. */
int orderCount; /*!< No. of transaction elements. */
int orderAlloced; /*!< No. of allocated transaction elements. */
-/*@shared@*/ TFI_t flList; /*!< Transaction element(s) file info. */
+/*@only@*/ TFI_t flList; /*!< Transaction element(s) file info. */
int flEntries; /*!< No. of transaction elements. */
int chrootDone; /*!< Has chroot(2) been been done? */
/*@only@*/ const char * rootDir;/*!< Path to top of install tree. */
}
exit:
- if (argv)
- free((void *)argv);
+ argv = _free(argv);
return rc;
}
strcat(formatPrefix, "s");
buf = rpmPermsString(*((int_32 *) data));
sprintf(val, formatPrefix, buf);
- free(buf);
+ buf = _free(buf);
}
return val;
/*@out@*/ int * freeData)
/*@modifies h, *type, *data, *count, *freeData @*/
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
+ int ipt;
char ** array;
- if (headerGetEntry(h, RPMTAG_INSTALLPREFIX, type, (void **)data, count)) {
+ if (hge(h, RPMTAG_INSTALLPREFIX, type, (void **)data, count)) {
*freeData = 0;
return 0;
- } else if (headerGetEntry(h, RPMTAG_INSTPREFIXES, NULL, (void **) &array,
- count)) {
+ } else if (hge(h, RPMTAG_INSTPREFIXES, &ipt, (void **) &array, count)) {
*data = xstrdup(array[0]);
*freeData = 1;
*type = RPM_STRING_TYPE;
- free(array);
+ array = hfd(array, ipt);
return 0;
}
/*@out@*/ int * freeData)
/*@modifies h, *type, *data, *count, *freeData @*/
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
const char ** filenames;
int_32 * filesizes;
uint_32 * usages;
int numFiles;
- if (!headerGetEntry(h, RPMTAG_FILESIZES, NULL, (void **) &filesizes,
- &numFiles)) {
+ if (!hge(h, RPMTAG_FILESIZES, NULL, (void **) &filesizes, &numFiles)) {
filesizes = NULL;
numFiles = 0;
filenames = NULL;
*data = usages;
- if (filenames) free(filenames);
+ filenames = _free(filenames);
return 0;
}
/*@out@*/ int * freeData)
/*@modifies h, *type, *data, *count, *freeData @*/
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
+ int tnt, tvt, tst;
int_32 * indices, * flags;
char ** names, ** versions;
int numNames, numScripts;
int i, j;
char buf[5];
- if (!headerGetEntry(h, RPMTAG_TRIGGERNAME, NULL, (void **) &names,
- &numNames)) {
+ if (!hge(h, RPMTAG_TRIGGERNAME, &tnt, (void **) &names, &numNames)) {
*freeData = 0;
return 0;
}
- headerGetEntry(h, RPMTAG_TRIGGERINDEX, NULL, (void **) &indices, NULL);
- headerGetEntry(h, RPMTAG_TRIGGERFLAGS, NULL, (void **) &flags, NULL);
- headerGetEntry(h, RPMTAG_TRIGGERVERSION, NULL, (void **) &versions, NULL);
- headerGetEntry(h, RPMTAG_TRIGGERSCRIPTS, NULL, (void **) &s, &numScripts);
- free(s);
+ hge(h, RPMTAG_TRIGGERINDEX, NULL, (void **) &indices, NULL);
+ hge(h, RPMTAG_TRIGGERFLAGS, NULL, (void **) &flags, NULL);
+ hge(h, RPMTAG_TRIGGERVERSION, &tvt, (void **) &versions, NULL);
+ hge(h, RPMTAG_TRIGGERSCRIPTS, &tst, (void **) &s, &numScripts);
+ s = hfd(s, tst);
*freeData = 1;
*data = conds = xmalloc(sizeof(char * ) * numScripts);
item = xmalloc(strlen(names[j]) + strlen(versions[j]) + 20);
if (flags[j] & RPMSENSE_SENSEMASK) {
buf[0] = '%', buf[1] = '\0';
- flagsStr = depflagsFormat(RPM_INT32_TYPE, flags, buf,
- 0, j);
+ flagsStr = depflagsFormat(RPM_INT32_TYPE, flags, buf, 0, j);
sprintf(item, "%s %s %s", names[j], flagsStr, versions[j]);
- free(flagsStr);
+ flagsStr = _free(flagsStr);
} else {
strcpy(item, names[j]);
}
chptr = xrealloc(chptr, strlen(chptr) + strlen(item) + 5);
- if (*chptr) strcat(chptr, ", ");
+ if (*chptr != '\0') strcat(chptr, ", ");
strcat(chptr, item);
- free(item);
+ item = _free(item);
}
conds[i] = chptr;
}
- free(names);
- free(versions);
+ names = hfd(names, tnt);
+ versions = hfd(versions, tvt);
return 0;
}
/*@out@*/ int * freeData)
/*@modifies h, *type, *data, *count, *freeData @*/
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
+ int tst;
int_32 * indices, * flags;
- char ** conds, ** s;
+ const char ** conds;
+ const char ** s;
int i, j;
int numScripts, numNames;
- if (!headerGetEntry(h, RPMTAG_TRIGGERINDEX, NULL, (void **) &indices,
- &numNames)) {
+ if (!hge(h, RPMTAG_TRIGGERINDEX, NULL, (void **) &indices, &numNames)) {
*freeData = 0;
return 1;
}
- headerGetEntry(h, RPMTAG_TRIGGERFLAGS, NULL, (void **) &flags, NULL);
-
- headerGetEntry(h, RPMTAG_TRIGGERSCRIPTS, NULL, (void **) &s, &numScripts);
- free(s);
+ hge(h, RPMTAG_TRIGGERFLAGS, NULL, (void **) &flags, NULL);
+ hge(h, RPMTAG_TRIGGERSCRIPTS, &tst, (void **) &s, &numScripts);
+ s = hfd(s, tst);
*freeData = 1;
*data = conds = xmalloc(sizeof(char * ) * numScripts);
/*@out@*/ int * freeData)
/*@modifies h, *type, *data, *count, *freeData @*/
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
char * dstring = rpmExpand(_macro_i18ndomains, NULL);
int rc;
*count = 1;
*freeData = 1;
}
- free(dstring); dstring = NULL;
- if (*data) {
+ dstring = _free(dstring);
+ if (*data)
return 0;
- }
}
- if (dstring) free(dstring);
+ dstring = _free(dstring);
- rc = headerGetEntry(h, tag, type, (void **)data, count);
+ rc = hge(h, tag, type, (void **)data, count);
if (rc) {
*data = xstrdup(*data);
/* as we're stating paths here, we want to follow symlinks */
- if ((cacheHit = cacheContainsDirectory(cache, *buf ? buf : "/"))) {
+ cacheHit = cacheContainsDirectory(cache, (*buf != '\0' ? buf : "/"));
+ if (cacheHit != NULL) {
fp.entry = cacheHit;
- } else if (!stat(*buf ? buf : "/", &sb)) {
- size_t nb = sizeof(*fp.entry) + (*buf ? (end-buf) : 1) + 1;
+ } else if (!stat((*buf != '\0' ? buf : "/"), &sb)) {
+ size_t nb = sizeof(*fp.entry) + (*buf != '\0' ? (end-buf) : 1) + 1;
char * dn = xmalloc(nb);
struct fprintCacheEntry_s * newEntry = (void *)dn;
dn += sizeof(*newEntry);
- strcpy(dn, (*buf ? buf : "/"));
+ strcpy(dn, (*buf != '\0' ? buf : "/"));
newEntry->ino = sb.st_ino;
newEntry->dev = sb.st_dev;
newEntry->isFake = 0;
ch = 0;
chptr = fp->baseName;
- while (*chptr) ch ^= *chptr++;
+ while (*chptr != '\0') ch ^= *chptr++;
hash |= ((unsigned)ch) << 24;
hash |= (((((unsigned)fp->entry->dev) >> 8) ^ fp->entry->dev) & 0xFF) << 16;
if (filesystems) {
int i;
for (i = 0; i < numFilesystems; i++)
- free((void *)filesystems[i].mntPoint);
- free(filesystems);
- filesystems = NULL;
+ filesystems[i].mntPoint = _free(filesystems[i].mntPoint);
+ filesystems = _free(filesystems);
}
if (fsnames) {
#if 0 /* XXX leak/segfault on exit of "rpm -qp --qf '%{#fsnames}' pkg" */
if (errno != ENOENT) {
rpmError(RPMERR_STAT, _("failed to stat %s: %s\n"), buf,
strerror(errno));
- free((void *)sourceDir);
- free(usages);
+ sourceDir = _free(sourceDir);
+ usages = _free(usages);
return 1;
}
if (j == numFilesystems) {
rpmError(RPMERR_BADDEV,
_("file %s is on an unknown device\n"), buf);
- free((void *)sourceDir);
- free(usages);
+ sourceDir = _free(sourceDir);
+ usages = _free(usages);
return 1;
}
usages[lastfs] += fssizes[i];
}
- if (sourceDir) free((void *)sourceDir);
+ sourceDir = _free(sourceDir);
- *usagesPtr = usages;
+ if (usagesPtr)
+ *usagesPtr = usages;
+ else
+ usages = _free(usages);
return 0;
}
/*@access FD_t @*/
/*@access rpmTransactionSet @*/
/*@access TFI_t @*/
+/*@access FSMI_t @*/
/*@access FSM_t @*/
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
-
int _fsm_debug = 0;
rpmTransactionSet fsmGetTs(const FSM_t fsm) {
FSM_t freeFSM(FSM_t fsm)
{
if (fsm) {
- if (fsm->path) free((void *)fsm->path);
+ fsm->path = _free(fsm->path);
while ((fsm->li = fsm->links) != NULL) {
fsm->links = fsm->li->next;
fsm->li->next = NULL;
fsm->path = dn;
/* Assume '/' directory exists, otherwise "mkdir -p" if non-existent. */
- for (i = 1, te = dn + 1; *te; te++, i++) {
+ for (i = 1, te = dn + 1; *te != '\0'; te++, i++) {
if (*te != '/') continue;
*te = '\0';
if (!rc)
rpmMessage(RPMMESS_WARNING,
_("%s directory created with perms %04o.\n"),
- fsm->path, (st->st_mode & 07777));
+ fsm->path, (unsigned)(st->st_mode & 07777));
*te = '/';
}
if (rc) break;
if (_fsm_debug && !(stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s %06o%3d (%4d,%4d)%10d %s %s\n",
cur,
- st->st_mode, st->st_nlink, st->st_uid, st->st_gid, st->st_size,
+ (unsigned)st->st_mode, (int)st->st_nlink,
+ (int)st->st_uid, (int)st->st_gid, (int)st->st_size,
(fsm->path ? fsm->path : ""),
_fafilter(fsm->action));
} else {
if (_fsm_debug || !(stage & FSM_VERBOSE))
rpmMessage(RPMMESS_DEBUG, "%-8s %06o%3d (%4d,%4d)%10d %s %s\n",
cur,
- st->st_mode, st->st_nlink, st->st_uid, st->st_gid, st->st_size,
+ (unsigned)st->st_mode, (int)st->st_nlink,
+ (int)st->st_uid, (int)st->st_gid, (int)st->st_size,
(fsm->path ? fsm->path + fsm->astriplen : ""),
_fafilter(fsm->action));
}
rc = Mkdir(fsm->path, (st->st_mode & 07777));
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (%s, 0%04o) %s\n", cur,
- fsm->path, (st->st_mode & 07777),
+ fsm->path, (unsigned)(st->st_mode & 07777),
(rc < 0 ? strerror(errno) : ""));
if (rc < 0) rc = CPIOERR_MKDIR_FAILED;
break;
rc = chown(fsm->path, st->st_uid, st->st_gid);
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (%s, %d, %d) %s\n", cur,
- fsm->path, st->st_uid, st->st_gid,
+ fsm->path, (int)st->st_uid, (int)st->st_gid,
(rc < 0 ? strerror(errno) : ""));
if (rc < 0) rc = CPIOERR_CHOWN_FAILED;
break;
rc = lchown(fsm->path, st->st_uid, st->st_gid);
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (%s, %d, %d) %s\n", cur,
- fsm->path, st->st_uid, st->st_gid,
+ fsm->path, (int)st->st_uid, (int)st->st_gid,
(rc < 0 ? strerror(errno) : ""));
if (rc < 0) rc = CPIOERR_CHOWN_FAILED;
#endif
rc = chmod(fsm->path, (st->st_mode & 07777));
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (%s, 0%04o) %s\n", cur,
- fsm->path, (st->st_mode & 07777),
+ fsm->path, (unsigned)(st->st_mode & 07777),
(rc < 0 ? strerror(errno) : ""));
if (rc < 0) rc = CPIOERR_CHMOD_FAILED;
break;
rc = mkfifo(fsm->path, (st->st_mode & 07777));
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (%s, 0%04o) %s\n", cur,
- fsm->path, (st->st_mode & 07777),
+ fsm->path, (unsigned)(st->st_mode & 07777),
(rc < 0 ? strerror(errno) : ""));
if (rc < 0) rc = CPIOERR_MKFIFO_FAILED;
break;
rc = mknod(fsm->path, (st->st_mode & ~07777), st->st_rdev);
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (%s, 0%o, 0x%x) %s\n", cur,
- fsm->path, (st->st_mode & ~07777), (unsigned)st->st_rdev,
+ fsm->path, (unsigned)(st->st_mode & ~07777),
+ (unsigned)st->st_rdev,
(rc < 0 ? strerror(errno) : ""));
if (rc < 0) rc = CPIOERR_MKNOD_FAILED;
/*@=unrecog@*/
rc = Readlink(fsm->path, fsm->rdbuf, fsm->rdsize - 1);
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (%s, rdbuf, %d) %s\n", cur,
- fsm->path, fsm->rdlen, (rc < 0 ? strerror(errno) : ""));
+ fsm->path, (int)fsm->rdlen, (rc < 0 ? strerror(errno) : ""));
if (rc < 0) rc = CPIOERR_READLINK_FAILED;
else {
fsm->rdnb = rc;
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (%s, %d, cfd)\trdnb %d\n",
cur, (fsm->wrbuf == fsm->wrb ? "wrbuf" : "mmap"),
- fsm->wrlen, fsm->rdnb);
+ (int)fsm->wrlen, (int)fsm->rdnb);
if (fsm->rdnb != fsm->wrlen) fprintf(stderr, "*** short read, had %d, got %d\n", (int)fsm->rdnb, (int)fsm->wrlen);
#ifdef NOTYET
if (Ferror(fsm->rfd))
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (%s, %d, cfd)\twrnb %d\n",
cur, (fsm->rdbuf == fsm->rdb ? "rdbuf" : "mmap"),
- fsm->rdnb, fsm->wrnb);
+ (int)fsm->rdnb, (int)fsm->wrnb);
if (fsm->rdnb != fsm->wrnb) fprintf(stderr, "*** short write, had %d, got %d\n", (int)fsm->rdnb, (int)fsm->wrnb);
#ifdef NOTYET
if (Ferror(fsm->wfd))
fsm->rdnb = Fread(fsm->rdbuf, sizeof(*fsm->rdbuf), fsm->rdlen, fsm->rfd);
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (rdbuf, %d, rfd)\trdnb %d\n",
- cur, fsm->rdlen, fsm->rdnb);
+ cur, (int)fsm->rdlen, (int)fsm->rdnb);
if (fsm->rdnb != fsm->rdlen) fprintf(stderr, "*** short read, had %d, got %d\n", (int)fsm->rdnb, (int)fsm->rdlen);
#ifdef NOTYET
if (Ferror(fsm->rfd))
fsm->wrnb = Fwrite(fsm->wrbuf, sizeof(*fsm->wrbuf), fsm->rdnb, fsm->wfd);
if (_fsm_debug && (stage & FSM_SYSCALL))
rpmMessage(RPMMESS_DEBUG, " %8s (wrbuf, %d, wfd)\twrnb %d\n",
- cur, fsm->rdnb, fsm->wrnb);
+ cur, (int)fsm->rdnb, (int)fsm->wrnb);
if (fsm->rdnb != fsm->wrnb) fprintf(stderr, "*** short write: had %d, got %d\n", (int)fsm->rdnb, (int)fsm->wrnb);
#ifdef NOTYET
if (Ferror(fsm->wfd))
int abbrev;
/* Make it lowercase. */
- for (p = buff; *p; p++)
+ for (p = buff; *p != '\0'; p++)
if (isupper(*p))
*p = tolower(*p);
}
/* Drop out any periods and try the timezone table again. */
- for (i = 0, p = q = buff; *q; q++)
+ for (i = 0, p = q = buff; *q != '\0'; q++)
if (*q != '.')
*p++ = *q;
else
* @param onDisk data is concatenated strings (with NUL's))?
* @return no. bytes in data
*/
+/*@mayexit@*/
static int dataLength(int_32 type, const void * p, int_32 count, int onDisk)
/*@*/
{
if ((table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE)) == NULL)
return entry->data;
- for (l = lang; *l; l = le) {
+ for (l = lang; *l != '\0'; l = le) {
const char *td;
char *ed;
int langNum;
/* upper limit on number of individual formats */
numTokens = 0;
- for (chptr = str; *chptr; chptr++)
+ for (chptr = str; *chptr != '\0'; chptr++)
if (*chptr == '%') numTokens++;
numTokens = numTokens * 2 + 1;
/*@-infloops@*/
dst = start = str;
currToken = -1;
- while (*start) {
+ while (*start != '\0') {
switch (*start) {
case '%':
/* handle %% */
*chptr++ = '\0';
while (start < chptr) {
- if (isdigit(*start)) {
+ if (xisdigit(*start)) {
i = strtoul(start, &start, 10);
format[currToken].u.tag.pad += i;
} else {
chptr = start;
while (*chptr && *chptr != ':') chptr++;
- if (*chptr) {
+ if (*chptr != '\0') {
*chptr++ = '\0';
if (!*chptr) {
/*@-observertrans@*/
result = dst = xmalloc(strlen(buf) * 4 + 3);
*dst++ = '\'';
- for (src = buf; *src; src++) {
+ for (src = buf; *src != '\0'; src++) {
if (*src == '\'') {
*dst++ = '\'';
*dst++ = '\\';
* @param c number of values
* @return 1 on success, 0 on failure
*/
+/*@mayexit@*/
int headerAddEntry(Header h, int_32 tag, int_32 type, const void *p, int_32 c)
/*@modifies h @*/;
#include "system.h"
+#include <rpmlib.h>
#include <rpmio_internal.h>
#include "stringbuf.h"
#include "manifest.h"
/*@access StringBuf @*/
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
-
char * rpmPermsString(int mode)
{
char *perms = xstrdup("----------");
int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr)
{
StringBuf sb = newStringBuf();
- char * s, *se;
+ char * s = NULL;
+ char * se;
int ac = 0;
const char ** av = NULL;
int argc = (argcPtr ? *argcPtr : 0);
/*@access Header@*/ /* XXX compared with NULL */
/*@access FD_t@*/ /* XXX compared with NULL */
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
-
char * RPMVERSION = VERSION; /* just to put a marker in librpm.a */
char ** splitString(const char * str, int length, char sep)
/* loop through each version segment of str1 and str2 and compare them */
while (*one && *two) {
- while (*one && !isalnum(*one)) one++;
- while (*two && !isalnum(*two)) two++;
+ while (*one && !xisalnum(*one)) one++;
+ while (*two && !xisalnum(*two)) two++;
str1 = one;
str2 = two;
/* grab first completely alpha or completely numeric segment */
/* leave one and two pointing to the start of the alpha or numeric */
/* segment and walk str1 and str2 to end of segment */
- if (isdigit(*str1)) {
- while (*str1 && isdigit(*str1)) str1++;
- while (*str2 && isdigit(*str2)) str2++;
+ if (xisdigit(*str1)) {
+ while (*str1 && xisdigit(*str1)) str1++;
+ while (*str2 && xisdigit(*str2)) str2++;
isnum = 1;
} else {
- while (*str1 && isalpha(*str1)) str1++;
- while (*str2 && isalpha(*str2)) str2++;
+ while (*str1 && xisalpha(*str1)) str1++;
+ while (*str2 && xisalpha(*str2)) str2++;
isnum = 0;
}
d = alloca(strlen(path)+2);
de = stpcpy(d, path);
de[1] = '\0';
- for (de = d; *de; de++) {
+ for (de = d; *de != '\0'; de++) {
struct stat st;
char savec;
*p = '\0';
if (headerGetEntry(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) {
sprintf(p, "%d:", *epoch);
- while (*p)
+ while (*p != '\0')
p++;
}
(void) stpcpy( stpcpy( stpcpy(p, version) , "-") , release);
* @param c character to strip
* @return string
*/
-/*@unused@*/ static inline char * stripTrailingChar(char * s, char c)
+/*@unused@*/ static inline
+/*@only@*/ char * stripTrailingChar(/*@only@*/ char * s, char c)
/*@modifies *s */
{
char * t;
case POPT_TP:
case POPT_TS:
if (rba->buildMode == ' ') {
- rba->buildMode = ((unsigned)(opt->val >> 8)) & 0xff;
+ rba->buildMode = (((unsigned)opt->val) >> 8) & 0xff;
rba->buildChar = (opt->val ) & 0xff;
}
break;
static void queryArgCallback(/*@unused@*/poptContext con, /*@unused@*/enum poptCallbackReason reason,
const struct poptOption * opt, const char * arg,
- const void * data)
+ /*@unused@*/ const void * data)
{
QVA_t *qva = &rpmQVArgs;
}
}
-#if !defined(HAVE_VSNPRINTF)
+#if !defined(HAVE_VSNPRINTF) || defined(__LCLINT__)
static inline int vsnprintf(char * buf, /*@unused@*/ int nb,
const char * fmt, va_list ap)
{
return vsprintf(buf, fmt, ap);
}
#endif
-#if !defined(HAVE_SNPRINTF)
+#if !defined(HAVE_SNPRINTF) || defined(__LCLINT__)
static inline int snprintf(char * buf, int nb, const char * fmt, ...)
{
va_list ap;
{
const char *msg = rpmProblemString(prob);
fprintf(fp, "%s\n", msg);
- free((void *)msg);
+ msg = _free(msg);
}
void rpmProblemSetPrint(FILE *fp, rpmProblemSet probs)
extern int _fsm_debug;
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
-
int rpmVersionCompare(Header first, Header second)
{
const char * one, * two;
if (ipath && ipath[5] != '%')
path = ipath;
doputenv(path);
- if (ipath) free((void *)ipath);
+ ipath = _free(ipath);
}
for (i = 0; i < numPrefixes; i++) {
if (script) {
if (!rpmIsDebug()) unlink(fn);
- free((void *)fn);
+ fn = _free(fn);
}
return rc;
* @return
*/
static int handleOneTrigger(PSM_t psm, Header sourceH, Header triggeredH,
- int arg2, char * triggersAlreadyRun)
+ int arg2, unsigned char * triggersAlreadyRun)
{
const rpmTransactionSet ts = psm->ts;
TFI_t fi = psm->fi;
} else {
arg1 += psm->countCorrection;
index = triggerIndices[i];
- if (!triggersAlreadyRun || !triggersAlreadyRun[index]) {
+ if (triggersAlreadyRun == NULL ||
+ triggersAlreadyRun[index] == 0)
+ {
rc = runScript(psm, triggeredH, "%trigger", 1,
triggerProgs + index, triggerScripts[index],
arg1, arg2);
- if (triggersAlreadyRun) triggersAlreadyRun[index] = 1;
+ if (triggersAlreadyRun != NULL)
+ triggersAlreadyRun[index] = 1;
}
}
}
int_32 * triggerIndices;
int_32 tnt, tit;
int numTriggerIndices;
- char * triggersRun;
+ unsigned char * triggersRun;
rpmRC rc = RPMRC_OK;
if (!hge(fi->h, RPMTAG_TRIGGERNAME, &tnt,
for (i = 0; i < numTriggers; i++) {
rpmdbMatchIterator mi;
- if (triggersRun[triggerIndices[i]]) continue;
+ if (triggersRun[triggerIndices[i]] != 0) continue;
mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_NAME, triggerNames[i], 0);
#include "manifest.h"
#include "debug.h"
-/*@access Header@*/ /* XXX compared with NULL */
/*@access rpmdbMatchIterator@*/ /* XXX compared with NULL */
-
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
+/*@access Header@*/ /* XXX compared with NULL */
+/*@access rpmdb@*/ /* XXX compared with NULL */
+/*@access FD_t@*/ /* XXX compared with NULL */
/**
*/
{
char sizefield[15];
char ownerfield[9], groupfield[9];
- char timefield[100] = "";
+ char timefield[100];
time_t when = mtime; /* important if sizeof(int_32) ! sizeof(time_t) */
struct tm * tm;
static time_t now;
t = xrealloc(t, BUFSIZ+sb);
te = t + tb;
}
+ /*@-usereleased@*/
te = stpcpy(te, str);
+ /*@=usereleased@*/
str = _free(str);
}
}
{ const char * s;
char * fn;
- for (s = arg; *s; s++)
+ for (s = arg; *s != '\0'; s++)
if (!(*s == '.' || *s == '/')) break;
if (*s == '\0') {
case RPMQV_DBOFFSET:
{ int mybase = 10;
const char * myarg = arg;
- int recOffset;
+ unsigned recOffset;
/* XXX should be in strtoul */
if (*myarg == '0') {
mi = rpmdbInitIterator(rpmdb, RPMDBI_PACKAGES, &recOffset, sizeof(recOffset));
if (mi == NULL) {
rpmError(RPMERR_QUERY,
- _("record %d could not be read\n"), recOffset);
+ _("record %u could not be read\n"), recOffset);
retcode = 1;
} else {
retcode = showMatches(qva, mi, showPackage);
rc = rpmQueryVerify(qva, source, arg, rpmdb, showQueryPackage);
- if (rpmdb)
+ if (rpmdb != NULL)
rpmdbClose(rpmdb);
return rc;
/* Clean up intermediate target */
unlink(sigtarget);
- free((void *)sigtarget); sigtarget = NULL;
+ sigtarget = _free(sigtarget);
/* Move final target into place. */
unlink(rpm);
}
if (sigtarget) {
unlink(sigtarget);
- free((void *)sigtarget);
- sigtarget = NULL;
+ sigtarget = _free(sigtarget);
}
if (tmprpm[0] != '\0') {
unlink(tmprpm);
headerFreeIterator(hi);
res += res2;
unlink(sigtarget);
- free((void *)sigtarget); sigtarget = NULL;
+ sigtarget = _free(sigtarget);
if (res2) {
if (rpmIsVerbose()) {
if (ofd) manageFile(&ofd, NULL, 0, 0);
if (sigtarget) {
unlink(sigtarget);
- free((void *)sigtarget); sigtarget = NULL;
+ sigtarget = _free(sigtarget);
}
}
dbiTagStr = rpmExpand("%{_dbi_tags}", NULL);
if (!(dbiTagStr && *dbiTagStr && *dbiTagStr != '%')) {
- free((void *)dbiTagStr);
+ dbiTagStr = _free(dbiTagStr);
dbiTagStr = xstrdup(_dbiTagStr_default);
}
if (dbiTagsMax || dbiTags) {
- free(dbiTags);
- dbiTags = NULL;
+ dbiTags = _free(dbiTags);
dbiTagsMax = 0;
}
dbiTags = xcalloc(1, dbiTagsMax * sizeof(*dbiTags));
for (o = dbiTagStr; o && *o; o = oe) {
- while (*o && isspace(*o))
+ while (*o && xisspace(*o))
o++;
if (*o == '\0')
break;
for (oe = o; oe && *oe; oe++) {
- if (isspace(*oe))
+ if (xisspace(*oe))
break;
if (oe[0] == ':' && !(oe[1] == '/' && oe[2] == '/'))
break;
dbiTags[dbiTagsMax++] = rpmtag;
}
- if (dbiTagStr)
- free(dbiTagStr);
+ dbiTagStr = _free(dbiTagStr);
}
#if USE_DB1
* @param dbcursor index database cursor
* @param keyp search key
* @param keylen search key length (0 will use strlen(key))
- * @param setp address of items retrieved from index database
+ * @retval setp address of items retrieved from index database
* @return -1 error, 0 success, 1 not found
*/
static int dbiSearch(dbiIndex dbi, DBC * dbcursor,
- const char * keyp, size_t keylen, dbiIndexSet * setp)
+ const char * keyp, size_t keylen, /*@out@*/ dbiIndexSet * setp)
{
void * datap = NULL;
size_t datalen = 0;
for (i = 0; i < set->count; i++) {
union _dbswap hdrNum, tagNum;
+ memset(&hdrNum, 0, sizeof(hdrNum));
+ memset(&tagNum, 0, sizeof(tagNum));
hdrNum.ui = set->recs[i].hdrNum;
tagNum.ui = set->recs[i].tagNum;
if (_dbbyteswapped) {
for (i = 0; i < set->count; i++) {
union _dbswap hdrNum;
+ memset(&hdrNum, 0, sizeof(hdrNum));
hdrNum.ui = set->recs[i].hdrNum;
if (_dbbyteswapped) {
_DBSWAP(hdrNum);
if (set == NULL || recs == NULL || nrecs <= 0 || recsize <= 0)
return 1;
- set->recs = (set->count == 0)
- ? xmalloc(nrecs * sizeof(*(set->recs)))
- : xrealloc(set->recs, (set->count + nrecs) * sizeof(*(set->recs)));
+ if (set->count == 0)
+ set->recs = xmalloc(nrecs * sizeof(*(set->recs)));
+ else
+ set->recs = xrealloc(set->recs,
+ (set->count + nrecs) * sizeof(*(set->recs)));
memset(set->recs + set->count, 0, nrecs * sizeof(*(set->recs)));
dbiClose(rpmdb->_dbi[dbix], 0);
rpmdb->_dbi[dbix] = NULL;
}
- if (rpmdb->db_errpfx) {
- free((void *)rpmdb->db_errpfx);
- rpmdb->db_errpfx = NULL;
- }
- if (rpmdb->db_root) {
- free((void *)rpmdb->db_root);
- rpmdb->db_root = NULL;
- }
- if (rpmdb->db_home) {
- free((void *)rpmdb->db_home);
- rpmdb->db_home = NULL;
- }
- if (rpmdb->_dbi) {
- free((void *)rpmdb->_dbi);
- rpmdb->_dbi = NULL;
- }
- free(rpmdb);
+ rpmdb->db_errpfx = _free(rpmdb->db_errpfx);
+ rpmdb->db_root = _free(rpmdb->db_root);
+ rpmdb->db_home = _free(rpmdb->db_home);
+ rpmdb->_dbi = _free(rpmdb->_dbi);
+ rpmdb = _free(rpmdb);
return 0;
}
static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
/*@out@*/ dbiIndexSet * matches)
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
const char * dirName;
const char * baseName;
+ int bnt, dnt;
fingerPrintCache fpc;
fingerPrint fp1;
dbiIndex dbi = NULL;
continue;
}
- headerGetEntryMinMemory(h, RPMTAG_BASENAMES, NULL,
- (const void **) &baseNames, NULL);
- headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
- (const void **) &dirNames, NULL);
- headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
- (const void **) &dirIndexes, NULL);
+ hge(h, RPMTAG_BASENAMES, &bnt, (void **) &baseNames, NULL);
+ hge(h, RPMTAG_DIRNAMES, &dnt, (void **) &dirNames, NULL);
+ hge(h, RPMTAG_DIRINDEXES, NULL, (const void **) &dirIndexes, NULL);
do {
fingerPrint fp2;
} while (i < allMatches->count &&
(i == 0 || offset == prevoff));
- free(baseNames);
- free(dirNames);
+ baseNames = hfd(baseNames, bnt);
+ dirNames = hfd(dirNames, dnt);
headerFree(h);
}
- if (rec) {
- free(rec);
- rec = NULL;
- }
+ rec = _free(rec);
if (allMatches) {
dbiFreeIndexSet(allMatches);
allMatches = NULL;
dbi->dbi_rmw = NULL;
}
- if (mi->mi_release) {
- free((void *)mi->mi_release);
- mi->mi_release = NULL;
- }
- if (mi->mi_version) {
- free((void *)mi->mi_version);
- mi->mi_version = NULL;
- }
+ mi->mi_release = _free(mi->mi_release);
+ mi->mi_version = _free(mi->mi_version);
if (mi->mi_dbc) {
xx = dbiCclose(dbi, mi->mi_dbc, 1);
mi->mi_dbc = NULL;
dbiFreeIndexSet(mi->mi_set);
mi->mi_set = NULL;
}
- if (mi->mi_keyp) {
- free((void *)mi->mi_keyp);
- mi->mi_keyp = NULL;
- }
- free(mi);
+ mi->mi_keyp = _free(mi->mi_keyp);
+ mi = _free(mi);
}
rpmdb rpmdbGetIteratorRpmDB(rpmdbMatchIterator mi) {
void rpmdbSetIteratorRelease(rpmdbMatchIterator mi, const char * release) {
if (mi == NULL)
return;
- if (mi->mi_release) {
- free((void *)mi->mi_release);
- mi->mi_release = NULL;
- }
+ mi->mi_release = _free(mi->mi_release);
mi->mi_release = (release ? xstrdup(release) : NULL);
}
void rpmdbSetIteratorVersion(rpmdbMatchIterator mi, const char * version) {
if (mi == NULL)
return;
- if (mi->mi_version) {
- free((void *)mi->mi_version);
- mi->mi_version = NULL;
- }
+ mi->mi_version = _free(mi->mi_version);
mi->mi_version = (version ? xstrdup(version) : NULL);
}
/* XXX install.c uninstall.c */
int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum)
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
Header h;
sigset_t signalMask;
{ const char *n, *v, *r;
headerNVR(h, &n, &v, &r);
- rpmMessage(RPMMESS_DEBUG, " --- %10d %s-%s-%s\n", hdrNum, n, v, r);
+ rpmMessage(RPMMESS_DEBUG, " --- %10u %s-%s-%s\n", hdrNum, n, v, r);
}
blockSignals(rpmdb, &signalMask);
/*@notreached@*/ break;
}
- if (!headerGetEntry(h, rpmtag, &rpmtype,
- (void **) &rpmvals, &rpmcnt))
+ if (!hge(h, rpmtag, &rpmtype, (void **) &rpmvals, &rpmcnt))
continue;
dbi = dbiOpen(rpmdb, rpmtag, 0);
if (!dbi->dbi_no_dbsync)
xx = dbiSync(dbi, 0);
- rpmvals = headerFreeData(rpmvals, rpmtype);
+ rpmvals = hfd(rpmvals, rpmtype);
rpmtype = 0;
rpmcnt = 0;
}
/* XXX install.c */
int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
sigset_t signalMask;
const char ** baseNames;
+ int bnt;
int count = 0;
- int type;
dbiIndex dbi;
int dbix;
unsigned int hdrNum;
* being written to the package header database.
*/
- headerGetEntry(h, RPMTAG_BASENAMES, &type, (void **) &baseNames, &count);
+ hge(h, RPMTAG_BASENAMES, &bnt, (void **) &baseNames, &count);
if (_noDirTokens)
expandFilelist(h);
xx = dbiSync(dbi, 0);
{ const char *n, *v, *r;
headerNVR(h, &n, &v, &r);
- rpmMessage(RPMMESS_DEBUG, " +++ %10d %s-%s-%s\n", hdrNum, n, v, r);
+ rpmMessage(RPMMESS_DEBUG, " +++ %10u %s-%s-%s\n", hdrNum, n, v, r);
}
continue;
/*@notreached@*/ break;
/* XXX preserve legacy behavior */
case RPMTAG_BASENAMES:
- rpmtype = type;
+ rpmtype = bnt;
rpmvals = baseNames;
rpmcnt = count;
break;
case RPMTAG_REQUIRENAME:
- headerGetEntry(h, rpmtag, &rpmtype, (void **)&rpmvals, &rpmcnt);
- headerGetEntry(h, RPMTAG_REQUIREFLAGS, NULL,
- (void **)&requireFlags, NULL);
+ hge(h, rpmtag, &rpmtype, (void **)&rpmvals, &rpmcnt);
+ hge(h, RPMTAG_REQUIREFLAGS, NULL, (void **)&requireFlags, NULL);
break;
default:
- headerGetEntry(h, rpmtag, &rpmtype, (void **)&rpmvals, &rpmcnt);
+ hge(h, rpmtag, &rpmtype, (void **)&rpmvals, &rpmcnt);
break;
}
xx = dbiSync(dbi, 0);
/*@-observertrans@*/
- rpmvals = headerFreeData(rpmvals, rpmtype);
+ rpmvals = hfd(rpmvals, rpmtype);
/*@=observertrans@*/
rpmtype = 0;
rpmcnt = 0;
int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList,
int numItems)
{
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
rpmdbMatchIterator mi;
fingerPrintCache fpc;
Header h;
const char ** dirNames;
const char ** baseNames;
const char ** fullBaseNames;
+ int bnt, dnt;
int_32 * dirIndexes;
int_32 * fullDirIndexes;
fingerPrint * fps;
num = end - start;
/* Compute fingerprints for this header's matches */
- headerGetEntryMinMemory(h, RPMTAG_BASENAMES, NULL,
- (const void **) &fullBaseNames, NULL);
- headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
- (const void **) &dirNames, NULL);
- headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
- (const void **) &fullDirIndexes, NULL);
+ hge(h, RPMTAG_BASENAMES, &bnt, (void **) &fullBaseNames, NULL);
+ hge(h, RPMTAG_DIRNAMES, &dnt, (void **) &dirNames, NULL);
+ hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &fullDirIndexes, NULL);
baseNames = xcalloc(num, sizeof(*baseNames));
dirIndexes = xcalloc(num, sizeof(*dirIndexes));
dbiAppendSet(matchList[im->fpNum], im, 1, sizeof(*im), 0);
}
- free(fps);
- free(dirNames);
- free(fullBaseNames);
- free(baseNames);
- free(dirIndexes);
+ fps = _free(fps);
+ dirNames = hfd(dirNames, dnt);
+ fullBaseNames = hfd(fullBaseNames, bnt);
+ baseNames = _free(baseNames);
+ dirIndexes = _free(dirIndexes);
mi->mi_setx = end;
}
sprintf(filename, "%s/%s/%s", rootdir, dbpath, base);
(void)rpmCleanPath(filename);
xx = unlink(filename);
- free((void *)base);
+ base = _free(base);
}
break;
}
(void)rpmCleanPath(nfilename);
if ((xx = Rename(ofilename, nfilename)) != 0)
rc = 1;
- free((void *)base);
+ base = _free(base);
}
break;
}
dbpath = rootdbpath = rpmGetPath(rootdir, tfn, NULL);
if (!(rootdir[0] == '/' && rootdir[1] == '\0'))
dbpath += strlen(rootdir);
- free((void *)tfn);
+ tfn = _free(tfn);
tfn = rpmGetPath("%{_dbpath_rebuild}", NULL);
if (!(tfn && tfn[0] != '%' && strcmp(tfn, dbpath))) {
sprintf(pidbuf, "rebuilddb.%d", (int) getpid());
t = xmalloc(strlen(dbpath) + strlen(pidbuf) + 1);
(void)stpcpy(stpcpy(t, dbpath), pidbuf);
- if (tfn) free((void *)tfn);
+ tfn = _free(tfn);
tfn = t;
nocleanup = 0;
}
newdbpath = newrootdbpath = rpmGetPath(rootdir, tfn, NULL);
if (!(rootdir[0] == '/' && rootdir[1] == '\0'))
newdbpath += strlen(rootdir);
- free((void *)tfn);
+ tfn = _free(tfn);
rpmMessage(RPMMESS_DEBUG, _("rebuilding database %s into %s\n"),
rootdbpath, newrootdbpath);
headerIsEntry(h, RPMTAG_BUILDTIME)))
{
rpmError(RPMERR_INTERNAL,
- _("record number %d in database is bad -- skipping.\n"),
+ _("record number %u in database is bad -- skipping.\n"),
_RECNUM);
continue;
}
if (rc) {
rpmError(RPMERR_INTERNAL,
- _("cannot add record originally at %d\n"), _RECNUM);
+ _("cannot add record originally at %u\n"), _RECNUM);
failed = 1;
break;
}
rpmMessage(RPMMESS_ERROR, _("failed to remove directory %s: %s\n"),
newrootdbpath, strerror(errno));
}
- if (newrootdbpath) free((void *)newrootdbpath);
- if (rootdbpath) free((void *)rootdbpath);
+ newrootdbpath = _free(newrootdbpath);
+ rootdbpath = _free(rootdbpath);
return rc;
}
int dbi_tflags; /*!< dbenv->txn_begin flags */
int dbi_type; /*!< db index type */
- int dbi_mode; /*!< mode to use on open */
+ unsigned dbi_mode; /*!< mode to use on open */
int dbi_perms; /*!< file permission to use on open */
int dbi_api; /*!< Berkeley API type */
#include "debug.h"
/*@access rpmTransactionSet@*/ /* XXX compared with NULL */
+/*@access rpmProblemSet@*/ /* XXX compared with NULL */
/*@access Header@*/ /* XXX compared with NULL */
/*@access FD_t@*/ /* XXX compared with NULL */
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
-
/* Define if you want percentage progress in the hash bars when
* writing to a tty (ordinary hash bars otherwise) --claudio
*/
rc = rpmGlob(*fnp, &ac, &av);
if (rc || ac == 0) continue;
- argv = (argc == 0)
- ? xmalloc((argc+2) * sizeof(*argv))
- : xrealloc(argv, (argc+2) * sizeof(*argv));
+ if (argv == NULL)
+ argv = xmalloc((argc+ac+1) * sizeof(*argv));
+ else
+ argv = xrealloc(argv, (argc+ac+1) * sizeof(*argv));
memcpy(argv+argc, av, ac * sizeof(*av));
argc += ac;
argv[argc] = NULL;
/* Allocate sufficient storage for next set of args. */
if (pkgx >= numPkgs) {
numPkgs = pkgx + argc;
- pkgURL = (pkgURL == NULL)
- ? xmalloc( (numPkgs + 1) * sizeof(*pkgURL))
- : xrealloc(pkgURL, (numPkgs + 1) * sizeof(*pkgURL));
+ if (pkgURL == NULL)
+ pkgURL = xmalloc( (numPkgs + 1) * sizeof(*pkgURL));
+ else
+ pkgURL = xrealloc(pkgURL, (numPkgs + 1) * sizeof(*pkgURL));
memset(pkgURL + pkgx, 0, ((argc + 1) * sizeof(*pkgURL)));
- pkgState = (pkgState == NULL)
- ? xmalloc( (numPkgs + 1) * sizeof(*pkgState))
- : xrealloc(pkgState, (numPkgs + 1) * sizeof(*pkgState));
+ if (pkgState == NULL)
+ pkgState = xmalloc( (numPkgs + 1) * sizeof(*pkgState));
+ else
+ pkgState = xrealloc(pkgState, (numPkgs + 1) * sizeof(*pkgState));
memset(pkgState + pkgx, 0, ((argc + 1) * sizeof(*pkgState)));
}
if ((rpmrc == RPMRC_OK || rpmrc == RPMRC_BADSIZE) && isSource) {
rpmMessage(RPMMESS_DEBUG, "\tadded source package [%d]\n",
numSRPMS);
- sourceURL = (sourceURL == NULL)
- ? xmalloc( (numSRPMS + 2) * sizeof(*sourceURL))
- : xrealloc(sourceURL, (numSRPMS + 2) * sizeof(*sourceURL));
+ if (sourceURL == NULL)
+ sourceURL = xmalloc((numSRPMS + 2) * sizeof(*sourceURL));
+ else
+ sourceURL = xrealloc(sourceURL,
+ (numSRPMS + 2) * sizeof(*sourceURL));
sourceURL[numSRPMS++] = *fnp;
+ sourceURL[numSRPMS] = NULL;
*fnp = NULL;
continue;
}
if (count == 0) {
headerFree(h);
continue;
- break; /* XXX out of switch */
}
/* Package is newer than those currently installed. */
}
rpmProblemSetPrint(stderr, probs);
}
- if (probs) rpmProblemSetFree(probs);
+ if (probs != NULL) rpmProblemSetFree(probs);
}
if (numSRPMS && !stopInstall) {
#endif
/**
+ * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
+ * @param this memory to free
+ * @retval NULL always
+ */
+/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
+ if (this != NULL) free((void *)this);
+ return NULL;
+}
+
+/**
* Return package signatures and header from file handle.
* @param fd file handle
* @retval signatures address of signatures pointer (or NULL)
/*@out@*/ void ** p, /*@out@*/int_32 * c)
/*@modifies *type, *p, *c @*/;
-/* we pass these around as an array with a sentinel */
+/**
+ * We pass these around as an array with a sentinel.
+ */
typedef struct rpmRelocation_s {
- const char * oldPath; /*!< NULL here evals to RPMTAG_DEFAULTPREFIX, */
- const char * newPath; /*!< NULL means to omit the file completely! */
+/*@only@*/ /*@null@*/ const char * oldPath;
+ /*!< NULL here evals to RPMTAG_DEFAULTPREFIX, */
+/*@only@*/ /*@null@*/ const char * newPath;
+ /*!< NULL means to omit the file completely! */
} rpmRelocation;
/**
/*@out@*/ const char ** specFile,
rpmCallbackFunction notify, rpmCallbackData notifyData,
/*@out@*/ char ** cookie)
- /*@modifies *specFile, *cookie @*/;
+ /*@modifies fd, *specFile, *cookie @*/;
/**
* Compare headers to determine which header is "newer".
int qva_sourceCount;/*!< Exclusive check (>1 is error). */
int qva_flags; /*!< Bit(s) to control operation. */
int qva_verbose; /*!< (unused) */
- const char *qva_queryFormat;/*!< Format for headerSprintf(). */
- const char *qva_prefix; /*!< Path to top of install tree. */
+/*@only@*/ const char *qva_queryFormat;/*!< Format for headerSprintf(). */
+/*@dependent@*/ const char *qva_prefix; /*!< Path to top of install tree. */
char qva_mode; /*!< 'q' is query, 'v' is verify mode. */
char qva_char; /*!< (unused) always ' ' */
} QVA_t;
int i;
struct machCacheEntry * entry = NULL;
- while (*name && isspace(*name)) name++;
+ while (*name && xisspace(*name)) name++;
chptr = name;
while (*chptr && *chptr != ':') chptr++;
return 1;
}
- while (*chptr == ':' || isspace(*chptr)) chptr--;
+ while (*chptr == ':' || xisspace(*chptr)) chptr--;
*(++chptr) = '\0';
equivs = chptr + 1;
- while (*equivs && isspace(*equivs)) equivs++;
+ while (*equivs && xisspace(*equivs)) equivs++;
if (!*equivs) {
delEntry = 1;
}
entry = machCacheFindEntry(cache, name);
if (entry) {
for (i = 0; i < entry->count; i++)
- free((void *)entry->equivs[i]);
- free((void *)entry->equivs);
- entry->equivs = NULL;
+ entry->equivs[i] = _free(entry->equivs[i]);
+ entry->equivs = _free(entry->equivs);
entry->count = 0;
}
}
cache->cache[i].visited = 0;
while (table->count > 0) {
- free((void *)table->list[--table->count].name);
- table->list[table->count].name = NULL;
+ --table->count;
+ table->list[table->count].name = _free(table->list[table->count].name);
}
table->count = 0;
- if (table->list) free((void *)table->list);
- table->list = NULL;
+ table->list = _free(table->list);
/*
* We have a general graph built using strings instead of pointers.
{ const char *cpu = rpmExpand("%{_target_cpu}", NULL);
const char *os = rpmExpand("%{_target_os}", NULL);
rpmSetMachine(cpu, os);
- free((void *)cpu);
- free((void *)os);
+ cpu = _free(cpu);
+ os = _free(os);
}
return 0;
strcat(fn, subdir);
rpmSetVar(var, fn);
- if (topdir) free((void *)topdir);
+ topdir = _free(topdir);
}
if (macroname != NULL) {
}
if (rc) break;
}
- if (myrcfiles) free(myrcfiles);
+ myrcfiles = _free(myrcfiles);
if (rc)
return rc;
rpmSetMachine(NULL, NULL); /* XXX WTFO? Why bother? */
- { const char *macrofiles;
- if ((macrofiles = rpmGetVar(RPMVAR_MACROFILES)) != NULL) {
- macrofiles = strdup(macrofiles);
- rpmInitMacros(NULL, macrofiles);
- free((void *)macrofiles);
+ { const char *mfpath;
+ if ((mfpath = rpmGetVar(RPMVAR_MACROFILES)) != NULL) {
+ mfpath = xstrdup(mfpath);
+ rpmInitMacros(NULL, mfpath);
+ mfpath = _free(mfpath);
}
}
next[nb + 1] = '\0';
}
- while (*next) {
+ while (*next != '\0') {
linenum++;
s = se = next;
/* Find end-of-line. */
while (*se && *se != '\n') se++;
- if (*se) *se++ = '\0';
+ if (*se != '\0') *se++ = '\0';
next = se;
/* Trim leading spaces */
- while (*s && isspace(*s)) s++;
+ while (*s && xisspace(*s)) s++;
/* We used to allow comments to begin anywhere, but not anymore. */
if (*s == '#' || *s == '\0') continue;
/* Find end-of-keyword. */
se = (char *)s;
- while (*se && !isspace(*se) && *se != ':') se++;
+ while (*se && !xisspace(*se) && *se != ':') se++;
- if (isspace(*se)) {
+ if (xisspace(*se)) {
*se++ = '\0';
- while (*se && isspace(*se) && *se != ':') se++;
+ while (*se && xisspace(*se) && *se != ':') se++;
}
if (*se != ':') {
rpmError(RPMERR_RPMRC, _("missing ':' (found 0x%02x) at %s:%d\n"),
- (0xff & *se), urlfn, linenum);
+ (unsigned)(0xff & *se), urlfn, linenum);
return 1;
}
*se++ = '\0'; /* terminate keyword or option, point to value */
- while (*se && isspace(*se)) se++;
+ while (*se && xisspace(*se)) se++;
/* Find keyword in table */
searchOption.name = s;
{ FD_t fdinc;
s = se;
- while (*se && !isspace(*se)) se++;
- if (*se) *se++ = '\0';
+ while (*se && !xisspace(*se)) se++;
+ if (*se != '\0') *se++ = '\0';
rpmRebuildTargetVars(NULL, NULL);
if (fn == NULL || *fn == '\0') {
rpmError(RPMERR_RPMRC, _("%s expansion failed at %s:%d \"%s\"\n"),
option->name, urlfn, linenum, s);
- if (fn) free((void *)fn);
+ fn = _free(fn);
return 1;
/*@notreached@*/
}
} else {
rc = doReadRC(fdinc, fn);
}
- if (fn) free((void *)fn);
+ fn = _free(fn);
if (rc) return rc;
continue; /* XXX don't save include value as var/macro */
} /*@notreached@*/ break;
if (fn == NULL || *fn == '\0') {
rpmError(RPMERR_RPMRC, _("%s expansion failed at %s:%d \"%s\"\n"),
option->name, urlfn, linenum, fn);
- if (fn) free((void *)fn);
+ fn = _free(fn);
return 1;
}
se = (char *)fn;
s = rpmGetVar(RPMVAR_PROVIDES);
if (s == NULL) s = "";
fn = t = xmalloc(strlen(s) + strlen(se) + 2);
- while (*s) *t++ = *s++;
+ while (*s != '\0') *t++ = *s++;
*t++ = ' ';
- while (*se) *t++ = *se++;
+ while (*se != '\0') *t++ = *se++;
*t++ = '\0';
se = (char *)fn;
} break;
if (option->archSpecific) {
arch = se;
- while (*se && !isspace(*se)) se++;
+ while (*se && !xisspace(*se)) se++;
if (*se == '\0') {
rpmError(RPMERR_RPMRC,
_("missing architecture for %s at %s:%d\n"),
return 1;
}
*se++ = '\0';
- while (*se && isspace(*se)) se++;
+ while (*se && xisspace(*se)) se++;
if (*se == '\0') {
rpmError(RPMERR_RPMRC,
_("missing argument for %s at %s:%d\n"),
free(name);
}
rpmSetVarArch(option->var, val, arch);
- if (fn) free((void *)fn);
+ fn = _free(fn);
} else { /* For arch/os compatibilty tables ... */
int gotit;
for (fd = 0;
(un.release[fd] != 0 && (fd < sizeof(un.release)));
fd++) {
- if (!isdigit(un.release[fd]) && (un.release[fd] != '.')) {
+ if (!xisdigit(un.release[fd]) && (un.release[fd] != '.')) {
un.release[fd] = 0;
break;
}
#endif /* __linux__ */
/* get rid of the hyphens in the sysname */
- for (chptr = un.machine; *chptr; chptr++)
+ for (chptr = un.machine; *chptr != '\0'; chptr++)
if (*chptr == '/') *chptr = '-';
# if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
while (var) {
next = var->next;
- if (var->arch) {
- free((void *)var->arch);
- var->arch = NULL;
- }
- if (var->value) {
- free((void *)var->value);
- var->value = NULL;
- }
+ var->arch = _free(var->arch);
+ var->value = _free(var->value);
- if (var != orig) free(var);
+ if (var != orig) var = _free(var);
var = next;
}
}
}
if (next->arch && arch && !strcmp(next->arch, arch)) {
- if (next->value) free((void *)next->value);
- if (next->arch) free((void *)next->arch);
+ next->value = _free(next->value);
+ next->arch = _free(next->arch);
} else if (next->arch || arch) {
next->next = xmalloc(sizeof(*next->next));
next = next->next;
}
if (!current[ARCH] || strcmp(arch, current[ARCH])) {
- if (current[ARCH]) free((void *)current[ARCH]);
+ current[ARCH] = _free(current[ARCH]);
current[ARCH] = xstrdup(arch);
rebuildCompatTables(ARCH, host_cpu);
}
if (!current[OS] || strcmp(os, current[OS])) {
char * t = xstrdup(os);
- if (current[OS]) free((void *)current[OS]);
+ current[OS] = _free(current[OS]);
/*
* XXX Capitalizing the 'L' is needed to insure that old
* XXX os-from-uname (e.g. "Linux") is compatible with the new
defaultMachine(&a, NULL);
ca = (a) ? xstrdup(a) : NULL;
}
- for (x = 0; ca[x]; x++)
- ca[x] = tolower(ca[x]);
+ for (x = 0; ca[x] != '\0'; x++)
+ ca[x] = xtolower(ca[x]);
if (co == NULL) {
const char *o = NULL;
defaultMachine(NULL, &o);
co = (o) ? xstrdup(o) : NULL;
}
- for (x = 0; co[x]; x++)
- co[x] = tolower(co[x]);
+ for (x = 0; co[x] != '\0'; x++)
+ co[x] = xtolower(co[x]);
/* XXX For now, set canonical target to arch-os */
if (ct == NULL) {
if (canontarget)
*canontarget = ct;
else
- free(ct);
- free(ca);
- free(co);
+ ct = _free(ct);
+ ca = _free(ca);
+ co = _free(co);
}
void rpmFreeRpmrc(void)
struct tableType *t;
t = tables + i;
if (t->equiv.list) {
- for (j = 0; j < t->equiv.count; j++) {
- if (t->equiv.list[j].name) free((void *)t->equiv.list[j].name);
- }
- free((void *)t->equiv.list);
- t->equiv.list = NULL;
+ for (j = 0; j < t->equiv.count; j++)
+ t->equiv.list[j].name = _free(t->equiv.list[j].name);
+ t->equiv.list = _free(t->equiv.list);
t->equiv.count = 0;
}
if (t->cache.cache) {
struct machCacheEntry *e;
e = t->cache.cache + j;
if (e == NULL) continue;
- if (e->name) free((void *)e->name);
+ e->name = _free(e->name);
if (e->equivs) {
- for (k = 0; k < e->count; k++) {
- if (e->equivs[k]) free((void *)e->equivs[k]);
- }
- free((void *)e->equivs);
+ for (k = 0; k < e->count; k++)
+ e->equivs[k] = _free(e->equivs[k]);
+ e->equivs = _free(e->equivs);
}
}
- free((void *)t->cache.cache);
- t->cache.cache = NULL;
+ t->cache.cache = _free(t->cache.cache);
t->cache.size = 0;
}
if (t->defaults) {
for (j = 0; j < t->defaultsLength; j++) {
- if (t->defaults[j].name) free((void *)t->defaults[j].name);
- if (t->defaults[j].defName) free((void *)t->defaults[j].defName);
+ t->defaults[j].name = _free(t->defaults[j].name);
+ t->defaults[j].defName = _free(t->defaults[j].defName);
}
- free((void *)t->defaults);
- t->defaults = NULL;
+ t->defaults = _free(t->defaults);
t->defaultsLength = 0;
}
if (t->canons) {
for (j = 0; j < t->canonsLength; j++) {
- if (t->canons[j].name) free((void *)t->canons[j].name);
- if (t->canons[j].short_name) free((void *)t->canons[j].short_name);
+ t->canons[j].name = _free(t->canons[j].name);
+ t->canons[j].short_name = _free(t->canons[j].short_name);
}
- free((void *)t->canons);
- t->canons = NULL;
+ t->canons = _free(t->canons);
t->canonsLength = 0;
}
}
struct rpmvarValue *this;
while ((this = values[i].next) != NULL) {
values[i].next = this->next;
- if (this->value) free((void *)this->value);
- if (this->arch) free((void *)this->arch);
- free((void *)this);
+ this->value = _free(this->value);
+ this->arch = _free(this->arch);
+ this = _free(this);
}
- if (values[i].value)
- free((void *)values[i].value);
- values[i].value = NULL;
- if (values[i].arch)
- free((void *)values[i].arch);
- values[i].arch = NULL;
+ values[i].value = _free(values[i].value);
+ values[i].arch = _free(values[i].arch);
}
- if (current[OS])
- free((void *)current[OS]);
- current[OS] = NULL;
- if (current[ARCH])
- free((void *)current[ARCH]);
- current[ARCH] = NULL;
+ current[OS] = _free(current[OS]);
+ current[ARCH] = _free(current[ARCH]);
defaultsInitialized = 0;
return;
}
rc = RPMSIGTAG_GPG;
else
rc = -1; /* Invalid %_signature spec in macro file */
- free((void *)name);
+ name = _free(name);
} break;
}
return rc;
struct stat st;
if (!(pgpbin && pgpbin[0] != '%')) {
- if (pgpbin) free((void *)pgpbin);
+ pgpbin = _free(pgpbin);
saved_pgp_version = -1;
return NULL;
}
rpmMessage((rc == RPMRC_OK ? RPMMESS_DEBUG : RPMMESS_WARNING),
_("Expected size: %12d = lead(%d)+sigs(%d)+pad(%d)+data(%d)\n"),
- sizeof(struct rpmlead)+siglen+pad+datalen,
- sizeof(struct rpmlead), siglen, pad, datalen);
+ (int)sizeof(struct rpmlead)+siglen+pad+datalen,
+ (int)sizeof(struct rpmlead), siglen, pad, datalen);
rpmMessage((rc == RPMRC_OK ? RPMMESS_DEBUG : RPMMESS_WARNING),
- _(" Actual size: %12d\n"), st.st_size);
+ _(" Actual size: %12d\n"), (int)st.st_size);
return rc;
}
/* Write out the signature */
{ const char *tmppath = rpmGetPath("%{_tmppath}", NULL);
sigfile = tempnam(tmppath, "rpmsig");
- free((void *)tmppath);
+ tmppath = _free(tmppath);
}
sfd = Fopen(sigfile, "w.fdio");
(void)Fwrite(sig, sizeof(char), count, sfd);
/* Write out the signature */
{ const char *tmppath = rpmGetPath("%{_tmppath}", NULL);
sigfile = tempnam(tmppath, "rpmsig");
- free((void *)tmppath);
+ tmppath = _free(tmppath);
}
sfd = Fopen(sigfile, "w.fdio");
(void)Fwrite(sig, sizeof(char), count, sfd);
case RPMSIGTAG_GPG:
{ const char *name = rpmExpand("%{_gpg_name}", NULL);
aok = (name && *name != '%');
- free((void *)name);
+ name = _free(name);
}
if (!aok) {
rpmError(RPMERR_SIGGEN,
case RPMSIGTAG_PGP:
{ const char *name = rpmExpand("%{_pgp_name}", NULL);
aok = (name && *name != '%');
- free((void *)name);
+ name = _free(name);
}
if (!aok) {
rpmError(RPMERR_SIGGEN,
#define BUF_CHUNK 1024
+/**
+ * Locale insensitive isspace(3).
+ */
+/*@unused@*/ static inline int xisspace(int c) {
+ return (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v');
+}
+
struct StringBufRec {
/*@owned@*/ char *buf;
/*@dependent@*/ char *tail; /* Points to first "free" char */
void stripTrailingBlanksStringBuf(StringBuf sb)
{
while (sb->free != sb->allocated) {
- if (! isspace(*(sb->tail - 1))) {
+ if (! xisspace(*(sb->tail - 1))) {
break;
}
sb->free++;
if (tag != rpmTagTable[i].val)
continue;
strcpy(nameBuf, rpmTagTable[i].name + 7);
- for (s = nameBuf+1; *s; s++)
- *s = tolower(*s);
+ for (s = nameBuf+1; *s != '\0'; s++)
+ *s = xtolower(*s);
break;
}
return nameBuf;
#define XSTRCMP(a, b) ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b))))
-
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
-
static void freeFl(rpmTransactionSet ts, TFI_t flList)
{
TFI_t fi;
*/
if (fi->flangs && languages && *fi->flangs[i]) {
const char **lang, *l, *le;
- for (lang = languages; *lang; lang++) {
+ for (lang = languages; *lang != '\0'; lang++) {
if (!strcmp(*lang, "all"))
break;
- for (l = fi->flangs[i]; *l; l = le) {
- for (le = l; *le && *le != '|'; le++)
+ for (l = fi->flangs[i]; *l != '\0'; l = le) {
+ for (le = l; *le != '\0' && *le != '|'; le++)
;
if ((le-l) > 0 && !strncmp(*lang, l, (le-l)))
break;
if (*le == '|') le++; /* skip over | */
}
- if (*l) break;
+ if (*l != '\0') break;
}
if (*lang == NULL) {
drc[ix]--; dff[ix] = 1;
#include "misc.h"
#include "debug.h"
-/*@ access TFI_t */
-/*@ access PSM_t */
+/*@access TFI_t*/
+/*@access PSM_t*/
+/*@access FD_t*/ /* XXX compared with NULL */
+/*@access rpmdb*/ /* XXX compared with NULL */
static int _ie = 0x44332211;
static union _vendian { int i; char b[4]; } *_endian = (union _vendian *)&_ie;
POPT_TABLEEND
};
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param this memory to free
- * @retval NULL always
- */
-static /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
- if (this) free((void *)this);
- return NULL;
-}
-
/* ======================================================================== */
int rpmVerifyFile(const char * prefix, Header h, int filenum,
int * result, int omitMask)
PSM_t psm = &psmbuf;
int rc;
- if (scriptFd)
+ if (scriptFd != NULL)
ts->scriptFd = fdLink(scriptFd, "rpmVerifyScript");
fi->magic = TFIMAGIC;
loadFi(h, fi);
rc = rpmQueryVerify(qva, source, arg, rpmdb, showVerifyPackage);
- if (rpmdb)
+ if (rpmdb != NULL)
rpmdbClose(rpmdb);
return rc;
* @param flags or'd POPT_CONTEXT_* bits
* @return initialized popt context
*/
-/*@only@*/ poptContext poptGetContext(/*@keep@*/ const char * name,
- int argc, /*@keep@*/ const char ** argv,
- /*@keep@*/ const struct poptOption * options, int flags);
+/*@only@*/ poptContext poptGetContext(
+ /*@dependent@*/ /*@keep@*/ const char * name,
+ int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
+ /*@dependent@*/ /*@keep@*/ const struct poptOption * options,
+ int flags);
/** \ingroup popt
* Reinitialize popt context.
-unrecogcomments
# don't-bother-me-yet parameters
--branchstate
+-branchstate # ~43 occurences
#-immediatetrans
--mustfree
+-mustfree # alloca is painful
#-observertrans
#-statictrans
# not-yet normal parameters
-boolops # w->n
--fixedformalarray
--null
--predboolint # w->n
--predboolothers # w->n
--retvalint # w->n
--type
+#-fixedformalarray
+-null # ugh
+-predboolint # w->n ~144
+#-predboolothers # w->n ~8
+-retvalint # w->n ~48
+-type # ~449
# not-yet -weak paramaters
#+boolint
typedef unsigned int uint32;
typedef unsigned char byte;
+/*@access DIGEST_CTX@*/
+
/**
* MD5/SHA1 digest private data.
*/
#define COPYNAME(_ne, _s, _c) \
{ SKIPBLANK(_s,_c); \
- while(((_c) = *(_s)) && (isalnum(_c) || (_c) == '_')) \
+ while(((_c) = *(_s)) && (xisalnum(_c) || (_c) == '_')) \
*(_ne)++ = *(_s)++; \
*(_ne) = '\0'; \
}
se = s;
/* Names must start with alphabetic or _ and be at least 3 chars */
- if (!((c = *n) && (isalpha(c) || c == '_') && (ne - n) > 2)) {
+ if (!((c = *n) && (xisalpha(c) || c == '_') && (ne - n) > 2)) {
rpmError(RPMERR_BADSPEC,
_("Macro %%%s has illegal name (%%define)\n"), n);
return se;
se = s;
/* Names must start with alphabetic or _ and be at least 3 chars */
- if (!((c = *n) && (isalpha(c) || c == '_') && (ne - n) > 2)) {
+ if (!((c = *n) && (xisalpha(c) || c == '_') && (ne - n) > 2)) {
rpmError(RPMERR_BADSPEC,
_("Macro %%%s has illegal name (%%undefine)\n"), n);
return se;
}
b = be;
} else if (STREQ("S", f, fn)) {
- for (b = buf; (c = *b) && isdigit(c);)
+ for (b = buf; (c = *b) && xisdigit(c);)
b++;
if (!c) { /* digit index */
b++;
} else
b = buf;
} else if (STREQ("P", f, fn)) {
- for (b = buf; (c = *b) && isdigit(c);)
+ for (b = buf; (c = *b) && xisdigit(c);)
b++;
if (!c) { /* digit index */
b++;
f = se = s;
if (*se == '-')
se++;
- while((c = *se) && (isalnum(c) || c == '_'))
+ while((c = *se) && (xisalnum(c) || c == '_'))
se++;
/* Recognize non-alnum macros too */
switch (*se) {
/* Setup args for "%name " macros with opts */
if (me && me->opts != NULL) {
- if (grab) {
+ if (grab != '\0') {
se = grabArgs(mb, me, fe, grab);
} else {
addMacro(mb->mc, "**", NULL, "", mb->depth);
if (mc == NULL)
mc = &rpmGlobalMacroContext;
- for (mfile = m = xstrdup(macrofiles); *mfile; mfile = me) {
+ for (mfile = m = xstrdup(macrofiles); *mfile != '\0'; mfile = me) {
FD_t fd;
char buf[BUFSIZ];
/*fprintf(stderr, "*** RCP %s ->\n", path); */
s = t = te = path;
- while (*s) {
+ while (*s != '\0') {
/*fprintf(stderr, "*** got \"%.*s\"\trest \"%s\"\n", (t-path), path, s); */
switch(*s) {
case ':': /* handle url's */
int _ftp_debug = 0;
int _rpmio_debug = 0;
+/**
+ * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
+ * @param this memory to free
+ * @retval NULL always
+ */
+/*@unused@*/ static inline /*@null@*/ void * _free(/*@only@*/ /*@null@*/ const void * this) {
+ if (this != NULL) free((void *)this);
+ return NULL;
+}
+
/* =============================================================== */
static /*@observer@*/ const char * fdbg(FD_t fd)
DBGREFS(fd, (stderr, "--> fd %p -- %d %s at %s:%u %s\n", fd, fd->nrefs, msg, file, line, fdbg(fd)));
if (--fd->nrefs > 0)
/*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/
- if (fd->stats) free(fd->stats);
- if (fd->digest) free(fd->digest);
+ fd->stats = _free(fd->stats);
+ fd->digest = _free(fd->digest);
/*@-refcounttrans@*/ free(fd); /*@=refcounttrans@*/
}
return NULL;
static int getHostAddress(const char * host, struct in_addr * address)
{
- if (isdigit(host[0])) {
+ if (xisdigit(host[0])) {
if (! /*@-unrecog@*/ inet_aton(host, address) /*@=unrecog@*/ ) {
return FTPERR_BAD_HOST_ADDR;
}
/* FTP: look for "123-" and/or "123 " */
if (strchr("0123456789", *s)) {
- if (errorCode[0]) {
+ if (errorCode[0] != '\0') {
if (!strncmp(s, errorCode, sizeof("123")-1) && s[3] == ' ')
moretodo = 0;
} else {
}
chptr = passReply;
- while (*chptr++) {
+ while (*chptr++ != '\0') {
if (*chptr == ',') *chptr = '.';
}
}
*stdio = *other = '\0';
- if (end)
- *end = (*m ? m : NULL);
- if (f)
+ if (end != NULL)
+ *end = (*m != '\0' ? m : NULL);
+ if (f != NULL)
*f = flags;
}
fdPush(fd, fpio, fp, fdno); /* Push fpio onto stack */
}
}
- } else if (other[0]) {
+ } else if (other[0] != '\0') {
for (end = other; *end && strchr("0123456789fh", *end); end++)
;
if (*end == '\0') {
/*@observer@*/ extern FDIO_t fadio;
/*@}*/
+/*@unused@*/ static inline int xislower(int c) {return (c >= 'a' && c <= 'z');}
+/*@unused@*/ static inline int xisupper(int c) {return (c >= 'A' && c <= 'Z');}
+/*@unused@*/ static inline int xisalpha(int c) {
+ return (xislower(c) || xisupper(c));
+}
+/*@unused@*/ static inline int xisdigit(int c) {return (c >= '0' && c <= '9');}
+/*@unused@*/ static inline int xisalnum(int c) {
+ return (xisalpha(c) || xisdigit(c));
+}
+/*@unused@*/ static inline int xisblank(int c) {return (c == ' ' || c == '\t');}
+/*@unused@*/ static inline int xisspace(int c) {
+ return (xisblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
+}
+
+/*@unused@*/ static inline int xtolower(int c) {
+ return ((xisupper(c)) ? (c | ('a' - 'A')) : c);
+}
+/*@unused@*/ static inline int xtoupper(int c) {
+ return ((xislower(c)) ? (c & ~('a' - 'A')) : c);
+}
+
/** \ingroup rpmio
* Locale insensitive strcasecmp(3).
*/
int mask = RPMLOG_MASK(pri);
/*@unused@*/ int fac = RPMLOG_FAC(code);
char *msgbuf, *msg;
+ int freeMsgbuf = 1;
int msgnb = BUFSIZ, nb;
FILE * msgout = stderr;
rpmlogRec rec;
/* Allocate a sufficently large buffer for output. */
while (1) {
va_list apc;
- __va_copy(apc, ap);
- /*@-unrecog@*/
- nb = vsnprintf(msgbuf, msgnb, fmt, apc);
- /*@=unrecog@*/
+ /*@-sysunrecog@*/ __va_copy(apc, ap); /*@=sysunrecog@*/
+ /*@-unrecog@*/ nb = vsnprintf(msgbuf, msgnb, fmt, apc); /*@=unrecog@*/
if (nb > -1 && nb < msgnb)
break;
if (nb > -1) /* glibc 2.1 */
rec->code = code;
rec->message = msgbuf;
- msgbuf = NULL;
+ freeMsgbuf = 0;
if (_rpmlogCallback) {
_rpmlogCallback();
- if (msgbuf)
- free(msgbuf);
return; /* XXX Preserve legacy rpmError behavior. */
}
}
break;
}
- /* Silly FORTRAN-like carriage control. */
- if (*msg == '+')
- msg++;
- else if (rpmlogMsgPrefix[pri] && *rpmlogMsgPrefix[pri])
+ if (rpmlogMsgPrefix[pri] && *rpmlogMsgPrefix[pri])
fputs(_(rpmlogMsgPrefix[pri]), msgout);
fputs(msg, msgout);
fflush(msgout);
- if (msgbuf)
+ if (freeMsgbuf)
free(msgbuf);
if (pri <= RPMLOG_CRIT)
exit(EXIT_FAILURE);
/**
* Generate a log message using FMT string and option arguments.
*/
-void rpmlog (int pri, const char *fmt, ...);
+/*@mayexit@*/ /*@printflike@*/ void rpmlog (int pri, const char *fmt, ...);
/**
* Set rpmlog callback function.
#include "rpmio.h"
#include "debug.h"
-static inline unsigned char xtolower(unsigned char c)
+int xstrcasecmp(const char * s1, const char * s2)
{
- return ((c >= 'A' && c <= 'Z') ? (c | 0x20) : c);
-}
-
-int xstrcasecmp(const char *s1, const char *s2)
-{
- const unsigned char *p1 = (const unsigned char *) s1;
- const unsigned char *p2 = (const unsigned char *) s2;
- unsigned char c1, c2;
+ const char * p1 = s1;
+ const char * p2 = s2;
+ char c1, c2;
if (p1 == p2)
return 0;
}
while (c1 == c2);
- return c1 - c2;
+ return (int)(c1 - c2);
}
int xstrncasecmp(const char *s1, const char *s2, size_t n)
{
- const unsigned char *p1 = (const unsigned char *) s1;
- const unsigned char *p2 = (const unsigned char *) s2;
- unsigned char c1, c2;
+ const char * p1 = s1;
+ const char * p2 = s2;
+ char c1, c2;
if (p1 == p2 || n == 0)
return 0;
c1 = xtolower (*p1++);
c2 = xtolower (*p2++);
if (c1 == '\0' || c1 != c2)
- return c1 - c2;
+ break;
} while (--n > 0);
- return c1 - c2;
+ return (int)(c1 - c2);
}
int unameToUid(const char * thisUname, uid_t * uid)
{
- /*@only@*/ static char * lastUname = NULL;
- static int lastUnameLen = 0;
- static int lastUnameAlloced;
+/*@only@*/ static char * lastUname = NULL;
+ static size_t lastUnameLen = 0;
+ static size_t lastUnameAlloced;
static uid_t lastUid;
struct passwd * pwent;
- int thisUnameLen;
+ size_t thisUnameLen;
if (!thisUname) {
lastUnameLen = 0;
return -1;
- } else if (!strcmp(thisUname, "root")) {
+ } else if (strcmp(thisUname, "root") == 0) {
*uid = 0;
return 0;
}
thisUnameLen = strlen(thisUname);
- if (!lastUname || thisUnameLen != lastUnameLen ||
- strcmp(thisUname, lastUname)) {
+ if (lastUname == NULL || thisUnameLen != lastUnameLen ||
+ strcmp(thisUname, lastUname) != 0) {
if (lastUnameAlloced < thisUnameLen + 1) {
lastUnameAlloced = thisUnameLen + 10;
lastUname = xrealloc(lastUname, lastUnameAlloced); /* XXX memory leak */
strcpy(lastUname, thisUname);
pwent = getpwnam(thisUname);
- if (!pwent) {
+ if (pwent == NULL) {
endpwent();
pwent = getpwnam(thisUname);
- if (!pwent) return -1;
+ if (pwent == NULL) return -1;
}
lastUid = pwent->pw_uid;
int gnameToGid(const char * thisGname, gid_t * gid)
{
- /*@only@*/ static char * lastGname = NULL;
- static int lastGnameLen = 0;
- static int lastGnameAlloced;
- static uid_t lastGid;
- int thisGnameLen;
+/*@only@*/ static char * lastGname = NULL;
+ static size_t lastGnameLen = 0;
+ static size_t lastGnameAlloced;
+ static gid_t lastGid;
+ size_t thisGnameLen;
struct group * grent;
- if (!thisGname) {
+ if (thisGname == NULL) {
lastGnameLen = 0;
return -1;
- } else if (!strcmp(thisGname, "root")) {
+ } else if (strcmp(thisGname, "root") == 0) {
*gid = 0;
return 0;
}
thisGnameLen = strlen(thisGname);
- if (!lastGname || thisGnameLen != lastGnameLen ||
- strcmp(thisGname, lastGname)) {
+ if (lastGname == NULL || thisGnameLen != lastGnameLen ||
+ strcmp(thisGname, lastGname) != 0)
+ {
if (lastGnameAlloced < thisGnameLen + 1) {
lastGnameAlloced = thisGnameLen + 10;
lastGname = xrealloc(lastGname, lastGnameAlloced); /* XXX memory leak */
strcpy(lastGname, thisGname);
grent = getgrnam(thisGname);
- if (!grent) {
+ if (grent == NULL) {
endgrent();
grent = getgrnam(thisGname);
- if (!grent) return -1;
+ if (grent == NULL) return -1;
}
lastGid = grent->gr_gid;
}
char * uidToUname(uid_t uid)
{
- static int lastUid = -1;
- /*@only@*/ static char * lastUname = NULL;
- static int lastUnameLen = 0;
- struct passwd * pwent;
- int len;
+ static uid_t lastUid = (uid_t) -1;
+/*@only@*/ static char * lastUname = NULL;
+ static size_t lastUnameLen = 0;
if (uid == (uid_t) -1) {
- lastUid = -1;
+ lastUid = (uid_t) -1;
return NULL;
- } else if (!uid) {
+ } else if (uid == (uid_t) 0) {
return "root";
} else if (uid == lastUid) {
return lastUname;
} else {
- pwent = getpwuid(uid);
- if (!pwent) return NULL;
+ struct passwd * pwent = getpwuid(uid);
+ size_t len;
+
+ if (pwent == NULL) return NULL;
lastUid = uid;
len = strlen(pwent->pw_name);
char * gidToGname(gid_t gid)
{
- static int lastGid = -1;
- /*@only@*/ static char * lastGname = NULL;
- static int lastGnameLen = 0;
- struct group * grent;
- int len;
+ static gid_t lastGid = (gid_t) -1;
+/*@only@*/ static char * lastGname = NULL;
+ static size_t lastGnameLen = 0;
if (gid == (gid_t) -1) {
- lastGid = -1;
+ lastGid = (gid_t) -1;
return NULL;
- } else if (!gid) {
+ } else if (gid == (gid_t) 0) {
return "root";
} else if (gid == lastGid) {
return lastGname;
} else {
- grent = getgrgid(gid);
- if (!grent) return NULL;
+ struct group * grent = getgrgid(gid);
+ size_t len;
+
+ if (grent == NULL) return NULL;
lastGid = gid;
len = strlen(grent->gr_name);
#define _AUTOHELP
-#if defined(IAM_RPM)
+#if defined(IAM_RPM) || defined(__LCLINT__)
#define IAM_RPMBT
#define IAM_RPMDB
#define IAM_RPMEIU
long _stksize = 64 * 1024L;
#endif
-static void argerror(const char * desc) {
+/*@exits@*/ static void argerror(const char * desc)
+{
fprintf(stderr, _("rpm: %s\n"), desc);
exit(EXIT_FAILURE);
}
#endif
#ifdef IAM_RPMEIU
- rpmRelocation * relocations = NULL;
+/*@only@*/ rpmRelocation * relocations = NULL;
int numRelocations = 0;
#endif
freeSpecVec = freeSpec;
/* set up the correct locale */
- setlocale(LC_ALL, "" );
+ (void) setlocale(LC_ALL, "" );
#ifdef __LCLINT__
#define LOCALEDIR "/usr/share/locale"
if (signIt) {
if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD) {
- const char ** argv;
+ const char ** av;
struct stat sb;
int errors = 0;
- if ((argv = poptGetArgs(optCon)) == NULL) {
+ if ((av = poptGetArgs(optCon)) == NULL) {
fprintf(stderr, _("no files to sign\n"));
errors++;
} else
- while (*argv) {
- if (stat(*argv, &sb)) {
- fprintf(stderr, _("cannot access file %s\n"), *argv);
+ while (*av) {
+ if (stat(*av, &sb)) {
+ fprintf(stderr, _("cannot access file %s\n"), *av);
errors++;
}
- argv++;
+ av++;
}
- if (errors) return errors;
+ if (errors) {
+ ec = errors;
+ goto exit;
+ }
if (poptPeekArg(optCon)) {
int sigTag;
if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
!rpmDetectPGPVersion(NULL)) {
fprintf(stderr, _("pgp not found: "));
- exit(EXIT_FAILURE);
+ ec = EXIT_FAILURE;
+ goto exit;
} /*@fallthrough@*/
case RPMSIGTAG_GPG:
passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
if (passPhrase == NULL) {
fprintf(stderr, _("Pass phrase check failed\n"));
- exit(EXIT_FAILURE);
+ ec = EXIT_FAILURE;
+ goto exit;
}
fprintf(stderr, _("Pass phrase is good.\n"));
passPhrase = xstrdup(passPhrase);
default:
fprintf(stderr,
_("Invalid %%_signature spec in macro file.\n"));
- exit(EXIT_FAILURE);
+ ec = EXIT_FAILURE;
+ goto exit;
/*@notreached@*/ break;
}
}
case MODE_REBUILDDB:
ec = rpmdbRebuild(rootdir);
break;
+#if !defined(__LCLINT__)
case MODE_QUERY:
case MODE_VERIFY:
case MODE_QUERYTAGS:
case MODE_RESIGN:
if (!showVersion && !help && !noUsageMsg) printUsage();
break;
+#endif
#endif /* IAM_RPMDB */
#ifdef IAM_RPMBT
}
} break;
+#if !defined(__LCLINT__)
case MODE_QUERY:
case MODE_VERIFY:
case MODE_QUERYTAGS:
case MODE_REBUILDDB:
if (!showVersion && !help && !noUsageMsg) printUsage();
break;
+#endif
#endif /* IAM_RPMBT */
#ifdef IAM_RPMEIU
transFlags, installInterfaceFlags, probFilter,
relocations);
break;
+#if !defined(__LCLINT__)
case MODE_QUERY:
case MODE_VERIFY:
case MODE_QUERYTAGS:
case MODE_REBUILDDB:
if (!showVersion && !help && !noUsageMsg) printUsage();
break;
+#endif
#endif /* IAM_RPMEIU */
#ifdef IAM_RPMQV
rpmDisplayQueryTags(stdout);
break;
+#if !defined(__LCLINT__)
case MODE_INSTALL:
case MODE_UNINSTALL:
case MODE_BUILD:
case MODE_REBUILDDB:
if (!showVersion && !help && !noUsageMsg) printUsage();
break;
+#endif
#endif /* IAM_RPMQV */
#ifdef IAM_RPMK
/* XXX don't overflow single byte exit status */
if (ec > 255) ec = 255;
break;
+#if !defined(__LCLINT__)
case MODE_QUERY:
case MODE_VERIFY:
case MODE_QUERYTAGS:
case MODE_REBUILDDB:
if (!showVersion && !help && !noUsageMsg) printUsage();
break;
+#endif
#endif /* IAM_RPMK */
case MODE_UNKNOWN:
}
+exit:
poptFreeContext(optCon);
rpmFreeMacros(NULL);
rpmFreeMacros(&rpmCLIMacroContext);
urlFreeCache();
#ifdef IAM_RPMQV
- if (qva->qva_queryFormat) free((void *)qva->qva_queryFormat);
+ qva->qva_queryFormat = _free(qva->qva_queryFormat);
#endif
#ifdef IAM_RPMBT
- if (ba->buildRootOverride) free((void *)ba->buildRootOverride);
- if (ba->targets) free(ba->targets);
+ ba->buildRootOverride = _free(ba->buildRootOverride);
+ ba->targets = _free(ba->targets);
#endif
#if HAVE_MCHECK_H && HAVE_MTRACE
/*@only@*/ void * xmalloc (size_t size);
/*@only@*/ void * xcalloc (size_t nmemb, size_t size);
-/*@only@*/ void * xrealloc (/*@only@*/ void *ptr, size_t size);
+/*@only@*/ void * xrealloc (/*@only@*/ /*@null@*/ void * ptr, size_t size);
/*@only@*/ char * xstrdup (const char *str);
/*@only@*/ void *vmefail(size_t size);