- still more boring lclint annotations and fiddles.
CVS patchset: 4738 CVS date: 2001/05/03 21:00:18
This commit is contained in:
parent
0ecdbba935
commit
d78e027808
16
.lclintrc
16
.lclintrc
|
@ -1,6 +1,6 @@
|
|||
-I. -I./build -I./lib -I./rpmio -I./popt -DHAVE_CONFIG_H -D_GNU_SOURCE
|
||||
|
||||
+partial
|
||||
#+partial
|
||||
|
||||
-warnunixlib
|
||||
-warnposix
|
||||
|
@ -11,23 +11,15 @@
|
|||
-unrecogcomments
|
||||
|
||||
# don't-bother-me-yet parameters
|
||||
#-branchstate
|
||||
#-immediatetrans
|
||||
-branchstate # painful
|
||||
-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
|
||||
-type #
|
||||
|
||||
|
||||
# not-yet -weak paramaters
|
||||
# -weak paramaters
|
||||
#+boolint
|
||||
#-boolops
|
||||
#+ignorequals
|
||||
|
|
1
CHANGES
1
CHANGES
|
@ -40,6 +40,7 @@
|
|||
- erasures not yet strict, warn & chug on unlink(2)/rmdir(2) failure.
|
||||
- more boring lclint annotations and fiddles.
|
||||
- yet more boring lclint annotations and fiddles.
|
||||
- still more boring lclint annotations and fiddles.
|
||||
|
||||
4.0 -> 4.0.[12]
|
||||
- add doxygen and lclint annotations most everywhere.
|
||||
|
|
|
@ -87,7 +87,11 @@ $(PROGRAMS): $(myLDADD) @WITH_APIDOCS_TARGET@
|
|||
|
||||
.PHONY: lclint
|
||||
lclint:
|
||||
lclint $(DEFS) $(INCLUDES) $(rpm_SOURCES) $(rpmb_SOURCES) rpmqv.c
|
||||
lclint $(DEFS) $(INCLUDES) rpmqv.c $(rpmb_SOURCES) \
|
||||
`make -s sources -C build` \
|
||||
`make -s sources -C lib` \
|
||||
`make -s sources -C rpmio` \
|
||||
`make -s sources -C popt`
|
||||
|
||||
CVSTAG = r$(subst .,-,$(VERSION))
|
||||
|
||||
|
|
70
build.c
70
build.c
|
@ -10,11 +10,15 @@
|
|||
#include "build.h"
|
||||
#include "debug.h"
|
||||
|
||||
/*@access rpmTransactionSet @*/ /* XXX compared with NULL @*/
|
||||
/*@access rpmdb @*/ /* XXX compared with NULL @*/
|
||||
/*@access FD_t @*/ /* XXX compared with NULL @*/
|
||||
|
||||
/**
|
||||
*/
|
||||
static int checkSpec(Header h)
|
||||
{
|
||||
char *rootdir = NULL;
|
||||
const char * rootdir = NULL;
|
||||
rpmdb db = NULL;
|
||||
int mode = O_RDONLY;
|
||||
rpmTransactionSet ts;
|
||||
|
@ -29,7 +33,7 @@ static int checkSpec(Header h)
|
|||
const char *dn;
|
||||
dn = rpmGetPath( (rootdir ? rootdir : ""), "%{_dbpath}", NULL);
|
||||
rpmError(RPMERR_OPEN, _("cannot open rpm database in %s\n"), dn);
|
||||
free((void *)dn);
|
||||
dn = _free(dn);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ts = rpmtransCreateSet(db, rootdir);
|
||||
|
@ -44,10 +48,10 @@ static int checkSpec(Header h)
|
|||
rc = 1;
|
||||
}
|
||||
|
||||
if (ts)
|
||||
if (ts != NULL)
|
||||
rpmtransFree(ts);
|
||||
if (db)
|
||||
rpmdbClose(db);
|
||||
if (db != NULL)
|
||||
(void) rpmdbClose(db);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -59,7 +63,7 @@ static int checkSpec(Header h)
|
|||
/* XXX this is still a dumb test but at least it's i18n aware */
|
||||
/**
|
||||
*/
|
||||
static int isSpecFile(const char *specfile)
|
||||
static int isSpecFile(const char * specfile)
|
||||
{
|
||||
char buf[256];
|
||||
const char * s;
|
||||
|
@ -74,7 +78,7 @@ static int isSpecFile(const char *specfile)
|
|||
return 0;
|
||||
}
|
||||
count = Fread(buf, sizeof(buf[0]), sizeof(buf), fd);
|
||||
Fclose(fd);
|
||||
(void) Fclose(fd);
|
||||
|
||||
checking = 1;
|
||||
for (s = buf; count--; s++) {
|
||||
|
@ -96,8 +100,8 @@ static int isSpecFile(const char *specfile)
|
|||
|
||||
/**
|
||||
*/
|
||||
static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
|
||||
const char *passPhrase, char *cookie)
|
||||
static int buildForTarget(const char * arg, BTA_t ba,
|
||||
const char * passPhrase, char * cookie)
|
||||
{
|
||||
int buildAmount = ba->buildAmount;
|
||||
const char *buildRootURL = NULL;
|
||||
|
@ -129,46 +133,48 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
|
|||
/* XXX FWIW, default %{_specdir} is root.root 0755 */
|
||||
{ char tfn[64];
|
||||
strcpy(tfn, "rpm-spec.XXXXXX");
|
||||
/*@-unrecog@*/
|
||||
tmpSpecFile = rpmGetPath("%{_specdir}/", mktemp(tfn), NULL);
|
||||
/*@=unrecog@*/
|
||||
}
|
||||
|
||||
isCompressed(arg, &res);
|
||||
(void) isCompressed(arg, &res);
|
||||
|
||||
cmd = alloca(strlen(arg) + 50 + strlen(tmpSpecFile));
|
||||
sprintf(cmd, "%s < %s | tar xOvf - Specfile 2>&1 > %s",
|
||||
zcmds[res & 0x3], arg, tmpSpecFile);
|
||||
if (!(fp = popen(cmd, "r"))) {
|
||||
rpmError(RPMERR_POPEN, _("Failed to open tar pipe: %m\n"));
|
||||
free((void *)specDir);
|
||||
free((void *)tmpSpecFile);
|
||||
specDir = _free(specDir);
|
||||
tmpSpecFile = _free(tmpSpecFile);
|
||||
return 1;
|
||||
}
|
||||
if ((!fgets(buf, sizeof(buf) - 1, fp)) || !strchr(buf, '/')) {
|
||||
/* Try again */
|
||||
pclose(fp);
|
||||
(void) pclose(fp);
|
||||
|
||||
sprintf(cmd, "%s < %s | tar xOvf - \\*.spec 2>&1 > %s",
|
||||
zcmds[res & 0x3], arg, tmpSpecFile);
|
||||
if (!(fp = popen(cmd, "r"))) {
|
||||
rpmError(RPMERR_POPEN, _("Failed to open tar pipe: %m\n"));
|
||||
free((void *)specDir);
|
||||
free((void *)tmpSpecFile);
|
||||
specDir = _free(specDir);
|
||||
tmpSpecFile = _free(tmpSpecFile);
|
||||
return 1;
|
||||
}
|
||||
if (!fgets(buf, sizeof(buf) - 1, fp)) {
|
||||
/* Give up */
|
||||
rpmError(RPMERR_READ, _("Failed to read spec file from %s\n"),
|
||||
arg);
|
||||
unlink(tmpSpecFile);
|
||||
free((void *)specDir);
|
||||
free((void *)tmpSpecFile);
|
||||
(void) unlink(tmpSpecFile);
|
||||
specDir = _free(specDir);
|
||||
tmpSpecFile = _free(tmpSpecFile);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
pclose(fp);
|
||||
(void) pclose(fp);
|
||||
|
||||
cmd = s = buf;
|
||||
while (*cmd) {
|
||||
while (*cmd != '\0') {
|
||||
if (*cmd == '/') s = cmd + 1;
|
||||
cmd++;
|
||||
}
|
||||
|
@ -182,16 +188,16 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
|
|||
specURL = s = alloca(strlen(specDir) + strlen(cmd) + 5);
|
||||
sprintf(s, "%s/%s", specDir, cmd);
|
||||
res = rename(tmpSpecFile, s);
|
||||
free((void *)specDir);
|
||||
specDir = _free(specDir);
|
||||
|
||||
if (res) {
|
||||
rpmError(RPMERR_RENAME, _("Failed to rename %s to %s: %m\n"),
|
||||
tmpSpecFile, s);
|
||||
unlink(tmpSpecFile);
|
||||
free((void *)tmpSpecFile);
|
||||
(void) unlink(tmpSpecFile);
|
||||
tmpSpecFile = _free(tmpSpecFile);
|
||||
return 1;
|
||||
}
|
||||
free((void *)tmpSpecFile);
|
||||
tmpSpecFile = _free(tmpSpecFile);
|
||||
|
||||
/* Make the directory which contains the tarball the source
|
||||
directory for this run */
|
||||
|
@ -268,23 +274,23 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if (ba->buildMode == 't') Unlink(specURL);
|
||||
if (ba->buildMode == 't')
|
||||
(void) Unlink(specURL);
|
||||
rc = 0;
|
||||
|
||||
exit:
|
||||
if (spec)
|
||||
freeSpec(spec);
|
||||
if (buildRootURL)
|
||||
free((void *)buildRootURL);
|
||||
buildRootURL = _free(buildRootURL);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int build(const char * arg, struct rpmBuildArguments * ba,
|
||||
int build(const char * arg, BTA_t ba,
|
||||
const char * passPhrase, char * cookie, const char * rcfile)
|
||||
{
|
||||
char *t, *te;
|
||||
int rc = 0;
|
||||
char *targets = ba->targets;
|
||||
char * targets = ba->targets;
|
||||
#define buildCleanMask (RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)
|
||||
int cleanFlags = ba->buildAmount & buildCleanMask;
|
||||
|
||||
|
@ -305,7 +311,7 @@ int build(const char * arg, struct rpmBuildArguments * ba,
|
|||
target = alloca(te-t+1);
|
||||
strncpy(target, t, (te-t));
|
||||
target[te-t] = '\0';
|
||||
if (*te)
|
||||
if (*te != '\0')
|
||||
te++;
|
||||
else /* XXX Perform clean-up after last target build. */
|
||||
ba->buildAmount |= cleanFlags;
|
||||
|
@ -314,7 +320,7 @@ int build(const char * arg, struct rpmBuildArguments * ba,
|
|||
|
||||
/* Read in configuration for target. */
|
||||
rpmFreeMacros(NULL);
|
||||
rpmReadConfigFiles(rcfile, target);
|
||||
(void) rpmReadConfigFiles(rcfile, target);
|
||||
rc = buildForTarget(arg, ba, passPhrase, cookie);
|
||||
if (rc)
|
||||
break;
|
||||
|
@ -323,6 +329,6 @@ int build(const char * arg, struct rpmBuildArguments * ba,
|
|||
exit:
|
||||
/* Restore original configuration. */
|
||||
rpmFreeMacros(NULL);
|
||||
rpmReadConfigFiles(rcfile, NULL);
|
||||
(void) rpmReadConfigFiles(rcfile, NULL);
|
||||
return rc;
|
||||
}
|
||||
|
|
4
build.h
4
build.h
|
@ -5,8 +5,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
int build(const char *arg, struct rpmBuildArguments *ba, const char *passPhrase,
|
||||
char *cookie, const char * rcfile);
|
||||
int build(const char * arg, BTA_t ba, const char * passPhrase,
|
||||
char * cookie, /*@null@*/ const char * rcfile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
|
||||
# not-yet normal parameters
|
||||
-boolops # ~351 w->n
|
||||
#-null # ~68
|
||||
-predboolint # ~200 w->n
|
||||
-type # ~271
|
||||
|
||||
|
||||
# -weak paramaters
|
||||
#+boolint
|
||||
#-boolops
|
||||
|
|
|
@ -24,6 +24,9 @@ install-data-local:
|
|||
sed -e "s|^dependency_libs='|& -lrpm|" < librpmbuild.la > .librpmbuild.la && \
|
||||
mv .librpmbuild.la librpmbuild.la
|
||||
|
||||
.PHONY: sources
|
||||
sources:
|
||||
@echo $(librpmbuild_la_SOURCES:%=build/%)
|
||||
|
||||
.PHONY: lclint
|
||||
lclint:
|
||||
|
|
|
@ -19,6 +19,7 @@ static int _build_debug = 0;
|
|||
/**
|
||||
*/
|
||||
static void doRmSource(Spec spec)
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
struct Source *p;
|
||||
Package pkg;
|
||||
|
@ -253,6 +254,7 @@ int buildSpec(Spec spec, int what, int test)
|
|||
int x;
|
||||
/* When iterating over buildArchitectures, do the source */
|
||||
/* packaging on the first run, and skip RMSOURCE altogether */
|
||||
if (spec->buildArchitectureSpecs != NULL)
|
||||
for (x = 0; x < spec->buildArchitectureCount; x++) {
|
||||
if ((rc = buildSpec(spec->buildArchitectureSpecs[x],
|
||||
(what & ~RPMBUILD_RMSOURCE) |
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
|
||||
/**
|
||||
*/
|
||||
typedef struct cpioSourceArchive {
|
||||
typedef /*@abstract@*/ struct cpioSourceArchive_s {
|
||||
unsigned int cpioArchiveSize;
|
||||
FD_t cpioFdIn;
|
||||
/*@dependent@*/ TFI_t cpioList;
|
||||
struct rpmlead * lead; /* XXX FIXME: exorcize lead/arch/os */
|
||||
} CSA_t;
|
||||
/*@only@*/ struct rpmlead * lead; /* XXX FIXME: exorcize lead/arch/os */
|
||||
} * CSA_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -32,8 +32,10 @@ extern "C" {
|
|||
* @param csa
|
||||
* @return 0 on success
|
||||
*/
|
||||
int readRPM(const char *fileName, /*@out@*/ Spec *specp, /*@out@*/ struct rpmlead *lead,
|
||||
/*@out@*/ Header *sigs, CSA_t *csa);
|
||||
int readRPM(/*@null@*/ const char * fileName, /*@out@*/ Spec * specp,
|
||||
/*@out@*/ struct rpmlead * lead, /*@out@*/ Header * sigs,
|
||||
CSA_t csa)
|
||||
/*@modifies *specp, *sigs, csa, csa->cpioFdIn @*/;
|
||||
|
||||
/**
|
||||
* Write rpm package to file.
|
||||
|
@ -49,8 +51,10 @@ int readRPM(const char *fileName, /*@out@*/ Spec *specp, /*@out@*/ struct rpmlea
|
|||
* @retval cookie generated cookie (i.e build host/time)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int writeRPM(Header *hdrp, const char *fileName, int type,
|
||||
CSA_t *csa, char *passPhrase, /*@out@*/ const char **cookie);
|
||||
int writeRPM(Header * hdrp, const char * fileName, int type,
|
||||
CSA_t csa, /*@null@*/ char * passPhrase,
|
||||
/*@out@*/ const char ** cookie)
|
||||
/*@modifies *hdrp, *cookie, csa, csa->cpioArchiveSize @*/;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
117
build/files.c
117
build/files.c
|
@ -112,7 +112,7 @@ typedef struct FileList_s {
|
|||
specdFlags defSpecdFlags;
|
||||
int defVerifyFlags;
|
||||
int nLangs;
|
||||
/*@only@*/ const char ** currentLangs;
|
||||
/*@only@*/ /*@null@*/ const char ** currentLangs;
|
||||
|
||||
/* Hard coded limit of MAXDOCDIR docdirs. */
|
||||
/* If you break it you are doing something wrong. */
|
||||
|
@ -126,7 +126,7 @@ typedef struct FileList_s {
|
|||
|
||||
/**
|
||||
*/
|
||||
static void nullAttrRec(/*@out@*/ AttrRec ar)
|
||||
static void nullAttrRec(/*@out@*/ AttrRec ar) /*@modifies ar @*/
|
||||
{
|
||||
ar->ar_fmodestr = NULL;
|
||||
ar->ar_dmodestr = NULL;
|
||||
|
@ -138,18 +138,22 @@ static void nullAttrRec(/*@out@*/ AttrRec ar)
|
|||
|
||||
/**
|
||||
*/
|
||||
static void freeAttrRec(AttrRec ar)
|
||||
static void freeAttrRec(AttrRec ar) /*@modifies ar @*/
|
||||
{
|
||||
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) */
|
||||
/*@-nullstate@*/
|
||||
return;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
static void dupAttrRec(const AttrRec oar, /*@in@*/ /*@out@*/ AttrRec nar)
|
||||
/*@modifies nar @*/
|
||||
{
|
||||
if (oar == nar)
|
||||
return;
|
||||
|
@ -165,7 +169,8 @@ static void dupAttrRec(const AttrRec oar, /*@in@*/ /*@out@*/ AttrRec nar)
|
|||
#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",
|
||||
|
@ -237,7 +242,7 @@ static char *strtokWithQuotes(char *s, char *delim)
|
|||
|
||||
/**
|
||||
*/
|
||||
static void timeCheck(int tc, Header h)
|
||||
static void timeCheck(int tc, Header h) /*@modifies internalState @*/
|
||||
{
|
||||
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
||||
HFD_t hfd = headerFreeData;
|
||||
|
@ -281,7 +286,10 @@ VFA_t verifyAttrs[] = {
|
|||
/**
|
||||
* @param fl package file tree walk data
|
||||
*/
|
||||
static int parseForVerify(char *buf, FileList fl)
|
||||
static int parseForVerify(char * buf, FileList fl)
|
||||
/*@modifies buf, fl->processingFailed,
|
||||
fl->currentVerifyFlags, fl->defVerifyFlags,
|
||||
fl->currentSpecdFlags, fl->defSpecdFlags @*/
|
||||
{
|
||||
char *p, *pe, *q;
|
||||
const char *name;
|
||||
|
@ -371,7 +379,10 @@ static int parseForVerify(char *buf, FileList fl)
|
|||
/**
|
||||
* @param fl package file tree walk data
|
||||
*/
|
||||
static int parseForAttr(char *buf, FileList fl)
|
||||
static int parseForAttr(char * buf, FileList fl)
|
||||
/*@modifies buf, fl->processingFailed,
|
||||
fl->cur_ar, fl->def_ar,
|
||||
fl->currentSpecdFlags, fl->defSpecdFlags @*/
|
||||
{
|
||||
char *p, *pe, *q;
|
||||
const char *name;
|
||||
|
@ -496,7 +507,9 @@ static int parseForAttr(char *buf, FileList fl)
|
|||
/**
|
||||
* @param fl package file tree walk data
|
||||
*/
|
||||
static int parseForConfig(char *buf, FileList fl)
|
||||
static int parseForConfig(char * buf, FileList fl)
|
||||
/*@modifies buf, fl->processingFailed,
|
||||
fl->currentFlags @*/
|
||||
{
|
||||
char *p, *pe, *q;
|
||||
const char *name;
|
||||
|
@ -554,14 +567,17 @@ static int parseForConfig(char *buf, FileList fl)
|
|||
|
||||
/**
|
||||
*/
|
||||
static int langCmp(const void * ap, const void *bp) {
|
||||
static int langCmp(const void * ap, const void * bp) /*@*/
|
||||
{
|
||||
return strcmp(*(const char **)ap, *(const char **)bp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fl package file tree walk data
|
||||
*/
|
||||
static int parseForLang(char *buf, FileList fl)
|
||||
static int parseForLang(char * buf, FileList fl)
|
||||
/*@modifies buf, fl->processingFailed,
|
||||
fl->currentLangs, fl->nLangs @*/
|
||||
{
|
||||
char *p, *pe, *q;
|
||||
const char *name;
|
||||
|
@ -618,6 +634,7 @@ static int parseForLang(char *buf, FileList fl)
|
|||
}
|
||||
|
||||
/* Check for duplicate locales */
|
||||
if (fl->currentLangs != NULL)
|
||||
for (i = 0; i < fl->nLangs; i++) {
|
||||
if (strncmp(fl->currentLangs[i], p, np))
|
||||
continue;
|
||||
|
@ -628,9 +645,8 @@ static int parseForLang(char *buf, FileList fl)
|
|||
}
|
||||
|
||||
/* Add new locale */
|
||||
fl->currentLangs = (const char **) ((fl->currentLangs == NULL)
|
||||
? xmalloc(sizeof(*fl->currentLangs))
|
||||
: xrealloc(fl->currentLangs,((fl->nLangs+1)*sizeof(*fl->currentLangs))));
|
||||
fl->currentLangs = xrealloc(fl->currentLangs,
|
||||
(fl->nLangs + 1) * sizeof(*fl->currentLangs));
|
||||
newp = xmalloc( np+1 );
|
||||
strncpy(newp, p, np);
|
||||
newp[np] = '\0';
|
||||
|
@ -649,6 +665,7 @@ static int parseForLang(char *buf, FileList fl)
|
|||
/**
|
||||
*/
|
||||
static int parseForRegexLang(const char * fileName, /*@out@*/ char ** lang)
|
||||
/*@modifies *lang @*/
|
||||
{
|
||||
static int initialized = 0;
|
||||
static int hasRegex = 0;
|
||||
|
@ -690,7 +707,7 @@ static int parseForRegexLang(const char * fileName, /*@out@*/ char ** lang)
|
|||
|
||||
/**
|
||||
*/
|
||||
static int parseForRegexMultiLib(const char *fileName)
|
||||
static int parseForRegexMultiLib(const char *fileName) /*@*/
|
||||
{
|
||||
static int initialized = 0;
|
||||
static int hasRegex = 0;
|
||||
|
@ -743,8 +760,13 @@ VFA_t virtualFileAttributes[] = {
|
|||
/**
|
||||
* @param fl package file tree walk data
|
||||
*/
|
||||
static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char *buf,
|
||||
FileList fl, const char ** fileName)
|
||||
static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char * buf,
|
||||
FileList fl, /*@out@*/ const char ** fileName)
|
||||
/*@modifies buf, fl->processingFailed, *fileName,
|
||||
fl->currentFlags,
|
||||
fl->docDirs, fl->docDirCount, fl->isDir,
|
||||
fl->passedSpecialDoc, fl->isSpecialDoc,
|
||||
pkg->specialDoc @*/
|
||||
{
|
||||
char *s, *t;
|
||||
int res, specialDoc = 0;
|
||||
|
@ -821,7 +843,7 @@ static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char *buf,
|
|||
if (*fileName || (fl->currentFlags & ~(RPMFILE_DOC))) {
|
||||
rpmError(RPMERR_BADSPEC,
|
||||
_("Can't mix special %%doc with other forms: %s\n"),
|
||||
*fileName);
|
||||
(*fileName ? *fileName : ""));
|
||||
fl->processingFailed = 1;
|
||||
res = 1;
|
||||
} else {
|
||||
|
@ -845,7 +867,9 @@ static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char *buf,
|
|||
appendLineStringBuf(pkg->specialDoc, "rm -rf $DOCDIR");
|
||||
appendLineStringBuf(pkg->specialDoc, MKDIR_P " $DOCDIR");
|
||||
|
||||
/*@-temptrans@*/
|
||||
*fileName = buf;
|
||||
/*@=temptrans@*/
|
||||
fl->passedSpecialDoc = 1;
|
||||
fl->isSpecialDoc = 1;
|
||||
}
|
||||
|
@ -861,7 +885,7 @@ static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char *buf,
|
|||
|
||||
/**
|
||||
*/
|
||||
static int compareFileListRecs(const void *ap, const void *bp)
|
||||
static int compareFileListRecs(const void * ap, const void * bp) /*@*/
|
||||
{
|
||||
const char *a = ((FileListRec)ap)->fileURL;
|
||||
const char *b = ((FileListRec)bp)->fileURL;
|
||||
|
@ -871,7 +895,7 @@ static int compareFileListRecs(const void *ap, const void *bp)
|
|||
/**
|
||||
* @param fl package file tree walk data
|
||||
*/
|
||||
static int isDoc(FileList fl, const char * fileName)
|
||||
static int isDoc(FileList fl, const char * fileName) /*@*/
|
||||
{
|
||||
int x = fl->docDirCount;
|
||||
|
||||
|
@ -888,6 +912,7 @@ static int isDoc(FileList fl, const char * fileName)
|
|||
* @param fl package file tree walk data
|
||||
*/
|
||||
static void checkHardLinks(FileList fl)
|
||||
/*@modifies fl->fileList->flags, fl->fileList->langs @*/
|
||||
{
|
||||
char nlangs[BUFSIZ];
|
||||
FileListRec ilp, jlp;
|
||||
|
@ -958,7 +983,8 @@ static void checkHardLinks(FileList fl)
|
|||
* @param fl package file tree walk data
|
||||
*/
|
||||
static void genCpioListAndHeader(/*@partial@*/ FileList fl,
|
||||
TFI_t *cpioList, Header h, int isSrc)
|
||||
TFI_t * cpioList, Header h, int isSrc)
|
||||
/*@modifies h, *cpioList, fl->processingFailed, fl->fileList @*/
|
||||
{
|
||||
int _addDotSlash = !(isSrc || rpmExpandNumeric("%{_noPayloadPrefix}"));
|
||||
uint_32 multiLibMask = 0;
|
||||
|
@ -1256,7 +1282,9 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl,
|
|||
|
||||
/**
|
||||
*/
|
||||
static /*@null@*/ FileListRec freeFileList(/*@only@*/ FileListRec fileList, int count)
|
||||
static /*@null@*/ FileListRec freeFileList(/*@only@*/ FileListRec fileList,
|
||||
int count)
|
||||
/*@*/
|
||||
{
|
||||
while (count--) {
|
||||
fileList[count].diskURL = _free(fileList[count].diskURL);
|
||||
|
@ -1270,7 +1298,10 @@ static /*@null@*/ FileListRec freeFileList(/*@only@*/ FileListRec fileList, int
|
|||
/**
|
||||
* @param fl package file tree walk data
|
||||
*/
|
||||
static int addFile(FileList fl, const char * diskURL, struct stat *statp)
|
||||
static int addFile(FileList fl, const char * diskURL, struct stat * statp)
|
||||
/*@modifies *statp, fl->processingFailed,
|
||||
fl->fileList, fl->fileListRecsAlloced, fl->fileListRecsUsed,
|
||||
fl->totalFileSize, fl->fileCount, fl->inFtw, fl->isDir @*/
|
||||
{
|
||||
const char *fileURL = diskURL;
|
||||
struct stat statbuf;
|
||||
|
@ -1443,8 +1474,11 @@ static int addFile(FileList fl, const char * diskURL, struct stat *statp)
|
|||
/**
|
||||
* @param fl package file tree walk data
|
||||
*/
|
||||
static int processBinaryFile(/*@unused@*/Package pkg, FileList fl,
|
||||
const char *fileURL)
|
||||
static int processBinaryFile(/*@unused@*/ Package pkg, FileList fl,
|
||||
const char * fileURL)
|
||||
/*@modifies fl->processingFailed,
|
||||
fl->fileList, fl->fileListRecsAlloced, fl->fileListRecsUsed,
|
||||
fl->totalFileSize, fl->fileCount, fl->inFtw, fl->isDir @*/
|
||||
{
|
||||
int doGlob;
|
||||
const char *diskURL = NULL;
|
||||
|
@ -1505,6 +1539,7 @@ exit:
|
|||
*/
|
||||
static int processPackageFiles(Spec spec, Package pkg,
|
||||
int installSpecialDoc, int test)
|
||||
/*@modifies pkg->cpioList, pkg->specialDoc, pkg->header */
|
||||
{
|
||||
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
||||
struct FileList_s fl;
|
||||
|
@ -1549,6 +1584,7 @@ static int processPackageFiles(Spec spec, Package pkg,
|
|||
ffn = _free(ffn);
|
||||
|
||||
/*@+voidabstract@*/ f = fdGetFp(fd); /*@=voidabstract@*/
|
||||
if (f != NULL)
|
||||
while (fgets(buf, sizeof(buf), f)) {
|
||||
handleComments(buf);
|
||||
if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
|
||||
|
@ -1617,7 +1653,9 @@ static int processPackageFiles(Spec spec, Package pkg,
|
|||
if (*s == '\0')
|
||||
continue;
|
||||
fileName = NULL;
|
||||
/*@-nullpass@*/ /* LCL: buf is NULL ?!? */
|
||||
strcpy(buf, s);
|
||||
/*@=nullpass@*/
|
||||
|
||||
/* Reset for a new line in %files */
|
||||
fl.isDir = 0;
|
||||
|
@ -1641,6 +1679,7 @@ static int processPackageFiles(Spec spec, Package pkg,
|
|||
|
||||
dupAttrRec(&fl.def_ar, &fl.cur_ar);
|
||||
|
||||
/*@-nullpass@*/ /* LCL: buf is NULL ?!? */
|
||||
if (parseForVerify(buf, &fl))
|
||||
continue;
|
||||
if (parseForAttr(buf, &fl))
|
||||
|
@ -1649,8 +1688,11 @@ static int processPackageFiles(Spec spec, Package pkg,
|
|||
continue;
|
||||
if (parseForLang(buf, &fl))
|
||||
continue;
|
||||
/*@-nullstate@*/ /* FIX: pkg->fileFile might be NULL */
|
||||
if (parseForSimple(spec, pkg, buf, &fl, &fileName))
|
||||
/*@=nullstate@*/
|
||||
continue;
|
||||
/*@=nullpass@*/
|
||||
if (fileName == NULL)
|
||||
continue;
|
||||
|
||||
|
@ -1660,7 +1702,9 @@ static int processPackageFiles(Spec spec, Package pkg,
|
|||
specialDoc = xstrdup(fileName);
|
||||
dupAttrRec(&fl.cur_ar, specialDocAttrRec);
|
||||
} else {
|
||||
/*@-nullstate@*/ /* FIX: pkg->fileFile might be NULL */
|
||||
(void) processBinaryFile(pkg, &fl, fileName);
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1690,7 +1734,9 @@ static int processPackageFiles(Spec spec, Package pkg,
|
|||
dupAttrRec(specialDocAttrRec, &fl.cur_ar);
|
||||
freeAttrRec(specialDocAttrRec);
|
||||
|
||||
/*@-nullstate@*/ /* FIX: pkg->fileFile might be NULL */
|
||||
(void) processBinaryFile(pkg, &fl, specialDoc);
|
||||
/*@=nullstate@*/
|
||||
|
||||
specialDoc = _free(specialDoc);
|
||||
}
|
||||
|
@ -1762,7 +1808,8 @@ void initSourceHeader(Spec spec)
|
|||
case RPMTAG_CHANGELOGTEXT:
|
||||
case RPMTAG_URL:
|
||||
case HEADER_I18NTABLE:
|
||||
(void) headerAddEntry(spec->sourceHeader, tag, type, ptr, count);
|
||||
if (ptr)
|
||||
(void)headerAddEntry(spec->sourceHeader, tag, type, ptr, count);
|
||||
break;
|
||||
default:
|
||||
/* do not copy */
|
||||
|
@ -1776,11 +1823,12 @@ void initSourceHeader(Spec spec)
|
|||
headerNextIterator(hi, &tag, &type, &ptr, &count);
|
||||
ptr = headerFreeData(ptr, type))
|
||||
{
|
||||
if (ptr)
|
||||
(void) headerAddEntry(spec->sourceHeader, tag, type, ptr, count);
|
||||
}
|
||||
headerFreeIterator(hi);
|
||||
|
||||
if (spec->buildArchitectureCount) {
|
||||
if (spec->buildArchitectures && spec->buildArchitectureCount > 0) {
|
||||
(void) headerAddEntry(spec->sourceHeader, RPMTAG_BUILDARCHS,
|
||||
RPM_STRING_ARRAY_TYPE,
|
||||
spec->buildArchitectures, spec->buildArchitectureCount);
|
||||
|
@ -1807,6 +1855,7 @@ int processSourceFiles(Spec spec)
|
|||
|
||||
/* Construct the file list and source entries */
|
||||
appendLineStringBuf(sourceFiles, spec->specFile);
|
||||
if (spec->sourceHeader != NULL)
|
||||
for (srcPtr = spec->sources; srcPtr != NULL; srcPtr = srcPtr->next) {
|
||||
if (srcPtr->flags & RPMBUILD_ISSOURCE) {
|
||||
(void) headerAddOrAppendEntry(spec->sourceHeader, RPMTAG_SOURCE,
|
||||
|
@ -1910,7 +1959,9 @@ int processSourceFiles(Spec spec)
|
|||
freeSplitString(files);
|
||||
|
||||
if (! fl.processingFailed) {
|
||||
genCpioListAndHeader(&fl, (TFI_t *)&spec->sourceCpioList, spec->sourceHeader, 1);
|
||||
if (spec->sourceHeader != NULL)
|
||||
genCpioListAndHeader(&fl, (TFI_t *)&spec->sourceCpioList,
|
||||
spec->sourceHeader, 1);
|
||||
}
|
||||
|
||||
freeStringBuf(sourceFiles);
|
||||
|
@ -1920,9 +1971,10 @@ int processSourceFiles(Spec spec)
|
|||
|
||||
/**
|
||||
*/
|
||||
static StringBuf getOutputFrom(char *dir, char *argv[],
|
||||
const char *writePtr, int writeBytesLeft,
|
||||
static StringBuf getOutputFrom(char * dir, char * argv[],
|
||||
const char * writePtr, int writeBytesLeft,
|
||||
int failNonZero)
|
||||
/*@*/
|
||||
{
|
||||
int progPID;
|
||||
int toProg[2];
|
||||
|
@ -2109,6 +2161,7 @@ DepMsg_t depMsgs[] = {
|
|||
/**
|
||||
*/
|
||||
static int generateDepends(Spec spec, Package pkg, TFI_t cpioList, int multiLib)
|
||||
/*@modifies cpioList @*/
|
||||
{
|
||||
TFI_t fi = cpioList;
|
||||
StringBuf writeBuf;
|
||||
|
@ -2222,8 +2275,9 @@ static int generateDepends(Spec spec, Package pkg, TFI_t cpioList, int multiLib)
|
|||
|
||||
/**
|
||||
*/
|
||||
static void printDepMsg(DepMsg_t *dm, int count, const char **names,
|
||||
const char **versions, int *flags)
|
||||
static void printDepMsg(DepMsg_t * dm, int count, const char ** names,
|
||||
const char ** versions, int *flags)
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
int hasVersions = (versions != NULL);
|
||||
int hasFlags = (flags != NULL);
|
||||
|
@ -2264,6 +2318,7 @@ static void printDepMsg(DepMsg_t *dm, int count, const char **names,
|
|||
/**
|
||||
*/
|
||||
static void printDeps(Header h)
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
||||
HFD_t hfd = headerFreeData;
|
||||
|
|
|
@ -6,10 +6,13 @@
|
|||
#include "rpmbuild.h"
|
||||
#include "debug.h"
|
||||
|
||||
int parseNum(const char *line, int *res)
|
||||
int parseNum(const char * line, int * res)
|
||||
{
|
||||
char * s1 = NULL;
|
||||
unsigned long rc;
|
||||
|
||||
*res = strtoul(line, &s1, 10);
|
||||
return (((*s1) || (s1 == line) || (*res == ULONG_MAX)) ? 1 : 0);
|
||||
if (line == NULL) return 1;
|
||||
rc = strtoul(line, &s1, 10);
|
||||
if (res) *res = rc;
|
||||
return (((*s1) || (s1 == line) || (rc == ULONG_MAX)) ? 1 : 0);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ Cambridge, MA 02139, USA. */
|
|||
|
||||
/**
|
||||
*/
|
||||
/*@-nullstate@*/
|
||||
static int
|
||||
myftw_dir (DIR **dirs, int level, int descriptors,
|
||||
char *dir, size_t len,
|
||||
|
@ -106,8 +107,10 @@ myftw_dir (DIR **dirs, int level, int descriptors,
|
|||
{
|
||||
newlev = (level + 1) % descriptors;
|
||||
|
||||
/*@-unqualifiedtrans@*/
|
||||
if (dirs[newlev] != NULL)
|
||||
(void) Closedir (dirs[newlev]);
|
||||
/*@=unqualifiedtrans@*/
|
||||
|
||||
dirs[newlev] = Opendir (dir);
|
||||
if (dirs[newlev] != NULL)
|
||||
|
@ -165,6 +168,7 @@ myftw_dir (DIR **dirs, int level, int descriptors,
|
|||
|
||||
return errno == 0 ? 0 : -1;
|
||||
}
|
||||
/*@=nullstate@*/
|
||||
|
||||
/* Call a function on every element in a directory tree. */
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ static gid_t gids[1024];
|
|||
/*@owned@*/ /*@null@*/ static const char *gnames[1024];
|
||||
static int gid_used = 0;
|
||||
|
||||
/*@-nullderef@*/ /* FIX: shrug */
|
||||
void freeNames(void)
|
||||
{
|
||||
int x;
|
||||
|
@ -109,6 +110,7 @@ const char *getGnameS(const char *gname)
|
|||
gnames[x] = (gr ? xstrdup(gr->gr_name) : xstrdup(gname));
|
||||
return gnames[x];
|
||||
}
|
||||
/*@=nullderef@*/
|
||||
|
||||
time_t *const getBuildTime(void)
|
||||
{
|
||||
|
|
62
build/pack.c
62
build/pack.c
|
@ -20,10 +20,12 @@ extern int _noDirTokens;
|
|||
/*@access TFI_t @*/ /* compared with NULL */
|
||||
/*@access Header @*/ /* compared with NULL */
|
||||
/*@access FD_t @*/ /* compared with NULL */
|
||||
/*@access CSA_t @*/
|
||||
|
||||
/**
|
||||
*/
|
||||
static inline int genSourceRpmName(Spec spec)
|
||||
/*@modifies spec->sourceRpmName @*/
|
||||
{
|
||||
if (spec->sourceRpmName == NULL) {
|
||||
const char *name, *version, *release;
|
||||
|
@ -41,8 +43,9 @@ static inline int genSourceRpmName(Spec spec)
|
|||
/**
|
||||
* @todo Create transaction set *much* earlier.
|
||||
*/
|
||||
static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t * csa,
|
||||
static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t csa,
|
||||
const char * fmodeMacro)
|
||||
/*@modifies csa, fileSystem @*/
|
||||
{
|
||||
const char * rootDir = "/";
|
||||
rpmdb rpmdb = NULL;
|
||||
|
@ -55,8 +58,12 @@ static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t * csa,
|
|||
|
||||
if (!(fmode && fmode[0] == 'w'))
|
||||
fmode = xstrdup("w9.gzdio");
|
||||
/*@-nullpass@*/
|
||||
(void) Fflush(fdo);
|
||||
cfd = Fdopen(fdDup(Fileno(fdo)), fmode);
|
||||
/*@=nullpass@*/
|
||||
if (cfd == NULL)
|
||||
return 1;
|
||||
|
||||
rc = fsmSetup(fi->fsm, FSM_PKGBUILD, ts, fi, cfd,
|
||||
&csa->cpioArchiveSize, &failedFile);
|
||||
|
@ -78,7 +85,8 @@ static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t * csa,
|
|||
|
||||
/**
|
||||
*/
|
||||
static int cpio_copy(FD_t fdo, CSA_t *csa)
|
||||
static int cpio_copy(FD_t fdo, CSA_t csa)
|
||||
/*@modifies csa, fileSystem @*/
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
size_t nb;
|
||||
|
@ -103,6 +111,7 @@ static int cpio_copy(FD_t fdo, CSA_t *csa)
|
|||
*/
|
||||
static /*@only@*/ /*@null@*/ StringBuf addFileToTagAux(Spec spec,
|
||||
const char * file, /*@only@*/ StringBuf sb)
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
const char * fn = buf;
|
||||
|
@ -118,7 +127,7 @@ static /*@only@*/ /*@null@*/ StringBuf addFileToTagAux(Spec spec,
|
|||
freeStringBuf(sb);
|
||||
return NULL;
|
||||
}
|
||||
f = fdGetFp(fd);
|
||||
if ((f = fdGetFp(fd)) != NULL)
|
||||
while (fgets(buf, sizeof(buf), f)) {
|
||||
/* XXX display fn in error msg */
|
||||
if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
|
||||
|
@ -137,6 +146,7 @@ static /*@only@*/ /*@null@*/ StringBuf addFileToTagAux(Spec spec,
|
|||
/**
|
||||
*/
|
||||
static int addFileToTag(Spec spec, const char * file, Header h, int tag)
|
||||
/*@modifies h, fileSystem @*/
|
||||
{
|
||||
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
||||
StringBuf sb = newStringBuf();
|
||||
|
@ -159,6 +169,7 @@ static int addFileToTag(Spec spec, const char * file, Header h, int tag)
|
|||
/**
|
||||
*/
|
||||
static int addFileToArrayTag(Spec spec, const char *file, Header h, int tag)
|
||||
/*@modifies h, fileSystem @*/
|
||||
{
|
||||
StringBuf sb = newStringBuf();
|
||||
char *s;
|
||||
|
@ -176,6 +187,7 @@ static int addFileToArrayTag(Spec spec, const char *file, Header h, int tag)
|
|||
/**
|
||||
*/
|
||||
static int processScriptFiles(Spec spec, Package pkg)
|
||||
/*@modifies pkg->header, fileSystem @*/
|
||||
{
|
||||
struct TriggerFileEntry *p;
|
||||
|
||||
|
@ -243,26 +255,25 @@ static int processScriptFiles(Spec spec, Package pkg)
|
|||
}
|
||||
|
||||
int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sigs,
|
||||
CSA_t *csa)
|
||||
CSA_t csa)
|
||||
{
|
||||
FD_t fdi;
|
||||
Spec spec;
|
||||
rpmRC rc;
|
||||
|
||||
if (fileName != NULL) {
|
||||
fdi = Fopen(fileName, "r.ufdio");
|
||||
fdi = (fileName != NULL) ? Fopen(fileName, "r.ufdio") : fdDup(STDIN_FILENO);
|
||||
if (fdi == NULL || Ferror(fdi)) {
|
||||
rpmError(RPMERR_BADMAGIC, _("readRPM: open %s: %s\n"), fileName,
|
||||
rpmError(RPMERR_BADMAGIC, _("readRPM: open %s: %s\n"),
|
||||
(fileName ? fileName : "<stdin>"),
|
||||
Fstrerror(fdi));
|
||||
if (fdi) (void) Fclose(fdi);
|
||||
return RPMERR_BADMAGIC;
|
||||
}
|
||||
} else {
|
||||
fdi = fdDup(STDIN_FILENO);
|
||||
}
|
||||
|
||||
/* Get copy of lead */
|
||||
if ((rc = Fread(lead, sizeof(char), sizeof(*lead), fdi)) != sizeof(*lead)) {
|
||||
rpmError(RPMERR_BADMAGIC, _("readRPM: read %s: %s\n"), fileName,
|
||||
rpmError(RPMERR_BADMAGIC, _("readRPM: read %s: %s\n"),
|
||||
(fileName ? fileName : "<stdin>"),
|
||||
Fstrerror(fdi));
|
||||
return RPMERR_BADMAGIC;
|
||||
}
|
||||
|
@ -284,7 +295,7 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig
|
|||
switch (rc) {
|
||||
case RPMRC_BADMAGIC:
|
||||
rpmError(RPMERR_BADMAGIC, _("readRPM: %s is not an RPM package\n"),
|
||||
fileName);
|
||||
(fileName ? fileName : "<stdin>"));
|
||||
return RPMERR_BADMAGIC;
|
||||
case RPMRC_OK:
|
||||
break;
|
||||
|
@ -293,7 +304,7 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig
|
|||
case RPMRC_SHORTREAD:
|
||||
default:
|
||||
rpmError(RPMERR_BADMAGIC, _("readRPM: reading header from %s\n"),
|
||||
fileName);
|
||||
(fileName ? fileName : "<stdin>"));
|
||||
return RPMERR_BADMAGIC;
|
||||
/*@notreached@*/ break;
|
||||
}
|
||||
|
@ -303,7 +314,7 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig
|
|||
else
|
||||
freeSpec(spec);
|
||||
|
||||
if (csa)
|
||||
if (csa != NULL)
|
||||
csa->cpioFdIn = fdi;
|
||||
else
|
||||
(void) Fclose(fdi);
|
||||
|
@ -312,7 +323,7 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig
|
|||
}
|
||||
|
||||
int writeRPM(Header *hdrp, const char *fileName, int type,
|
||||
CSA_t *csa, char *passPhrase, const char **cookie)
|
||||
CSA_t csa, char *passPhrase, const char **cookie)
|
||||
{
|
||||
FD_t fd = NULL;
|
||||
FD_t ifd = NULL;
|
||||
|
@ -385,7 +396,13 @@ int writeRPM(Header *hdrp, const char *fileName, int type,
|
|||
}
|
||||
|
||||
/* Reallocate the header into one contiguous region. */
|
||||
/*@-refcounttrans -usereleased@*/
|
||||
*hdrp = h = headerReload(h, RPMTAG_HEADERIMMUTABLE);
|
||||
if (h == NULL) { /* XXX can't happen */
|
||||
rc = RPMERR_RELOAD;
|
||||
goto exit;
|
||||
}
|
||||
/*@=refcounttrans =usereleased@*/
|
||||
|
||||
/*
|
||||
* Write the header+archive into a temp file so that the size of
|
||||
|
@ -393,7 +410,8 @@ int writeRPM(Header *hdrp, const char *fileName, int type,
|
|||
*/
|
||||
if (makeTempFile(NULL, &sigtarget, &fd)) {
|
||||
rpmError(RPMERR_CREATE, _("Unable to open temp file.\n"));
|
||||
return RPMERR_CREATE;
|
||||
rc = RPMERR_CREATE;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (headerWrite(fd, h, HEADER_MAGIC_YES)) {
|
||||
|
@ -452,6 +470,10 @@ int writeRPM(Header *hdrp, const char *fileName, int type,
|
|||
|
||||
/* Reallocate the signature into one contiguous region. */
|
||||
sig = headerReload(sig, RPMTAG_HEADERSIGNATURES);
|
||||
if (sig == NULL) { /* XXX can't happen */
|
||||
rc = RPMERR_RELOAD;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Open the output file */
|
||||
fd = Fopen(fileName, "w.ufdio");
|
||||
|
@ -579,7 +601,9 @@ exit:
|
|||
else
|
||||
(void) Unlink(fileName);
|
||||
|
||||
/*@-nullstate@*/ /* FIX: *hdrp may be NULL */
|
||||
return rc;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
|
||||
static int_32 copyTags[] = {
|
||||
|
@ -591,7 +615,8 @@ static int_32 copyTags[] = {
|
|||
|
||||
int packageBinaries(Spec spec)
|
||||
{
|
||||
CSA_t csabuf, *csa = &csabuf;
|
||||
struct cpioSourceArchive_s csabuf;
|
||||
CSA_t csa = &csabuf;
|
||||
int rc;
|
||||
const char *errorString;
|
||||
Package pkg;
|
||||
|
@ -685,7 +710,8 @@ int packageBinaries(Spec spec)
|
|||
|
||||
int packageSources(Spec spec)
|
||||
{
|
||||
CSA_t csabuf, *csa = &csabuf;
|
||||
struct cpioSourceArchive_s csabuf;
|
||||
CSA_t csa = &csabuf;
|
||||
int rc;
|
||||
|
||||
/* Add some cruft */
|
||||
|
|
|
@ -35,6 +35,7 @@ void addChangelogEntry(Header h, time_t time, const char *name, const char *text
|
|||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
static int dateToTimet(const char * datestr, /*@out@*/ time_t * secs)
|
||||
/*@modifies *secs @*/
|
||||
{
|
||||
struct tm time;
|
||||
char *p, *pe, *q, ** idx;
|
||||
|
@ -103,6 +104,7 @@ static int dateToTimet(const char * datestr, /*@out@*/ time_t * secs)
|
|||
* @return 0 on success
|
||||
*/
|
||||
static int addChangelog(Header h, StringBuf sb)
|
||||
/*@modifies h @*/
|
||||
{
|
||||
char *s;
|
||||
int i;
|
||||
|
|
|
@ -428,6 +428,7 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro,
|
|||
int num;
|
||||
int rc;
|
||||
|
||||
if (field == NULL) return RPMERR_BADSPEC; /* XXX can't happen */
|
||||
/* Find the start of the "field" and strip trailing space */
|
||||
while ((*field) && (*field != ':'))
|
||||
field++;
|
||||
|
@ -664,12 +665,13 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro,
|
|||
|
||||
/**
|
||||
*/
|
||||
static struct PreambleRec {
|
||||
typedef struct PreambleRec_s {
|
||||
int tag;
|
||||
int len;
|
||||
int multiLang;
|
||||
char *token;
|
||||
} preambleList[] = {
|
||||
const char * token;
|
||||
} * PreambleRec;
|
||||
static struct PreambleRec_s preambleList[] = {
|
||||
{RPMTAG_NAME, 0, 0, "name"},
|
||||
{RPMTAG_VERSION, 0, 0, "version"},
|
||||
{RPMTAG_RELEASE, 0, 0, "release"},
|
||||
|
@ -710,24 +712,27 @@ static struct PreambleRec {
|
|||
{RPMTAG_AUTOREQ, 0, 0, "autoreq"},
|
||||
{RPMTAG_AUTOPROV, 0, 0, "autoprov"},
|
||||
{RPMTAG_DOCDIR, 0, 0, "docdir"},
|
||||
/*@-nullassign@*/ /* LCL: can't add null annotation */
|
||||
{0, 0, 0, 0}
|
||||
/*@=nullassign@*/
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
static inline void initPreambleList(void)
|
||||
{
|
||||
struct PreambleRec *p;
|
||||
PreambleRec p;
|
||||
for (p = preambleList; p->token; p++)
|
||||
p->len = strlen(p->token);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
static int findPreambleTag(Spec spec, /*@out@*/int *tag, /*@out@*/char **macro, char *lang)
|
||||
static int findPreambleTag(Spec spec, /*@out@*/int * tag,
|
||||
/*@null@*/ /*@out@*/ const char ** macro, char *lang)
|
||||
{
|
||||
char *s;
|
||||
struct PreambleRec *p;
|
||||
PreambleRec p;
|
||||
|
||||
if (preambleList[0].len == 0)
|
||||
initPreambleList();
|
||||
|
@ -772,7 +777,7 @@ static int findPreambleTag(Spec spec, /*@out@*/int *tag, /*@out@*/char **macro,
|
|||
|
||||
*tag = p->tag;
|
||||
if (macro)
|
||||
/*@-onlytrans@*/
|
||||
/*@-onlytrans@*/ /* FIX: observer, but double indirection. */
|
||||
*macro = p->token;
|
||||
/*@=onlytrans@*/
|
||||
return 0;
|
||||
|
@ -782,7 +787,7 @@ int parsePreamble(Spec spec, int initialPackage)
|
|||
{
|
||||
int nextPart;
|
||||
int tag, rc;
|
||||
char *name, *linep, *macro;
|
||||
char *name, *linep;
|
||||
int flag;
|
||||
Package pkg;
|
||||
char fullName[BUFSIZ];
|
||||
|
@ -822,6 +827,7 @@ int parsePreamble(Spec spec, int initialPackage)
|
|||
if (rc)
|
||||
return rc;
|
||||
while (! (nextPart = isPart(spec->line))) {
|
||||
const char * macro;
|
||||
/* Skip blank lines */
|
||||
linep = spec->line;
|
||||
SKIPSPACE(linep);
|
||||
|
|
|
@ -296,7 +296,7 @@ static int doSetupMacro(Spec spec, char *line)
|
|||
|
||||
if (parseNum(optArg, &num)) {
|
||||
rpmError(RPMERR_BADSPEC, _("line %d: Bad arg to %%setup: %s\n"),
|
||||
spec->lineNum, optArg);
|
||||
spec->lineNum, (optArg ? optArg : "???"));
|
||||
freeStringBuf(before);
|
||||
freeStringBuf(after);
|
||||
poptFreeContext(optCon);
|
||||
|
|
|
@ -18,7 +18,7 @@ static int _debug = 0;
|
|||
static struct PartRec {
|
||||
int part;
|
||||
int len;
|
||||
char *token;
|
||||
/*@observer@*/ /*@null@*/ const char * token;
|
||||
} partList[] = {
|
||||
{ PART_PREAMBLE, 0, "%package"},
|
||||
{ PART_PREP, 0, "%prep"},
|
||||
|
@ -193,7 +193,8 @@ retry:
|
|||
|
||||
/* Make sure we have something in the read buffer */
|
||||
if (!(ofi->readPtr && *(ofi->readPtr))) {
|
||||
if (!fgets(ofi->readBuf, BUFSIZ, fdGetFp(ofi->fd))) {
|
||||
FILE * f = fdGetFp(ofi->fd);
|
||||
if (f == NULL || !fgets(ofi->readBuf, BUFSIZ, f)) {
|
||||
/* EOF */
|
||||
if (spec->readStack->next) {
|
||||
rpmError(RPMERR_UNMATCHEDIF, _("Unclosed %%if\n"));
|
||||
|
@ -218,7 +219,7 @@ retry:
|
|||
ofi->lineNum++;
|
||||
spec->lineNum = ofi->lineNum;
|
||||
if (spec->sl) {
|
||||
struct speclines *sl = spec->sl;
|
||||
struct speclines * sl = spec->sl;
|
||||
if (sl->sl_nlines == sl->sl_nalloc) {
|
||||
sl->sl_nalloc += 100;
|
||||
sl->sl_lines = (char **) xrealloc(sl->sl_lines,
|
||||
|
@ -463,6 +464,7 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU
|
|||
spec->buildArchitectureSpecs =
|
||||
xmalloc(sizeof(Spec) * spec->buildArchitectureCount);
|
||||
index = 0;
|
||||
if (spec->buildArchitectures != NULL)
|
||||
for (x = 0; x < spec->buildArchitectureCount; x++) {
|
||||
if (rpmMachineScore(RPM_MACHTABLE_BUILDARCH,
|
||||
spec->buildArchitectures[x])) {
|
||||
|
|
159
build/rpmbuild.h
159
build/rpmbuild.h
|
@ -77,7 +77,8 @@ extern "C" {
|
|||
/** \ingroup rpmbuild
|
||||
* Destroy uid/gid caches.
|
||||
*/
|
||||
void freeNames(void);
|
||||
void freeNames(void)
|
||||
/*@modifies internalState */;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Return cached user name from user id.
|
||||
|
@ -85,7 +86,7 @@ void freeNames(void);
|
|||
* @param user id
|
||||
* @return cached user name
|
||||
*/
|
||||
/*@observer@*/ const char *getUname(uid_t uid);
|
||||
/*@observer@*/ const char * getUname(uid_t uid) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Return cached user name.
|
||||
|
@ -93,7 +94,7 @@ void freeNames(void);
|
|||
* @param user name
|
||||
* @return cached user name
|
||||
*/
|
||||
/*@observer@*/ const char *getUnameS(const char *uname);
|
||||
/*@observer@*/ const char * getUnameS(const char * uname) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Return cached group name from group id.
|
||||
|
@ -101,7 +102,7 @@ void freeNames(void);
|
|||
* @param group id
|
||||
* @return cached group name
|
||||
*/
|
||||
/*@observer@*/ const char *getGname(gid_t gid);
|
||||
/*@observer@*/ const char * getGname(gid_t gid) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Return cached group name.
|
||||
|
@ -109,19 +110,19 @@ void freeNames(void);
|
|||
* @param group name
|
||||
* @return cached group name
|
||||
*/
|
||||
/*@observer@*/ const char *getGnameS(const char *gname);
|
||||
/*@observer@*/ const char * getGnameS(const char * gname) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Return build hostname.
|
||||
* @return build hostname
|
||||
*/
|
||||
/*@observer@*/ const char *const buildHost(void);
|
||||
/*@observer@*/ const char * const buildHost(void) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Return build time stamp.
|
||||
* @return build time stamp
|
||||
*/
|
||||
/*@observer@*/ time_t *const getBuildTime(void);
|
||||
/*@observer@*/ time_t * const getBuildTime(void) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Read next line from spec file.
|
||||
|
@ -129,26 +130,30 @@ void freeNames(void);
|
|||
* @param strip truncate comments?
|
||||
* @return 0 on success, 1 on EOF, <0 on error
|
||||
*/
|
||||
int readLine(Spec spec, int strip);
|
||||
int readLine(Spec spec, int strip)
|
||||
/*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
|
||||
spec->sl @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Stop reading from spec file, freeing resources.
|
||||
* @param spec spec file control structure
|
||||
*/
|
||||
void closeSpec(Spec spec);
|
||||
void closeSpec(/*@partial@*/ Spec spec)
|
||||
/*@modifies spec->fileStack @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Truncate comment lines.
|
||||
* @param s skip white space, truncate line at '#'
|
||||
*/
|
||||
void handleComments(char *s);
|
||||
void handleComments(char * s)
|
||||
/*@modifies s @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Check line for section separator, return next parser state.
|
||||
* @param line from spec file
|
||||
* @return next parser state
|
||||
*/
|
||||
rpmParseState isPart(const char *line);
|
||||
rpmParseState isPart(const char * line) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse a number.
|
||||
|
@ -156,7 +161,8 @@ rpmParseState isPart(const char *line);
|
|||
* @retval res pointer to int
|
||||
* @return 0 on success, 1 on failure
|
||||
*/
|
||||
int parseNum(const char *line, /*@out@*/int *res);
|
||||
int parseNum(/*@null@*/ const char * line, /*@null@*/ /*@out@*/int * res)
|
||||
/*@modifies *res @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Add changelog entry to header.
|
||||
|
@ -165,7 +171,9 @@ int parseNum(const char *line, /*@out@*/int *res);
|
|||
* @param name person who made the change
|
||||
* @param text description of change
|
||||
*/
|
||||
void addChangelogEntry(Header h, time_t time, const char *name, const char *text);
|
||||
void addChangelogEntry(Header h, time_t time, const char * name,
|
||||
const char * text)
|
||||
/*@modifies h @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse %%build/%%install/%%clean section(s) of a spec file.
|
||||
|
@ -173,28 +181,40 @@ void addChangelogEntry(Header h, time_t time, const char *name, const char *text
|
|||
* @param parsePart current rpmParseState
|
||||
* @return >= 0 next rpmParseState, < 0 on error
|
||||
*/
|
||||
int parseBuildInstallClean(Spec spec, rpmParseState parsePart);
|
||||
int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
|
||||
/*@modifies spec->build, spec->install, spec->clean,
|
||||
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
|
||||
spec->sl @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse %%changelog section of a spec file.
|
||||
* @param spec spec file control structure
|
||||
* @return >= 0 next rpmParseState, < 0 on error
|
||||
*/
|
||||
int parseChangelog(Spec spec);
|
||||
int parseChangelog(Spec spec)
|
||||
/*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
|
||||
spec->sl,
|
||||
spec->packages->header @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse %%description section of a spec file.
|
||||
* @param spec spec file control structure
|
||||
* @return >= 0 next rpmParseState, < 0 on error
|
||||
*/
|
||||
int parseDescription(Spec spec);
|
||||
int parseDescription(Spec spec)
|
||||
/*@modifies spec->packages,
|
||||
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
|
||||
spec->sl, spec->st @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse %%files section of a spec file.
|
||||
* @param spec spec file control structure
|
||||
* @return >= 0 next rpmParseState, < 0 on error
|
||||
*/
|
||||
int parseFiles(Spec spec);
|
||||
int parseFiles(Spec spec)
|
||||
/*@modifies spec->packages,
|
||||
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
|
||||
spec->sl @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse tags from preamble of a spec file.
|
||||
|
@ -202,14 +222,20 @@ int parseFiles(Spec spec);
|
|||
* @param initialPackage
|
||||
* @return >= 0 next rpmParseState, < 0 on error
|
||||
*/
|
||||
int parsePreamble(Spec spec, int initialPackage);
|
||||
int parsePreamble(Spec spec, int initialPackage)
|
||||
/*@modifies spec->packages,
|
||||
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
|
||||
spec->sl @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse %%prep section of a spec file.
|
||||
* @param spec spec file control structure
|
||||
* @return >= 0 next rpmParseState, < 0 on error
|
||||
*/
|
||||
int parsePrep(Spec spec);
|
||||
int parsePrep(Spec spec)
|
||||
/*@modifies spec->prep,
|
||||
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
|
||||
spec->sl @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse dependency relations from spec file and/or autogenerated output buffer.
|
||||
|
@ -221,8 +247,9 @@ int parsePrep(Spec spec);
|
|||
* @param flags dependency flags already known from context
|
||||
* @return 0 on success, RPMERR_BADSPEC on failure
|
||||
*/
|
||||
int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index,
|
||||
rpmsenseFlags flags);
|
||||
int parseRCPOT(Spec spec, Package pkg, const char * field, int tag, int index,
|
||||
rpmsenseFlags flags)
|
||||
/*@modifies nothing @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse %%pre et al scriptlets from a spec file.
|
||||
|
@ -230,7 +257,10 @@ int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index,
|
|||
* @param parsePart current rpmParseState
|
||||
* @return >= 0 next rpmParseState, < 0 on error
|
||||
*/
|
||||
int parseScript(Spec spec, int parsePart);
|
||||
int parseScript(Spec spec, int parsePart)
|
||||
/*@modifies spec->packages,
|
||||
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
|
||||
spec->sl @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Parse %%trigger et al scriptlets from a spec file.
|
||||
|
@ -240,7 +270,8 @@ int parseScript(Spec spec, int parsePart);
|
|||
* @param tag
|
||||
* @return
|
||||
*/
|
||||
int parseTrigger(Spec spec, Package pkg, char *field, int tag);
|
||||
int parseTrigger(Spec spec, Package pkg, char * field, int tag)
|
||||
/*@modifies nothing @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Evaluate boolean expression.
|
||||
|
@ -248,7 +279,7 @@ int parseTrigger(Spec spec, Package pkg, char *field, int tag);
|
|||
* @param expr expression to parse
|
||||
* @return
|
||||
*/
|
||||
int parseExpressionBoolean(Spec spec, const char * expr);
|
||||
int parseExpressionBoolean(Spec spec, const char * expr) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Evaluate string expression.
|
||||
|
@ -256,7 +287,8 @@ int parseExpressionBoolean(Spec spec, const char * expr);
|
|||
* @param expr expression to parse
|
||||
* @return
|
||||
*/
|
||||
char *parseExpressionString(Spec spec, const char * expr);
|
||||
char * parseExpressionString(Spec spec, const char * expr)
|
||||
/*@modifies nothing @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Run a build script, assembled from spec file scriptlet section.
|
||||
|
@ -268,7 +300,8 @@ char *parseExpressionString(Spec spec, const char * expr);
|
|||
* @param test don't execute scripts or package if testing
|
||||
* @return 0 on success, RPMERR_SCRIPT on failure
|
||||
*/
|
||||
int doScript(Spec spec, int what, const char *name, StringBuf sb, int test);
|
||||
int doScript(Spec spec, int what, const char * name, StringBuf sb, int test)
|
||||
/*@modifies spec->macros, fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Find sub-package control structure by name.
|
||||
|
@ -278,26 +311,31 @@ int doScript(Spec spec, int what, const char *name, StringBuf sb, int test);
|
|||
* @retval pkg package control structure
|
||||
* @return 0 on success, 1 on failure
|
||||
*/
|
||||
int lookupPackage(Spec spec, const char *name, int flag, /*@out@*/Package *pkg);
|
||||
int lookupPackage(Spec spec, /*@null@*/ const char * name, int flag,
|
||||
/*@out@*/ Package * pkg)
|
||||
/*@modifies spec->packages, *pkg @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Create and initialize package control structure.
|
||||
* @param spec spec file control structure
|
||||
* @return package control structure
|
||||
*/
|
||||
/*@only@*/ Package newPackage(Spec spec);
|
||||
/*@only@*/ Package newPackage(Spec spec)
|
||||
/*@modifies spec->packages, spec->packages->next @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Destroy all packages associated with spec file.
|
||||
* @param spec spec file control structure
|
||||
*/
|
||||
void freePackages(Spec spec);
|
||||
void freePackages(Spec spec)
|
||||
/*@modifies spec->packages @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Destroy package control structure.
|
||||
* @param pkg package control structure
|
||||
*/
|
||||
void freePackage(/*@only@*/ Package pkg);
|
||||
void freePackage(/*@only@*/ Package pkg)
|
||||
/*@modifies pkg @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Add dependency to header, filtering duplicates.
|
||||
|
@ -310,8 +348,9 @@ void freePackage(/*@only@*/ Package pkg);
|
|||
* @return 0 always
|
||||
*/
|
||||
int addReqProv(/*@unused@*/Spec spec, Header h,
|
||||
rpmsenseFlags flag, const char *depName, const char *depEVR,
|
||||
int index);
|
||||
rpmsenseFlags flag, const char * depName, const char * depEVR,
|
||||
int index)
|
||||
/*@modifies h @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Add rpmlib feature dependency.
|
||||
|
@ -320,7 +359,8 @@ int addReqProv(/*@unused@*/Spec spec, Header h,
|
|||
* @param featureEVR rpm feature epoch/version/release
|
||||
* @return 0 always
|
||||
*/
|
||||
int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR);
|
||||
int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR)
|
||||
/*@modifies h @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Post-build processing for binary package(s).
|
||||
|
@ -329,20 +369,28 @@ int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR);
|
|||
* @param test don't execute scripts or package if testing
|
||||
* @return 0 on success
|
||||
*/
|
||||
int processBinaryFiles(Spec spec, int installSpecialDoc, int test);
|
||||
int processBinaryFiles(Spec spec, int installSpecialDoc, int test)
|
||||
/*@modifies spec->packages->cpioList, spec->packages->specialDoc,
|
||||
spec->packages->header @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Create and initialize header for source package.
|
||||
* @param spec spec file control structure
|
||||
*/
|
||||
void initSourceHeader(Spec spec);
|
||||
void initSourceHeader(Spec spec)
|
||||
/*@modifies spec->sourceHeader,
|
||||
spec->buildRestrictions, spec->buildArchitectures,
|
||||
spec->packages->header @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Post-build processing for source package.
|
||||
* @param spec spec file control structure
|
||||
* @return 0 on success
|
||||
*/
|
||||
int processSourceFiles(Spec spec);
|
||||
int processSourceFiles(Spec spec)
|
||||
/*@modifies spec->sourceHeader, spec->sourceCpioList,
|
||||
spec->buildRestrictions, spec->buildArchitectures,
|
||||
spec->packages->header @*/;
|
||||
|
||||
/* global entry points */
|
||||
|
||||
|
@ -359,9 +407,14 @@ int processSourceFiles(Spec spec);
|
|||
* @param force
|
||||
* @return
|
||||
*/
|
||||
int parseSpec(Spec *specp, const char *specFile, const char *rootdir,
|
||||
const char *buildRoot, int inBuildArch, const char *passPhrase,
|
||||
char *cookie, int anyarch, int force);
|
||||
int parseSpec(/*@out@*/ Spec * specp, const char * specFile,
|
||||
const char * rootdir,
|
||||
/*@null@*/ const char * buildRoot,
|
||||
int inBuildArch,
|
||||
/*@null@*/ const char * passPhrase,
|
||||
/*@null@*/ char * cookie,
|
||||
int anyarch, int force)
|
||||
/*@modifies *specp @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* @retval specp spec file control structure
|
||||
|
@ -375,10 +428,14 @@ int parseSpec(Spec *specp, const char *specFile, const char *rootdir,
|
|||
* @param force
|
||||
* @return
|
||||
*/
|
||||
extern int (*parseSpecVec) (Spec *specp, const char *specFile,
|
||||
const char *rootdir, const char *buildRoot,
|
||||
int inBuildArch, const char *passPhrase,
|
||||
char *cookie, int anyarch, int force); /* XXX FIXME */
|
||||
extern int (*parseSpecVec) (Spec * specp, const char * specFile,
|
||||
const char * rootdir,
|
||||
/*@null@*/ const char * buildRoot,
|
||||
int inBuildArch,
|
||||
/*@null@*/ const char * passPhrase,
|
||||
/*@null@*/ char * cookie,
|
||||
int anyarch, int force)
|
||||
/*@modifies *specp @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Build stages state machine driver.
|
||||
|
@ -387,21 +444,31 @@ extern int (*parseSpecVec) (Spec *specp, const char *specFile,
|
|||
* @param test don't execute scripts or package if testing
|
||||
* @return 0 on success
|
||||
*/
|
||||
int buildSpec(Spec spec, int what, int test);
|
||||
int buildSpec(Spec spec, int what, int test)
|
||||
/*@modifies spec->sourceHeader, spec->sourceCpioList, spec->cookie,
|
||||
spec->sourceRpmName, spec->macros,
|
||||
spec->buildArchitectureSpecs,
|
||||
spec->buildRestrictions, spec->buildArchitectures,
|
||||
spec->packages->cpioList, spec->packages->specialDoc,
|
||||
spec->packages->header @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Generate binary package(s).
|
||||
* @param spec spec file control structure
|
||||
* @return 0 on success
|
||||
*/
|
||||
int packageBinaries(Spec spec);
|
||||
int packageBinaries(Spec spec)
|
||||
/*@modifies spec->packages->header,
|
||||
spec->sourceRpmName @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Generate source package.
|
||||
* @param spec spec file control structure
|
||||
* @return 0 on success
|
||||
*/
|
||||
int packageSources(Spec spec);
|
||||
int packageSources(Spec spec)
|
||||
/*@modifies spec->sourceHeader, spec->cookie,
|
||||
spec->sourceRpmName @*/;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -32,29 +32,29 @@ struct TriggerFileEntry {
|
|||
/** \ingroup rpmbuild
|
||||
*/
|
||||
struct Source {
|
||||
/*@owned@*/ char *fullSource;
|
||||
/*@dependent@*/ char *source; /* Pointer into fullSource */
|
||||
/*@owned@*/ char * fullSource;
|
||||
/*@dependent@*/ char * source; /* Pointer into fullSource */
|
||||
int flags;
|
||||
int num;
|
||||
/*@owned@*/ struct Source *next;
|
||||
/*@owned@*/ struct Source * next;
|
||||
};
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
*/
|
||||
typedef struct ReadLevelEntry {
|
||||
int reading;
|
||||
/*@dependent@*/ struct ReadLevelEntry *next;
|
||||
/*@dependent@*/ struct ReadLevelEntry * next;
|
||||
} RLE_t;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
*/
|
||||
typedef struct OpenFileInfo {
|
||||
/*@only@*/ const char *fileName;
|
||||
/*@only@*/ const char * fileName;
|
||||
FD_t fd;
|
||||
int lineNum;
|
||||
char readBuf[BUFSIZ];
|
||||
/*@dependent@*/ char *readPtr;
|
||||
/*@owned@*/ struct OpenFileInfo *next;
|
||||
/*@owned@*/ struct OpenFileInfo * next;
|
||||
} OFI_t;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
|
@ -63,8 +63,8 @@ struct spectag {
|
|||
int t_tag;
|
||||
int t_startx;
|
||||
int t_nlines;
|
||||
/*@only@*/ const char *t_lang;
|
||||
/*@only@*/ const char *t_msgid;
|
||||
/*@only@*/ const char * t_lang;
|
||||
/*@only@*/ const char * t_msgid;
|
||||
};
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
|
@ -87,27 +87,27 @@ struct speclines {
|
|||
* The structure used to store values parsed from a spec file.
|
||||
*/
|
||||
struct SpecStruct {
|
||||
/*@only@*/ const char *specFile; /*!< Name of the spec file. */
|
||||
/*@only@*/ const char *sourceRpmName;
|
||||
/*@only@*/ const char *buildRootURL;
|
||||
/*@only@*/ const char *buildSubdir;
|
||||
/*@only@*/ const char *rootURL;
|
||||
/*@only@*/ const char * specFile; /*!< Name of the spec file. */
|
||||
/*@only@*/ const char * sourceRpmName;
|
||||
/*@only@*/ const char * buildRootURL;
|
||||
/*@only@*/ const char * buildSubdir;
|
||||
/*@only@*/ const char * rootURL;
|
||||
|
||||
/*@owned@*/ struct speclines *sl;
|
||||
/*@owned@*/ struct spectags *st;
|
||||
/*@owned@*/ /*@null@*/ struct speclines * sl;
|
||||
/*@owned@*/ /*@null@*/ struct spectags * st;
|
||||
|
||||
/*@owned@*/ struct OpenFileInfo *fileStack;
|
||||
/*@owned@*/ struct OpenFileInfo * fileStack;
|
||||
char lbuf[4*BUFSIZ];
|
||||
char nextpeekc;
|
||||
/*@dependent@*/ char *nextline;
|
||||
/*@dependent@*/ char *line;
|
||||
/*@dependent@*/ char * nextline;
|
||||
/*@dependent@*/ char * line;
|
||||
int lineNum;
|
||||
|
||||
/*@owned@*/ struct ReadLevelEntry *readStack;
|
||||
/*@owned@*/ struct ReadLevelEntry * readStack;
|
||||
|
||||
/*@refcounted@*/ Header buildRestrictions;
|
||||
/*@owned@*/ struct SpecStruct **buildArchitectureSpecs;
|
||||
/*@only@*/ const char ** buildArchitectures;
|
||||
/*@owned@*/ /*@null@*/ struct SpecStruct ** buildArchitectureSpecs;
|
||||
/*@only@*/ /*@null@*/ const char ** buildArchitectures;
|
||||
int buildArchitectureCount;
|
||||
int inBuildArchitectures;
|
||||
|
||||
|
@ -116,25 +116,25 @@ struct SpecStruct {
|
|||
|
||||
int gotBuildRootURL;
|
||||
|
||||
char *passPhrase;
|
||||
/*@null@*/ char * passPhrase;
|
||||
int timeCheck;
|
||||
const char *cookie;
|
||||
/*@null@*/ const char * cookie;
|
||||
|
||||
/*@owned@*/ struct Source *sources;
|
||||
/*@owned@*/ struct Source * sources;
|
||||
int numSources;
|
||||
int noSource;
|
||||
|
||||
/*@refcounted@*/ Header sourceHeader;
|
||||
/*@owned@*/ void * sourceCpioList;
|
||||
|
||||
/*@dependent@*/ struct MacroContext *macros;
|
||||
/*@dependent@*/ /*@null@*/ MacroContext macros;
|
||||
|
||||
/*@only@*/ StringBuf prep; /*!< %prep scriptlet. */
|
||||
/*@only@*/ StringBuf build; /*!< %build scriptlet. */
|
||||
/*@only@*/ StringBuf install; /*!< %install scriptlet. */
|
||||
/*@only@*/ StringBuf clean; /*!< %clean scriptlet. */
|
||||
|
||||
/*@owned@*/ struct PackageStruct *packages; /*!< Package list. */
|
||||
/*@owned@*/ struct PackageStruct * packages; /*!< Package list. */
|
||||
};
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
|
@ -145,35 +145,30 @@ struct PackageStruct {
|
|||
|
||||
/*@owned@*/ void * cpioList;
|
||||
|
||||
/*@owned@*/ struct Source *icon;
|
||||
/*@owned@*/ struct Source * icon;
|
||||
|
||||
int autoReq;
|
||||
int autoProv;
|
||||
|
||||
/*@only@*/ const char *preInFile; /*!< %pre scriptlet. */
|
||||
/*@only@*/ const char *postInFile; /*!< %post scriptlet. */
|
||||
/*@only@*/ const char *preUnFile; /*!< %preun scriptlet. */
|
||||
/*@only@*/ const char *postUnFile; /*!< %postun scriptlet. */
|
||||
/*@only@*/ const char *verifyFile; /*!< %verifyscript scriptlet. */
|
||||
/*@only@*/ const char * preInFile; /*!< %pre scriptlet. */
|
||||
/*@only@*/ const char * postInFile; /*!< %post scriptlet. */
|
||||
/*@only@*/ const char * preUnFile; /*!< %preun scriptlet. */
|
||||
/*@only@*/ const char * postUnFile; /*!< %postun scriptlet. */
|
||||
/*@only@*/ const char * verifyFile; /*!< %verifyscript scriptlet. */
|
||||
|
||||
/*@only@*/ StringBuf specialDoc;
|
||||
|
||||
#if 0
|
||||
struct ReqProvTrigger *triggers;
|
||||
char *triggerScripts;
|
||||
#endif
|
||||
/*@only@*/ struct TriggerFileEntry * triggerFiles;
|
||||
|
||||
/*@only@*/ struct TriggerFileEntry *triggerFiles;
|
||||
|
||||
/*@only@*/ const char *fileFile;
|
||||
/*@only@*/ const char * fileFile;
|
||||
/*@only@*/ StringBuf fileList; /* If NULL, package will not be written */
|
||||
|
||||
/*@dependent@*/ struct PackageStruct *next;
|
||||
/*@dependent@*/ struct PackageStruct * next;
|
||||
};
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
*/
|
||||
typedef struct PackageStruct *Package;
|
||||
typedef struct PackageStruct * Package;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -182,37 +177,44 @@ extern "C" {
|
|||
/** \ingroup rpmbuild
|
||||
* Create and initialize Spec structure.
|
||||
*/
|
||||
/*@only@*/ Spec newSpec(void);
|
||||
/*@only@*/ Spec newSpec(void) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* Destroy Spec structure.
|
||||
* @param spec spec file control structure
|
||||
*/
|
||||
void freeSpec(/*@only@*/ Spec spec);
|
||||
void freeSpec(/*@only@*/ Spec spec)
|
||||
/*@modifies spec @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* @param spec spec file control structure
|
||||
*/
|
||||
extern void (*freeSpecVec) (Spec spec); /* XXX FIXME */
|
||||
extern void (*freeSpecVec) (Spec spec) /* XXX FIXME */
|
||||
/*@modifies spec @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
*/
|
||||
struct OpenFileInfo * newOpenFileInfo(void);
|
||||
struct OpenFileInfo * newOpenFileInfo(void) /*@*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* @param spec spec file control structure
|
||||
*/
|
||||
struct spectag *stashSt(Spec spec, Header h, int tag, const char *lang);
|
||||
struct spectag * stashSt(Spec spec, Header h, int tag, const char * lang)
|
||||
/*@modifies spec->st @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* @param spec spec file control structure
|
||||
*/
|
||||
int addSource(Spec spec, Package pkg, const char *field, int tag);
|
||||
int addSource(Spec spec, Package pkg, const char * field, int tag)
|
||||
/*@modifies spec->sources, spec->numSources,
|
||||
spec->st,
|
||||
pkg->icon @*/;
|
||||
|
||||
/** \ingroup rpmbuild
|
||||
* @param spec spec file control structure
|
||||
*/
|
||||
int parseNoSource(Spec spec, const char *field, int tag);
|
||||
int parseNoSource(Spec spec, const char * field, int tag)
|
||||
/*@modifies nothing @*/;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
24
build/spec.c
24
build/spec.c
|
@ -10,7 +10,7 @@
|
|||
#include "debug.h"
|
||||
|
||||
extern int specedit;
|
||||
extern MacroContext rpmGlobalMacroContext;
|
||||
extern struct MacroContext_s rpmGlobalMacroContext;
|
||||
|
||||
#define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
|
||||
#define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
|
||||
|
@ -84,9 +84,7 @@ int lookupPackage(Spec spec, const char *name, int flag, /*@out@*/Package *pkg)
|
|||
}
|
||||
|
||||
if (pkg)
|
||||
/*@-dependenttrans@*/
|
||||
*pkg = p;
|
||||
/*@=dependenttrans@*/
|
||||
/*@-dependenttrans@*/ *pkg = p; /*@=dependenttrans@*/
|
||||
return ((p == NULL) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
@ -249,6 +247,7 @@ int addSource(Spec spec, Package pkg, const char *field, int tag)
|
|||
char buf[BUFSIZ];
|
||||
int num = 0;
|
||||
|
||||
buf[0] = '\0';
|
||||
switch (tag) {
|
||||
case RPMTAG_SOURCE:
|
||||
flag = RPMBUILD_ISSOURCE;
|
||||
|
@ -281,7 +280,7 @@ int addSource(Spec spec, Package pkg, const char *field, int tag)
|
|||
|
||||
nump = buf;
|
||||
SKIPSPACE(nump);
|
||||
if (! *nump) {
|
||||
if (nump == NULL || *nump == '\0') {
|
||||
num = 0;
|
||||
} else {
|
||||
if (parseNum(buf, &num)) {
|
||||
|
@ -315,7 +314,9 @@ int addSource(Spec spec, Package pkg, const char *field, int tag)
|
|||
spec->numSources++;
|
||||
|
||||
if (tag != RPMTAG_ICON) {
|
||||
/*@-nullpass@*/ /* LCL: varargs needs null annotate. */
|
||||
const char *body = rpmGetPath("%{_sourcedir}/", p->source, NULL);
|
||||
/*@=nullpass@*/
|
||||
|
||||
sprintf(buf, "%s%d",
|
||||
(flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num);
|
||||
|
@ -331,9 +332,9 @@ int addSource(Spec spec, Package pkg, const char *field, int tag)
|
|||
|
||||
/**
|
||||
*/
|
||||
static inline struct speclines * newSl(void)
|
||||
static inline /*@only@*/ /*@null@*/ struct speclines * newSl(void)
|
||||
{
|
||||
struct speclines *sl = NULL;
|
||||
struct speclines * sl = NULL;
|
||||
if (specedit) {
|
||||
sl = xmalloc(sizeof(struct speclines));
|
||||
sl->sl_lines = NULL;
|
||||
|
@ -345,7 +346,7 @@ static inline struct speclines * newSl(void)
|
|||
|
||||
/**
|
||||
*/
|
||||
static inline void freeSl(/*@only@*/struct speclines *sl)
|
||||
static inline void freeSl(/*@only@*/ /*@null@*/ struct speclines * sl)
|
||||
{
|
||||
int i;
|
||||
if (sl == NULL)
|
||||
|
@ -360,7 +361,7 @@ static inline void freeSl(/*@only@*/struct speclines *sl)
|
|||
|
||||
/**
|
||||
*/
|
||||
static inline struct spectags * newSt(void)
|
||||
static inline /*@only@*/ /*@null@*/ struct spectags * newSt(void)
|
||||
{
|
||||
struct spectags *st = NULL;
|
||||
if (specedit) {
|
||||
|
@ -374,7 +375,7 @@ static inline struct spectags * newSt(void)
|
|||
|
||||
/**
|
||||
*/
|
||||
static inline void freeSt(/*@only@*/struct spectags *st)
|
||||
static inline void freeSt(/*@only@*/ /*@null@*/ struct spectags *st)
|
||||
{
|
||||
int i;
|
||||
if (st == NULL)
|
||||
|
@ -497,6 +498,7 @@ void freeSpec(/*@only@*/ Spec spec)
|
|||
spec->buildRestrictions = NULL;
|
||||
|
||||
if (!spec->inBuildArchitectures) {
|
||||
if (spec->buildArchitectureSpecs != NULL)
|
||||
while (spec->buildArchitectureCount--) {
|
||||
/*@-unqualifiedtrans@*/
|
||||
freeSpec(
|
||||
|
@ -513,8 +515,10 @@ void freeSpec(/*@only@*/ Spec spec)
|
|||
spec->cookie = _free(spec->cookie);
|
||||
|
||||
freeSources(spec->sources); spec->sources = NULL;
|
||||
/*@-nullstate@*/ /* FIX: non-null pointers, shrug. */
|
||||
freePackages(spec);
|
||||
closeSpec(spec);
|
||||
/*@=nullstate@*/
|
||||
|
||||
spec = _free(spec);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
# not-yet normal parameters
|
||||
-boolops # ~831 w->n
|
||||
#-null # ~267
|
||||
-predboolint # ~576 w->n
|
||||
-type # ~872
|
||||
|
||||
|
|
|
@ -57,9 +57,9 @@ getdate.c: getdate.y
|
|||
@echo expect 10 shift/reduce conflicts
|
||||
$(YACC) $(srcdir)/getdate.y
|
||||
-@if test -f y.tab.c; then \
|
||||
{ echo "/*@-globstate -retvalint -unqualifiedtrans -usedef -varuse@*/";\
|
||||
{ echo "/*@-globstate -retvalint -unqualifiedtrans -usedef -varuse -nullderef@*/";\
|
||||
cat y.tab.c ;\
|
||||
echo "/*@=globstate =retvalint =unqualifiedtrans =usedef =varuse@*/";\
|
||||
echo "/*@=globstate =retvalint =unqualifiedtrans =usedef =varuse =nullderef@*/";\
|
||||
} > getdate.c ;\
|
||||
rm -f y.tab.c; \
|
||||
else \
|
||||
|
@ -72,7 +72,10 @@ getdate.c: getdate.y
|
|||
|
||||
BUILT_SOURCES = tagtable.c getdate.c
|
||||
|
||||
.PHONY: lclint
|
||||
.PHONY: sources
|
||||
sources:
|
||||
@echo $(librpm_la_SOURCES:%=lib/%)
|
||||
|
||||
.PHONY: lclint
|
||||
lclint:
|
||||
lclint $(DEFS) $(INCLUDES) $(librpm_la_SOURCES)
|
||||
|
|
|
@ -310,7 +310,9 @@ if (keylen) *keylen = key.size;
|
|||
if (datalen) *datalen = data.size;
|
||||
}
|
||||
|
||||
/*@-nullstate@*/
|
||||
return rc;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
/*@=compmempass@*/
|
||||
|
||||
|
@ -335,6 +337,7 @@ static int db1cdel(dbiIndex dbi, /*@unused@*/ DBC * dbcursor, const void * keyp,
|
|||
/*@=usedef@*/
|
||||
key.size = keylen;
|
||||
|
||||
if (db)
|
||||
rc = db->del(db, &key, 0);
|
||||
rc = cvtdberr(dbi, "db->del", rc, _debug);
|
||||
}
|
||||
|
@ -382,6 +385,7 @@ static int db1cput(dbiIndex dbi, /*@unused@*/ DBC * dbcursor,
|
|||
} else {
|
||||
DB * db = dbi->dbi_db;
|
||||
|
||||
if (db)
|
||||
rc = db->put(db, &key, &data, 0);
|
||||
rc = cvtdberr(dbi, "db->put", rc, _debug);
|
||||
}
|
||||
|
@ -495,7 +499,7 @@ static int db1open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
|
|||
exit:
|
||||
if (rc == 0 && dbi->dbi_db != NULL && dbip) {
|
||||
dbi->dbi_vec = &db1vec;
|
||||
*dbip = dbi;
|
||||
if (dbip) *dbip = dbi;
|
||||
} else
|
||||
(void) db1close(dbi, 0);
|
||||
|
||||
|
|
54
lib/db3.c
54
lib/db3.c
|
@ -109,8 +109,9 @@ static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit) {
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int db_fini(dbiIndex dbi, const char * dbhome, const char * dbfile,
|
||||
/*@unused@*/ const char * dbsubfile)
|
||||
static int db_fini(dbiIndex dbi, const char * dbhome,
|
||||
/*@null@*/ const char * dbfile,
|
||||
/*@unused@*/ /*@null@*/ const char * dbsubfile)
|
||||
{
|
||||
rpmdb rpmdb = dbi->dbi_rpmdb;
|
||||
DB_ENV * dbenv = dbi->dbi_dbenv;
|
||||
|
@ -161,8 +162,10 @@ static int db3_fsync_disable(/*@unused@*/ int fd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int db_init(dbiIndex dbi, const char *dbhome, const char *dbfile,
|
||||
/*@unused@*/ const char * dbsubfile, /*@out@*/ DB_ENV **dbenvp)
|
||||
static int db_init(dbiIndex dbi, const char *dbhome,
|
||||
/*@null@*/ const char *dbfile,
|
||||
/*@unused@*/ /*@null@*/ const char * dbsubfile,
|
||||
/*@out@*/ DB_ENV **dbenvp)
|
||||
{
|
||||
rpmdb rpmdb = dbi->dbi_rpmdb;
|
||||
DB_ENV *dbenv = NULL;
|
||||
|
@ -189,18 +192,21 @@ static int db_init(dbiIndex dbi, const char *dbhome, const char *dbfile,
|
|||
goto errxit;
|
||||
|
||||
#if defined(__USE_DB3)
|
||||
if (dbenv == NULL)
|
||||
return 1;
|
||||
|
||||
{ int xx;
|
||||
dbenv->set_errcall(dbenv, rpmdb->db_errcall);
|
||||
dbenv->set_errfile(dbenv, rpmdb->db_errfile);
|
||||
dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
|
||||
/* dbenv->set_paniccall(???) */
|
||||
dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
|
||||
(void) dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
|
||||
(dbi->dbi_verbose & DB_VERB_CHKPOINT));
|
||||
dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
|
||||
(void) dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
|
||||
(dbi->dbi_verbose & DB_VERB_DEADLOCK));
|
||||
dbenv->set_verbose(dbenv, DB_VERB_RECOVERY,
|
||||
(void) dbenv->set_verbose(dbenv, DB_VERB_RECOVERY,
|
||||
(dbi->dbi_verbose & DB_VERB_RECOVERY));
|
||||
dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
|
||||
(void) dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
|
||||
(dbi->dbi_verbose & DB_VERB_WAITSFOR));
|
||||
/* dbenv->set_lg_max(???) */
|
||||
/* dbenv->set_lk_conflicts(???) */
|
||||
|
@ -269,11 +275,12 @@ errxit:
|
|||
static int db3sync(dbiIndex dbi, unsigned int flags)
|
||||
{
|
||||
DB * db = dbi->dbi_db;
|
||||
int rc;
|
||||
int rc = 0;
|
||||
|
||||
#if defined(__USE_DB2) || defined(__USE_DB3)
|
||||
int _printit;
|
||||
|
||||
if (db != NULL)
|
||||
rc = db->sync(db, flags);
|
||||
/* XXX DB_INCOMPLETE is returned occaisionally with multiple access. */
|
||||
_printit = (rc == DB_INCOMPLETE ? 0 : _debug);
|
||||
|
@ -337,10 +344,12 @@ static int db3c_put(dbiIndex dbi, DBC * dbcursor,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static inline int db3c_close(dbiIndex dbi, /*@only@*/ DBC * dbcursor)
|
||||
static inline int db3c_close(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (dbcursor == NULL) return -2;
|
||||
|
||||
rc = dbcursor->c_close(dbcursor);
|
||||
rc = cvtdberr(dbi, "dbcursor->c_close", rc, _debug);
|
||||
return rc;
|
||||
|
@ -353,6 +362,7 @@ static inline int db3c_open(dbiIndex dbi, /*@out@*/ DBC ** dbcp)
|
|||
int flags;
|
||||
int rc;
|
||||
|
||||
if (db == NULL) return -2;
|
||||
#if defined(__USE_DB3)
|
||||
if ((dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY))
|
||||
flags = DB_WRITECURSOR;
|
||||
|
@ -367,7 +377,7 @@ static inline int db3c_open(dbiIndex dbi, /*@out@*/ DBC ** dbcp)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int db3cclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor,
|
||||
static int db3cclose(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor,
|
||||
unsigned int flags)
|
||||
{
|
||||
int rc = 0;
|
||||
|
@ -432,6 +442,7 @@ static int db3cput(dbiIndex dbi, DBC * dbcursor,
|
|||
data.size = datalen;
|
||||
|
||||
if (dbcursor == NULL) {
|
||||
if (db == NULL) return -2;
|
||||
rc = db->put(db, txnid, &key, &data, 0);
|
||||
rc = cvtdberr(dbi, "db->put", rc, _debug);
|
||||
} else {
|
||||
|
@ -459,6 +470,7 @@ static int db3cdel(dbiIndex dbi, DBC * dbcursor,
|
|||
key.size = keylen;
|
||||
|
||||
if (dbcursor == NULL) {
|
||||
if (db == NULL) return -2;
|
||||
rc = db->del(db, txnid, &key, 0);
|
||||
rc = cvtdberr(dbi, "db->del", rc, _debug);
|
||||
} else {
|
||||
|
@ -496,6 +508,9 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor,
|
|||
|
||||
if (dbcursor == NULL) {
|
||||
int _printit;
|
||||
/*@-compmempass@*/
|
||||
if (db == NULL) return -2;
|
||||
/*@=compmempass@*/
|
||||
rc = db->get(db, txnid, &key, &data, 0);
|
||||
/* XXX DB_NOTFOUND can be returned */
|
||||
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
|
||||
|
@ -517,9 +532,9 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor,
|
|||
/*@=onlytrans@*/
|
||||
}
|
||||
|
||||
/*@-compmempass@*/
|
||||
/*@-compmempass -nullstate@*/
|
||||
return rc;
|
||||
/*@=compmempass@*/
|
||||
/*@=compmempass =nullstate@*/
|
||||
}
|
||||
|
||||
static int db3byteswapped(dbiIndex dbi)
|
||||
|
@ -528,6 +543,7 @@ static int db3byteswapped(dbiIndex dbi)
|
|||
int rc = 0;
|
||||
|
||||
#if defined(__USE_DB3)
|
||||
if (db != NULL)
|
||||
rc = db->get_byteswapped(db);
|
||||
#endif /* __USE_DB3 */
|
||||
|
||||
|
@ -583,7 +599,9 @@ static int db3close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
|
|||
}
|
||||
|
||||
if (dbi->dbi_use_dbenv)
|
||||
xx = db_fini(dbi, dbhome, dbfile, dbsubfile);
|
||||
/*@-nullstate@*/
|
||||
xx = db_fini(dbi, (dbhome ? dbhome : ""), dbfile, dbsubfile);
|
||||
/*@=nullstate@*/
|
||||
|
||||
#else /* __USE_DB2 || __USE_DB3 */
|
||||
|
||||
|
@ -622,7 +640,9 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
|
|||
if (dbip)
|
||||
*dbip = NULL;
|
||||
if ((dbi = db3New(rpmdb, rpmtag)) == NULL)
|
||||
/*@-nullstate@*/
|
||||
return 1;
|
||||
/*@=nullstate@*/
|
||||
dbi->dbi_api = DB_VERSION_MAJOR;
|
||||
|
||||
urlfn = rpmGenPath(
|
||||
|
@ -671,7 +691,7 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
|
|||
#if defined(__USE_DB3)
|
||||
rc = db_create(&db, dbenv, dbi->dbi_cflags);
|
||||
rc = cvtdberr(dbi, "db_create", rc, _debug);
|
||||
if (rc == 0) {
|
||||
if (rc == 0 && db != NULL) {
|
||||
if (dbi->dbi_lorder) {
|
||||
rc = db->set_lorder(db, dbi->dbi_lorder);
|
||||
rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
|
||||
|
@ -776,7 +796,7 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
|
|||
_("cannot get %s lock on %s/%s\n"),
|
||||
((dbi->dbi_mode & O_RDWR)
|
||||
? _("exclusive") : _("shared")),
|
||||
dbhome, dbfile);
|
||||
dbhome, (dbfile ? dbfile : ""));
|
||||
rc = 1;
|
||||
} else if (dbfile) {
|
||||
rpmMessage(RPMMESS_DEBUG,
|
||||
|
@ -838,7 +858,9 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
|
|||
|
||||
urlfn = _free(urlfn);
|
||||
|
||||
/*@-nullstate@*/
|
||||
return rc;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
|
||||
/** \ingroup db3
|
||||
|
|
|
@ -156,7 +156,8 @@ static void alFree(struct availableList * al)
|
|||
rpmRelocation * r;
|
||||
int i;
|
||||
|
||||
for (i = 0, p = al->list; i < al->size; i++, p++) {
|
||||
if ((p = al->list) != NULL)
|
||||
for (i = 0; i < al->size; i++, p++) {
|
||||
|
||||
{ struct tsortInfo * tsi;
|
||||
while ((tsi = p->tsi.tsi_next) != NULL) {
|
||||
|
@ -184,15 +185,16 @@ static void alFree(struct availableList * al)
|
|||
p->fd = fdFree(p->fd, "alAddPackage (alFree)");
|
||||
}
|
||||
|
||||
if (al->dirs != NULL)
|
||||
for (i = 0; i < al->numDirs; i++) {
|
||||
al->dirs[i].dirName = _free(al->dirs[i].dirName);
|
||||
al->dirs[i].files = _free(al->dirs[i].files);
|
||||
}
|
||||
|
||||
if (al->numDirs && al->dirs)
|
||||
al->dirs = _free(al->dirs);
|
||||
if (al->alloced && al->list)
|
||||
al->numDirs = 0;
|
||||
al->list = _free(al->list);
|
||||
al->alloced = 0;
|
||||
alFreeIndex(al);
|
||||
}
|
||||
|
||||
|
@ -429,7 +431,7 @@ static void alMakeIndex(struct availableList * al)
|
|||
struct availableIndex * ai = &al->index;
|
||||
int i, j, k;
|
||||
|
||||
if (ai->size) return;
|
||||
if (ai->size || al->list == NULL) return;
|
||||
|
||||
for (i = 0; i < al->size; i++)
|
||||
ai->size += al->list[i].providesCount;
|
||||
|
@ -777,6 +779,9 @@ int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd,
|
|||
ts->order = xrealloc(ts->order, sizeof(*ts->order) * ts->orderAlloced);
|
||||
}
|
||||
ts->order[ts->orderCount].type = TR_ADDED;
|
||||
if (ts->addedPackages.list == NULL)
|
||||
return 0;
|
||||
|
||||
alNum = alAddPackage(&ts->addedPackages, h, key, fd, relocs) -
|
||||
ts->addedPackages.list;
|
||||
ts->order[ts->orderCount++].u.addedIndex = alNum;
|
||||
|
@ -920,31 +925,37 @@ alFileSatisfiesDepend(struct availableList * al,
|
|||
struct dirInfo_s dirNeedle;
|
||||
dirInfo dirMatch;
|
||||
|
||||
if (al->numDirs == 0) /* Solaris 2.6 bsearch sucks down on this. */
|
||||
/* Solaris 2.6 bsearch sucks down on this. */
|
||||
if (al->numDirs == 0 || al->dirs == NULL || al->list == NULL)
|
||||
return NULL;
|
||||
|
||||
{ char * chptr = xstrdup(fileName);
|
||||
dirName = chptr;
|
||||
chptr = strrchr(chptr, '/');
|
||||
chptr++;
|
||||
if ((chptr = strrchr(chptr, '/')) != NULL) {
|
||||
chptr++; /* leave the trailing '/' */
|
||||
*chptr = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
dirNeedle.dirName = (char *) dirName;
|
||||
dirNeedle.dirNameLen = strlen(dirName);
|
||||
dirMatch = bsearch(&dirNeedle, al->dirs, al->numDirs,
|
||||
sizeof(dirNeedle), dirInfoCompare);
|
||||
dirName = _free(dirName);
|
||||
if (!dirMatch) return NULL;
|
||||
if (dirMatch == NULL) return NULL;
|
||||
|
||||
baseName = strrchr(fileName, '/') + 1;
|
||||
|
||||
/* XXX FIXME: these file lists should be sorted and bsearched */
|
||||
for (i = 0; i < dirMatch->numFiles; i++) {
|
||||
if (!strcmp(dirMatch->files[i].baseName, baseName)) {
|
||||
if (dirMatch->files[i].baseName == NULL ||
|
||||
strcmp(dirMatch->files[i].baseName, baseName))
|
||||
continue;
|
||||
|
||||
/* If a file dependency would be satisfied by a file
|
||||
we are not going to install, skip it. */
|
||||
/*
|
||||
* If a file dependency would be satisfied by a file
|
||||
* we are not going to install, skip it.
|
||||
*/
|
||||
if (al->list[dirMatch->files[i].pkgNum].multiLib &&
|
||||
!isFileMULTILIB(dirMatch->files[i].fileFlags))
|
||||
continue;
|
||||
|
@ -954,7 +965,6 @@ alFileSatisfiesDepend(struct availableList * al,
|
|||
keyType, fileName);
|
||||
return al->list + dirMatch->files[i].pkgNum;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -981,7 +991,7 @@ alFileSatisfiesDepend(struct availableList * al,
|
|||
if (*keyName == '/')
|
||||
return alFileSatisfiesDepend(al, keyType, keyName);
|
||||
|
||||
if (!al->index.size) return NULL;
|
||||
if (!al->index.size || al->index.index == NULL) return NULL;
|
||||
|
||||
needle.entry = keyName;
|
||||
needle.entryLen = strlen(keyName);
|
||||
|
@ -1078,7 +1088,9 @@ static int unsatisfiedDepend(rpmTransactionSet ts,
|
|||
if (!(keyFlags & RPMSENSE_SENSEMASK) &&
|
||||
(rcProvidesString = rpmGetVar(RPMVAR_PROVIDES))) {
|
||||
i = strlen(keyName);
|
||||
/*@-nullpass -observertrans -mayaliasunique@*/
|
||||
while ((start = strstr(rcProvidesString, keyName))) {
|
||||
/*@=nullpass =observertrans =mayaliasunique@*/
|
||||
if (xisspace(start[i]) || start[i] == '\0' || start[i] == ',') {
|
||||
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (rpmrc provides)\n"),
|
||||
keyType, keyDepend+2);
|
||||
|
@ -1457,12 +1469,12 @@ static void markLoop(struct tsortInfo * tsi, struct availablePackage * q)
|
|||
{
|
||||
struct availablePackage * p;
|
||||
|
||||
while (tsi != NULL) {
|
||||
p = tsi->tsi_suc;
|
||||
while (tsi != NULL && (p = tsi->tsi_suc) != NULL) {
|
||||
tsi = tsi->tsi_next;
|
||||
if (p->tsi.tsi_pkg != NULL)
|
||||
continue;
|
||||
p->tsi.tsi_pkg = q;
|
||||
if (p->tsi.tsi_next != NULL)
|
||||
markLoop(p->tsi.tsi_next, p);
|
||||
}
|
||||
}
|
||||
|
@ -1505,16 +1517,21 @@ zapRelation(struct availablePackage * q, struct availablePackage * p,
|
|||
struct tsortInfo * tsi;
|
||||
const char *dp = NULL;
|
||||
|
||||
if (q == NULL)
|
||||
return dp;
|
||||
for (tsi_prev = &q->tsi, tsi = q->tsi.tsi_next;
|
||||
tsi != NULL;
|
||||
/* XXX Note: the loop traverses "not found", break on "found". */
|
||||
/*@-nullderef@*/
|
||||
tsi_prev = tsi, tsi = tsi->tsi_next)
|
||||
/*@=nullderef@*/
|
||||
{
|
||||
int j;
|
||||
|
||||
if (tsi->tsi_suc != p)
|
||||
continue;
|
||||
if (p->requires == NULL) continue; /* XXX can't happen */
|
||||
if (p->requireFlags == NULL) continue; /* XXX can't happen */
|
||||
if (p->requiresEVR == NULL) continue; /* XXX can't happen */
|
||||
|
||||
j = tsi->tsi_reqx;
|
||||
dp = printDepend( identifyDepend(p->requireFlags[j]),
|
||||
p->requires[j], p->requiresEVR[j], p->requireFlags[j]);
|
||||
|
@ -1532,7 +1549,9 @@ zapRelation(struct availablePackage * q, struct availablePackage * p,
|
|||
_("removing %s-%s-%s \"%s\" from tsort relations.\n"),
|
||||
p->name, p->version, p->release, dp);
|
||||
p->tsi.tsi_count--;
|
||||
/*@-nullderef@*/
|
||||
tsi_prev->tsi_next = tsi->tsi_next;
|
||||
/*@=nullderef@*/
|
||||
tsi->tsi_next = NULL;
|
||||
tsi->tsi_suc = NULL;
|
||||
tsi = _free(tsi);
|
||||
|
@ -1541,6 +1560,7 @@ zapRelation(struct availablePackage * q, struct availablePackage * p,
|
|||
if (zap)
|
||||
zap--;
|
||||
}
|
||||
/* XXX Note: the loop traverses "not found", get out now! */
|
||||
break;
|
||||
}
|
||||
return dp;
|
||||
|
@ -1561,6 +1581,7 @@ static inline int addRelation( const rpmTransactionSet ts,
|
|||
struct tsortInfo * tsi;
|
||||
int matchNum;
|
||||
|
||||
/*@-nullderef@*/
|
||||
q = alSatisfiesDepend(&ts->addedPackages, NULL, NULL,
|
||||
p->requires[j], p->requiresEVR[j], p->requireFlags[j]);
|
||||
|
||||
|
@ -1571,6 +1592,7 @@ static inline int addRelation( const rpmTransactionSet ts,
|
|||
/* Avoid rpmlib feature dependencies. */
|
||||
if (!strncmp(p->requires[j], "rpmlib(", sizeof("rpmlib(")-1))
|
||||
return 0;
|
||||
/*@=nullderef@*/
|
||||
|
||||
#if defined(DEPENDENCY_WHITEOUT)
|
||||
/* Avoid certain dependency relations. */
|
||||
|
@ -1673,7 +1695,8 @@ int rpmdepOrder(rpmTransactionSet ts)
|
|||
|
||||
/* Record all relations. */
|
||||
rpmMessage(RPMMESS_DEBUG, _("========== recording tsort relations\n"));
|
||||
for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++) {
|
||||
if ((p = ts->addedPackages.list) != NULL)
|
||||
for (i = 0; i < npkgs; i++, p++) {
|
||||
int matchNum;
|
||||
|
||||
if (p->requiresCount <= 0)
|
||||
|
@ -1690,6 +1713,8 @@ int rpmdepOrder(rpmTransactionSet ts)
|
|||
/* First, do pre-requisites. */
|
||||
for (j = 0; j < p->requiresCount; j++) {
|
||||
|
||||
if (p->requireFlags == NULL) continue; /* XXX can't happen */
|
||||
|
||||
/* Skip if not %pre/%post requires or legacy prereq. */
|
||||
|
||||
if (isErasePreReq(p->requireFlags[j]) ||
|
||||
|
@ -1705,6 +1730,8 @@ int rpmdepOrder(rpmTransactionSet ts)
|
|||
/* Then do co-requisites. */
|
||||
for (j = 0; j < p->requiresCount; j++) {
|
||||
|
||||
if (p->requireFlags == NULL) continue; /* XXX can't happen */
|
||||
|
||||
/* Skip if %pre/%post requires or legacy prereq. */
|
||||
|
||||
if (isErasePreReq(p->requireFlags[j]) ||
|
||||
|
@ -1719,7 +1746,8 @@ int rpmdepOrder(rpmTransactionSet ts)
|
|||
}
|
||||
|
||||
/* Save predecessor count. */
|
||||
for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++) {
|
||||
if ((p = ts->addedPackages.list) != NULL)
|
||||
for (i = 0; i < npkgs; i++, p++) {
|
||||
p->npreds = p->tsi.tsi_count;
|
||||
}
|
||||
|
||||
|
@ -1729,7 +1757,8 @@ int rpmdepOrder(rpmTransactionSet ts)
|
|||
rescan:
|
||||
q = r = NULL;
|
||||
qlen = 0;
|
||||
for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++) {
|
||||
if ((p = ts->addedPackages.list) != NULL)
|
||||
for (i = 0; i < npkgs; i++, p++) {
|
||||
|
||||
/* Prefer packages in presentation order. */
|
||||
if (!chainsaw)
|
||||
|
@ -1762,10 +1791,12 @@ rescan:
|
|||
tsi_next = tsi->tsi_next;
|
||||
tsi->tsi_next = NULL;
|
||||
p = tsi->tsi_suc;
|
||||
if ((--p->tsi.tsi_count) <= 0) {
|
||||
if (p && (--p->tsi.tsi_count) <= 0) {
|
||||
/* XXX FIXME: add control bit. */
|
||||
p->tsi.tsi_suc = NULL;
|
||||
/*@-nullstate@*/
|
||||
addQ(p, &q->tsi.tsi_suc, &r);
|
||||
/*@=nullstate@*/
|
||||
qlen++;
|
||||
}
|
||||
tsi = _free(tsi);
|
||||
|
@ -1783,7 +1814,8 @@ rescan:
|
|||
|
||||
/* T9. Initialize predecessor chain. */
|
||||
nzaps = 0;
|
||||
for (i = 0, q = ts->addedPackages.list; i < npkgs; i++, q++) {
|
||||
if ((q = ts->addedPackages.list) != NULL)
|
||||
for (i = 0; i < npkgs; i++, q++) {
|
||||
q->tsi.tsi_pkg = NULL;
|
||||
q->tsi.tsi_reqx = 0;
|
||||
/* Mark packages already sorted. */
|
||||
|
@ -1792,7 +1824,8 @@ rescan:
|
|||
}
|
||||
|
||||
/* T10. Mark all packages with their predecessors. */
|
||||
for (i = 0, q = ts->addedPackages.list; i < npkgs; i++, q++) {
|
||||
if ((q = ts->addedPackages.list) != NULL)
|
||||
for (i = 0; i < npkgs; i++, q++) {
|
||||
if ((tsi = q->tsi.tsi_next) == NULL)
|
||||
continue;
|
||||
q->tsi.tsi_next = NULL;
|
||||
|
@ -1801,7 +1834,8 @@ rescan:
|
|||
}
|
||||
|
||||
/* T11. Print all dependency loops. */
|
||||
for (i = 0, r = ts->addedPackages.list; i < npkgs; i++, r++) {
|
||||
if ((r = ts->addedPackages.list) != NULL)
|
||||
for (i = 0; i < npkgs; i++, r++) {
|
||||
int printed;
|
||||
|
||||
printed = 0;
|
||||
|
@ -1831,7 +1865,8 @@ rescan:
|
|||
|
||||
/* Print next member of loop. */
|
||||
sprintf(buf, "%s-%s-%s", p->name, p->version, p->release);
|
||||
rpmMessage(RPMMESS_WARNING, " %-40s %s\n", buf, dp);
|
||||
rpmMessage(RPMMESS_WARNING, " %-40s %s\n", buf,
|
||||
(dp ? dp : "not found!?!"));
|
||||
|
||||
dp = _free(dp);
|
||||
}
|
||||
|
@ -1881,6 +1916,7 @@ rescan:
|
|||
key.alIndex = ordering[i];
|
||||
needle = bsearch(&key, orderList, npkgs, sizeof(key),orderListIndexCmp);
|
||||
/* bsearch should never, ever fail */
|
||||
if (needle == NULL) continue;
|
||||
|
||||
newOrder[newOrderCount++] = ts->order[needle->orIndex];
|
||||
for (j = needle->orIndex + 1; j < ts->orderCount; j++) {
|
||||
|
@ -1938,7 +1974,8 @@ int rpmdepCheck(rpmTransactionSet ts,
|
|||
* Look at all of the added packages and make sure their dependencies
|
||||
* are satisfied.
|
||||
*/
|
||||
for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++)
|
||||
if ((p = ts->addedPackages.list) != NULL)
|
||||
for (i = 0; i < npkgs; i++, p++)
|
||||
{
|
||||
|
||||
rpmMessage(RPMMESS_DEBUG, ("========== +++ %s-%s-%s\n"),
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
struct tsortInfo {
|
||||
union {
|
||||
int count;
|
||||
/*@kept@*/ struct availablePackage * suc;
|
||||
/*@kept@*//*@null@*/ struct availablePackage * suc;
|
||||
} tsi_u;
|
||||
#define tsi_count tsi_u.count
|
||||
#define tsi_suc tsi_u.suc
|
||||
/*@owned@*/ struct tsortInfo * tsi_next;
|
||||
/*@kept@*/ struct availablePackage * tsi_pkg;
|
||||
/*@owned@*//*@null@*/ struct tsortInfo * tsi_next;
|
||||
/*@kept@*//*@null@*/ struct availablePackage * tsi_pkg;
|
||||
int tsi_reqx;
|
||||
int tsi_qcnt;
|
||||
} ;
|
||||
|
@ -35,11 +35,11 @@ struct availablePackage {
|
|||
/*@owned@*/ const char ** provides; /*!< Provides: name strings. */
|
||||
/*@owned@*/ const char ** providesEVR; /*!< Provides: [epoch:]version[-release] strings. */
|
||||
/*@dependent@*/ int * provideFlags; /*!< Provides: logical range qualifiers. */
|
||||
/*@owned@*/ const char ** requires; /*!< Requires: name strings. */
|
||||
/*@owned@*/ const char ** requiresEVR; /*!< Requires: [epoch:]version[-release] strings. */
|
||||
/*@dependent@*/ int * requireFlags; /*!< Requires: logical range qualifiers. */
|
||||
/*@owned@*/ const char ** baseNames; /*!< Header file basenames. */
|
||||
/*@dependent@*/ int_32 * epoch; /*!< Header epoch (if any). */
|
||||
/*@owned@*//*@null@*/ const char ** requires; /*!< Requires: name strings. */
|
||||
/*@owned@*//*@null@*/ const char ** requiresEVR;/*!< Requires: [epoch:]version[-release] strings. */
|
||||
/*@dependent@*//*@null@*/ int * requireFlags; /*!< Requires: logical range qualifiers. */
|
||||
/*@owned@*//*@null@*/ const char ** baseNames; /*!< Header file basenames. */
|
||||
/*@dependent@*//*@null@*/ int_32 * epoch; /*!< Header epoch (if any). */
|
||||
int providesCount; /*!< No. of Provide:'s in header. */
|
||||
int requiresCount; /*!< No. of Require:'s in header. */
|
||||
int filesCount; /*!< No. of files in header. */
|
||||
|
@ -47,8 +47,8 @@ struct availablePackage {
|
|||
int depth; /*!< Max. depth in dependency tree. */
|
||||
struct tsortInfo tsi; /*!< Dependency tsort data. */
|
||||
uint_32 multiLib; /* MULTILIB */
|
||||
/*@kept@*/ const void * key; /*!< Private data associated with a package (e.g. file name of package). */
|
||||
rpmRelocation * relocs;
|
||||
/*@kept@*//*@null@*/ const void * key; /*!< Private data associated with a package (e.g. file name of package). */
|
||||
/*@null@*/ rpmRelocation * relocs;
|
||||
/*@null@*/ FD_t fd;
|
||||
} ;
|
||||
|
||||
|
@ -78,7 +78,7 @@ struct availableIndex {
|
|||
struct fileIndexEntry {
|
||||
int pkgNum; /*!< Containing package number. */
|
||||
int fileFlags; /* MULTILIB */
|
||||
/*@dependent@*/ const char * baseName; /*!< File basename. */
|
||||
/*@dependent@*/ /*@null@*/ const char * baseName; /*!< File basename. */
|
||||
} ;
|
||||
|
||||
/** \ingroup rpmdep
|
||||
|
@ -101,7 +101,7 @@ struct availableList {
|
|||
int size; /*!< No. of pkgs in list. */
|
||||
int alloced; /*!< No. of pkgs allocated for list. */
|
||||
int numDirs; /*!< No. of directories. */
|
||||
/*@owned@*/ dirInfo dirs; /*!< Set of directories. */
|
||||
/*@owned@*/ /*@null@*/ dirInfo dirs; /*!< Set of directories. */
|
||||
} ;
|
||||
|
||||
/** \ingroup rpmdep
|
||||
|
|
11
lib/fprint.c
11
lib/fprint.c
|
@ -97,6 +97,10 @@ static fingerPrint doLookup(fingerPrintCache cache,
|
|||
cdnl = end - dir;
|
||||
}
|
||||
}
|
||||
fp.entry = NULL;
|
||||
fp.subDir = NULL;
|
||||
fp.baseName = NULL;
|
||||
if (cleanDirName == NULL) return fp; /* XXX can't happen */
|
||||
|
||||
buf = strcpy(alloca(cdnl + 1), cleanDirName);
|
||||
end = buf + cdnl;
|
||||
|
@ -107,9 +111,6 @@ static fingerPrint doLookup(fingerPrintCache cache,
|
|||
*end = '\0';
|
||||
}
|
||||
|
||||
fp.entry = NULL;
|
||||
fp.subDir = NULL;
|
||||
fp.baseName = NULL;
|
||||
while (1) {
|
||||
|
||||
/* as we're stating paths here, we want to follow symlinks */
|
||||
|
@ -163,7 +164,7 @@ static fingerPrint doLookup(fingerPrintCache cache,
|
|||
|
||||
/*@notreached@*/
|
||||
|
||||
return fp;
|
||||
/*@-nullret@*/ return fp; /*@=nullret@*/ /* LCL: can't happen. */
|
||||
}
|
||||
|
||||
fingerPrint fpLookup(fingerPrintCache cache, const char * dirName,
|
||||
|
@ -200,8 +201,10 @@ int fpEqual(const void * key1, const void * key2)
|
|||
return 0;
|
||||
|
||||
/* Otherwise, compare fingerprints by value. */
|
||||
/*@-nullpass@*/ /* LCL: whines about (*k2).subdir */
|
||||
if (FP_EQUAL(*k1, *k2))
|
||||
return 0;
|
||||
/*@=nullpass@*/
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
|
2
lib/fs.c
2
lib/fs.c
|
@ -305,7 +305,7 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles
|
|||
|
||||
if (lastDev != sb.st_dev) {
|
||||
for (j = 0; j < numFilesystems; j++)
|
||||
if (filesystems[j].dev == sb.st_dev) break;
|
||||
if (filesystems && filesystems[j].dev == sb.st_dev) break;
|
||||
|
||||
if (j == numFilesystems) {
|
||||
rpmError(RPMERR_BADDEV,
|
||||
|
|
19
lib/fsm.c
19
lib/fsm.c
|
@ -54,6 +54,7 @@ static /*@only@*//*@null@*/ const char * fsmFsPath(/*@null@*/ const FSM_t fsm,
|
|||
if (fsm) {
|
||||
int nb;
|
||||
char * t;
|
||||
/*@-nullpass@*/ /* LCL: subdir/suffix != NULL */
|
||||
nb = strlen(fsm->dirName) +
|
||||
(st && subdir && !S_ISDIR(st->st_mode) ? strlen(subdir) : 0) +
|
||||
(st && suffix && !S_ISDIR(st->st_mode) ? strlen(suffix) : 0) +
|
||||
|
@ -65,6 +66,7 @@ static /*@only@*//*@null@*/ const char * fsmFsPath(/*@null@*/ const FSM_t fsm,
|
|||
t = stpcpy(t, fsm->baseName);
|
||||
if (st && suffix && !S_ISDIR(st->st_mode))
|
||||
t = stpcpy(t, suffix);
|
||||
/*@=nullpass@*/
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
@ -283,10 +285,11 @@ static /*@observer@*/ const char * dnlNextIterator(/*@null@*/ DNLI_t dnli)
|
|||
{
|
||||
const char * dn = NULL;
|
||||
|
||||
if (dnli && dnli->active) {
|
||||
if (dnli) {
|
||||
TFI_t fi = dnli->fi;
|
||||
int i = -1;
|
||||
|
||||
if (dnli->active)
|
||||
do {
|
||||
i = (!dnli->reverse ? dnli->i++ : --dnli->i);
|
||||
} while (i >= 0 && i < fi->dc && !dnli->active[i]);
|
||||
|
@ -384,7 +387,9 @@ fprintf(stderr, "*** %p link[%d:%d] %d filex %d %s\n", fsm->li, fsm->li->linksLe
|
|||
fsm->path = _free(fsm->path);
|
||||
fsm->ix = ix;
|
||||
rc = fsmStage(fsm, FSM_MAP);
|
||||
/*@-nullstate@*/ /* FIX: fsm->path null annotation? */
|
||||
return rc;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
/*@=compmempass@*/
|
||||
|
||||
|
@ -453,7 +458,7 @@ int fsmSetup(FSM_t fsm, fileStage goal,
|
|||
|
||||
memset(fsm->sufbuf, 0, sizeof(fsm->sufbuf));
|
||||
if (fsm->goal == FSM_PKGINSTALL) {
|
||||
if (ts->id > 0)
|
||||
if (ts && ts->id > 0)
|
||||
sprintf(fsm->sufbuf, ";%08x", (unsigned)ts->id);
|
||||
}
|
||||
|
||||
|
@ -480,7 +485,9 @@ int fsmTeardown(FSM_t fsm) {
|
|||
fsm->cfd = NULL;
|
||||
}
|
||||
fsm->failedFile = NULL;
|
||||
/*@-nullstate@*/ /* FIX: fsm->iter null annotation? */
|
||||
return rc;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
|
||||
int fsmMapPath(FSM_t fsm)
|
||||
|
@ -566,8 +573,10 @@ fprintf(stderr, "*** %s:%s %s\n", fiTypeString(fi), fileActionString(fsm->action
|
|||
if ((fsm->mapFlags & CPIO_MAP_PATH) || fsm->nsuffix) {
|
||||
const struct stat * st = &fsm->sb;
|
||||
fsm->path = _free(fsm->path);
|
||||
/*@-nullstate@*/ /* FIX: fsm->path null annotation? */
|
||||
fsm->path = fsmFsPath(fsm, st, fsm->subdir,
|
||||
(fsm->suffix ? fsm->suffix : fsm->nsuffix));
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
|
@ -1473,8 +1482,12 @@ int fsmStage(FSM_t fsm, fileStage stage)
|
|||
if (fsm->diskchecked && fsm->exists && fsm->osuffix) {
|
||||
const char * opath = fsm->opath;
|
||||
const char * path = fsm->path;
|
||||
/*@-nullstate@*/ /* FIX: fsm->opath null annotation? */
|
||||
fsm->opath = fsmFsPath(fsm, st, NULL, NULL);
|
||||
/*@=nullstate@*/
|
||||
/*@-nullstate@*/ /* FIX: fsm->path null annotation? */
|
||||
fsm->path = fsmFsPath(fsm, st, NULL, fsm->osuffix);
|
||||
/*@=nullstate@*/
|
||||
rc = fsmStage(fsm, FSM_RENAME);
|
||||
if (!rc) {
|
||||
rpmMessage(RPMMESS_WARNING, _("%s saved as %s\n"),
|
||||
|
@ -1539,7 +1552,7 @@ int fsmStage(FSM_t fsm, fileStage stage)
|
|||
if (!rc && fsm->nsuffix) {
|
||||
const char * opath = fsmFsPath(fsm, st, NULL, NULL);
|
||||
rpmMessage(RPMMESS_WARNING, _("%s created as %s\n"),
|
||||
opath, fsm->path);
|
||||
(opath ? opath : ""), fsm->path);
|
||||
opath = _free(opath);
|
||||
}
|
||||
fsm->opath = _free(fsm->opath);
|
||||
|
|
|
@ -185,7 +185,7 @@ extern "C" {
|
|||
* Create file state machine instance.
|
||||
* @return file state machine data
|
||||
*/
|
||||
/*@only@*/ /*@null@*/ FSM_t newFSM(void);
|
||||
/*@only@*/ FSM_t newFSM(void);
|
||||
|
||||
/**
|
||||
* Destroy file state machine instance.
|
||||
|
@ -254,7 +254,7 @@ int fsmMapAttrs(FSM_t fsm)
|
|||
* @param stage next stage
|
||||
* @return 0 on success
|
||||
*/
|
||||
int fsmStage(FSM_t fsm, fileStage stage)
|
||||
int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
|
||||
/*@modifies fsm @*/;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -34,7 +34,8 @@ struct hashTable_s {
|
|||
* @param key pointer to key value
|
||||
* @return pointer to hash bucket of key (or NULL)
|
||||
*/
|
||||
static /*@shared@*/ struct hashBucket * findEntry(hashTable ht, const void * key)
|
||||
static /*@shared@*/ /*@null@*/
|
||||
struct hashBucket *findEntry(hashTable ht, const void * key)
|
||||
{
|
||||
unsigned int hash;
|
||||
struct hashBucket * b;
|
||||
|
|
121
lib/header.c
121
lib/header.c
|
@ -87,7 +87,7 @@ struct indexEntry {
|
|||
* The Header data structure.
|
||||
*/
|
||||
struct headerToken {
|
||||
/*@owned@*/ struct indexEntry *index; /*!< Array of tags. */
|
||||
/*@owned@*/ struct indexEntry * index; /*!< Array of tags. */
|
||||
int indexUsed; /*!< Current size of tag array. */
|
||||
int indexAlloced; /*!< Allocated size of tag array. */
|
||||
int region_allocated; /*!< Is 1st header region allocated? */
|
||||
|
@ -99,13 +99,13 @@ struct headerToken {
|
|||
/**
|
||||
*/
|
||||
struct sprintfTag {
|
||||
headerTagTagFunction ext; /*!< if NULL tag element is invalid */
|
||||
/*@null@*/ headerTagTagFunction ext; /*!< if NULL tag element is invalid */
|
||||
int extNum;
|
||||
int_32 tag;
|
||||
int justOne;
|
||||
int arrayCount;
|
||||
/*@kept@*/ char * format;
|
||||
/*@kept@*/ char * type;
|
||||
/*@kept@*/ /*@null@*/ char * type;
|
||||
int pad;
|
||||
};
|
||||
|
||||
|
@ -140,9 +140,9 @@ struct sprintfToken {
|
|||
int len;
|
||||
} string;
|
||||
struct {
|
||||
/*@only@*/ struct sprintfToken * ifFormat;
|
||||
/*@only@*/ /*@null@*/ struct sprintfToken * ifFormat;
|
||||
int numIfTokens;
|
||||
/*@only@*/ struct sprintfToken * elseFormat;
|
||||
/*@only@*/ /*@null@*/ struct sprintfToken * elseFormat;
|
||||
int numElseTokens;
|
||||
struct sprintfTag tag;
|
||||
} cond;
|
||||
|
@ -238,7 +238,7 @@ static int dataLength(int_32 type, const void * p, int_32 count, int onDisk)
|
|||
* @param regionid region offset
|
||||
* @return no. bytes of data in region
|
||||
*/
|
||||
static int regionSwab(struct indexEntry * entry, int il, int dl,
|
||||
static int regionSwab(/*@null@*/ struct indexEntry * entry, int il, int dl,
|
||||
const struct entryInfo * pe, char * dataStart, int regionid)
|
||||
{
|
||||
char * tprev = NULL;
|
||||
|
@ -315,8 +315,11 @@ assert(ie.info.type >= RPM_MIN_TYPE && ie.info.type <= RPM_MAX_TYPE);
|
|||
* @retval c address of count (or NULL)
|
||||
* @param minMem string pointers refer to header memory?
|
||||
*/
|
||||
static void copyEntry(const struct indexEntry * entry, /*@out@*/ int_32 * type,
|
||||
/*@out@*/ const void ** p, /*@out@*/ int_32 * c, int minMem)
|
||||
static void copyEntry(const struct indexEntry * entry,
|
||||
/*@null@*/ /*@out@*/ int_32 * type,
|
||||
/*@null@*/ /*@out@*/ const void ** p,
|
||||
/*@null@*/ /*@out@*/ int_32 * c,
|
||||
int minMem)
|
||||
/*@modifies *type, *p, *c @*/
|
||||
{
|
||||
int_32 count = entry->info.count;
|
||||
|
@ -481,7 +484,7 @@ Header headerCopy(Header h)
|
|||
headerNextIterator(hi, &tag, &type, &ptr, &count);
|
||||
ptr = headerFreeData((void *)ptr, type))
|
||||
{
|
||||
(void) headerAddEntry(nh, tag, type, ptr, count);
|
||||
if (ptr) (void) headerAddEntry(nh, tag, type, ptr, count);
|
||||
}
|
||||
headerFreeIterator(hi);
|
||||
|
||||
|
@ -925,6 +928,8 @@ int headerWrite(FD_t fd, Header h, enum hMagic magicp)
|
|||
int length;
|
||||
const void * uh;
|
||||
|
||||
if (h == NULL)
|
||||
return 1;
|
||||
uh = doHeaderUnload(h, &length);
|
||||
switch (magicp) {
|
||||
case HEADER_MAGIC_YES:
|
||||
|
@ -1129,11 +1134,13 @@ void headerDump(Header h, FILE *f, int flags,
|
|||
* @param type entry type
|
||||
* @return header entry
|
||||
*/
|
||||
static struct indexEntry *findEntry(Header h, int_32 tag, int_32 type)
|
||||
static /*@null@*/
|
||||
struct indexEntry * findEntry(/*@null@*/ Header h, int_32 tag, int_32 type)
|
||||
{
|
||||
struct indexEntry * entry, * entry2, * last;
|
||||
struct indexEntry key;
|
||||
|
||||
if (h == NULL) return NULL;
|
||||
if (!h->sorted) headerSort(h);
|
||||
|
||||
key.info.tag = tag;
|
||||
|
@ -1330,8 +1337,10 @@ headerFindI18NString(Header h, struct indexEntry *entry)
|
|||
* @param minMem string pointers reference header memory?
|
||||
* @return 1 on success, 0 on not found
|
||||
*/
|
||||
static int intGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
|
||||
/*@out@*/ const void **p, /*@out@*/ int_32 *c, int minMem)
|
||||
static int intGetEntry(Header h, int_32 tag, /*@null@*/ /*@out@*/ int_32 * type,
|
||||
/*@null@*/ /*@out@*/ const void ** p,
|
||||
/*@null@*/ /*@out@*/ int_32 *c,
|
||||
int minMem)
|
||||
/*@modifies *type, *p, *c @*/
|
||||
{
|
||||
struct indexEntry * entry;
|
||||
|
@ -1431,9 +1440,13 @@ int headerUsageCount(Header h)
|
|||
unsigned int headerSizeof(Header h, enum hMagic magicp)
|
||||
{
|
||||
struct indexEntry * entry;
|
||||
unsigned int size = 0, pad = 0;
|
||||
unsigned int size = 0;
|
||||
unsigned int pad = 0;
|
||||
int i;
|
||||
|
||||
if (h == NULL)
|
||||
return size;
|
||||
|
||||
headerSort(h);
|
||||
|
||||
switch (magicp) {
|
||||
|
@ -1485,7 +1498,7 @@ static void copyData(int_32 type, /*@out@*/ void * dstPtr, const void * srcPtr,
|
|||
{
|
||||
const char ** src;
|
||||
char * dst;
|
||||
int i, len;
|
||||
int i;
|
||||
|
||||
switch (type) {
|
||||
case RPM_STRING_ARRAY_TYPE:
|
||||
|
@ -1495,9 +1508,11 @@ static void copyData(int_32 type, /*@out@*/ void * dstPtr, const void * srcPtr,
|
|||
src = (const char **) srcPtr;
|
||||
dst = dstPtr;
|
||||
while (i--) {
|
||||
len = *src ? strlen(*src) + 1 : 0;
|
||||
if (*src) {
|
||||
int len = strlen(*src) + 1;
|
||||
memcpy(dst, *src, len);
|
||||
dst += len;
|
||||
}
|
||||
src++;
|
||||
}
|
||||
break;
|
||||
|
@ -1573,6 +1588,7 @@ headerGetLangs(Header h)
|
|||
if (!headerGetRawEntry(h, HEADER_I18NTABLE, &type, (const void **)&s, &count))
|
||||
return NULL;
|
||||
|
||||
/* XXX xcalloc never returns NULL. */
|
||||
if ((table = (char **)xcalloc((count+1), sizeof(char *))) == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -1580,13 +1596,12 @@ headerGetLangs(Header h)
|
|||
table[i] = e;
|
||||
table[count] = NULL;
|
||||
|
||||
return table;
|
||||
/*@-nullret@*/ return table; /*@=nullret@*/ /* LCL: double indirection? */
|
||||
}
|
||||
|
||||
int headerAddI18NString(Header h, int_32 tag, const char * string, const char * lang)
|
||||
{
|
||||
struct indexEntry * table, * entry;
|
||||
char * chptr;
|
||||
const char ** strArray;
|
||||
int length;
|
||||
int ghosts;
|
||||
|
@ -1618,12 +1633,15 @@ int headerAddI18NString(Header h, int_32 tag, const char * string, const char *
|
|||
table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE);
|
||||
}
|
||||
|
||||
if (!table)
|
||||
return 0;
|
||||
if (!lang) lang = "C";
|
||||
|
||||
chptr = table->data;
|
||||
{ const char * l = table->data;
|
||||
for (langNum = 0; langNum < table->info.count; langNum++) {
|
||||
if (!strcmp(chptr, lang)) break;
|
||||
chptr += strlen(chptr) + 1;
|
||||
if (!strcmp(l, lang)) break;
|
||||
l += strlen(l) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (langNum >= table->info.count) {
|
||||
|
@ -1837,10 +1855,12 @@ static char escapedChar(const char ch) /*@*/
|
|||
}
|
||||
}
|
||||
|
||||
static void freeFormat( /*@only@*/ struct sprintfToken * format, int num)
|
||||
static
|
||||
void freeFormat( /*@only@*/ /*@null@*/ struct sprintfToken * format, int num)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (format == NULL) return;
|
||||
for (i = 0; i < num; i++) {
|
||||
switch (format[i].type) {
|
||||
case PTOK_ARRAY:
|
||||
|
@ -1914,13 +1934,14 @@ static void findTag(char * name, const struct headerTagTableEntry * tags,
|
|||
static int parseExpression(struct sprintfToken * token, char * str,
|
||||
const struct headerTagTableEntry * tags,
|
||||
const struct headerSprintfExtension * extensions,
|
||||
/*@out@*/char ** endPtr, /*@out@*/const char ** errmsg)
|
||||
/*@out@*/char ** endPtr, /*@null@*/ /*@out@*/ errmsg_t * errmsg)
|
||||
/*@modifies str, *str, *token, *endPtr, *errmsg @*/;
|
||||
|
||||
static int parseFormat(char * str, const struct headerTagTableEntry * tags,
|
||||
const struct headerSprintfExtension * extensions,
|
||||
/*@out@*/struct sprintfToken ** formatPtr, /*@out@*/int * numTokensPtr,
|
||||
/*@out@*/char ** endPtr, int state, /*@out@*/const char ** errmsg)
|
||||
/*@null@*/ /*@out@*/char ** endPtr, int state,
|
||||
/*@null@*/ /*@out@*/errmsg_t * errmsg)
|
||||
/*@modifies str, *str, *formatPtr, *numTokensPtr, *endPtr, *errmsg @*/
|
||||
{
|
||||
char * chptr, * start, * next, * dst;
|
||||
|
@ -1990,7 +2011,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
|
|||
while (*chptr && *chptr != '{' && *chptr != '%') chptr++;
|
||||
if (!*chptr || *chptr == '%') {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("missing { after %");
|
||||
if (errmsg) *errmsg = _("missing { after %");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(format, numTokens);
|
||||
return 1;
|
||||
|
@ -2020,7 +2041,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
|
|||
while (*next && *next != '}') next++;
|
||||
if (!*next) {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("missing } after %{");
|
||||
if (errmsg) *errmsg = _("missing } after %{");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(format, numTokens);
|
||||
return 1;
|
||||
|
@ -2034,7 +2055,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
|
|||
*chptr++ = '\0';
|
||||
if (!*chptr) {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("empty tag format");
|
||||
if (errmsg) *errmsg = _("empty tag format");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(format, numTokens);
|
||||
return 1;
|
||||
|
@ -2046,7 +2067,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
|
|||
|
||||
if (!*start) {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("empty tag name");
|
||||
if (errmsg) *errmsg = _("empty tag name");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(format, numTokens);
|
||||
return 1;
|
||||
|
@ -2063,7 +2084,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
|
|||
format[currToken].u.tag.extNum = ext - extensions;
|
||||
} else {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("unknown tag");
|
||||
if (errmsg) *errmsg = _("unknown tag");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(format, numTokens);
|
||||
return 1;
|
||||
|
@ -2090,7 +2111,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
|
|||
|
||||
if (!start) {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("] expected at end of array");
|
||||
if (errmsg) *errmsg = _("] expected at end of array");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(format, numTokens);
|
||||
return 1;
|
||||
|
@ -2106,19 +2127,20 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
|
|||
case '}':
|
||||
if ((*start == ']' && state != PARSER_IN_ARRAY) ||
|
||||
(*start == '}' && state != PARSER_IN_EXPR)) {
|
||||
if (*start == ']')
|
||||
if (*start == ']') {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("unexpected ]");
|
||||
if (errmsg) *errmsg = _("unexpected ]");
|
||||
/*@=observertrans@*/
|
||||
else
|
||||
} else {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("unexpected }");
|
||||
if (errmsg) *errmsg = _("unexpected }");
|
||||
/*@=observertrans@*/
|
||||
}
|
||||
freeFormat(format, numTokens);
|
||||
return 1;
|
||||
}
|
||||
*start++ = '\0';
|
||||
*endPtr = start;
|
||||
if (endPtr) *endPtr = start;
|
||||
done = 1;
|
||||
break;
|
||||
|
||||
|
@ -2161,20 +2183,20 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
|
|||
static int parseExpression(struct sprintfToken * token, char * str,
|
||||
const struct headerTagTableEntry * tags,
|
||||
const struct headerSprintfExtension * extensions,
|
||||
/*@out@*/ char ** endPtr, /*@out@*/ const char ** errmsg)
|
||||
/*@out@*/ char ** endPtr, /*@null@*/ /*@out@*/ errmsg_t * errmsg)
|
||||
{
|
||||
const struct headerTagTableEntry * tag;
|
||||
const struct headerSprintfExtension * ext;
|
||||
char * chptr;
|
||||
char * end;
|
||||
|
||||
*errmsg = NULL;
|
||||
if (errmsg) *errmsg = NULL;
|
||||
chptr = str;
|
||||
while (*chptr && *chptr != '?') chptr++;
|
||||
|
||||
if (*chptr != '?') {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("? expected in expression");
|
||||
if (errmsg) *errmsg = _("? expected in expression");
|
||||
/*@=observertrans@*/
|
||||
return 1;
|
||||
}
|
||||
|
@ -2183,7 +2205,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
|
|||
|
||||
if (*chptr != '{') {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("{ expected after ? in expression");
|
||||
if (errmsg) *errmsg = _("{ expected after ? in expression");
|
||||
/*@=observertrans@*/
|
||||
return 1;
|
||||
}
|
||||
|
@ -2196,7 +2218,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
|
|||
|
||||
if (!*end) {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("} expected in expression");
|
||||
if (errmsg) *errmsg = _("} expected in expression");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
|
||||
token->u.cond.ifFormat = NULL;
|
||||
|
@ -2206,7 +2228,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
|
|||
chptr = end;
|
||||
if (*chptr != ':' && *chptr != '|') {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _(": expected following ? subexpression");
|
||||
if (errmsg) *errmsg = _(": expected following ? subexpression");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
|
||||
token->u.cond.ifFormat = NULL;
|
||||
|
@ -2223,7 +2245,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
|
|||
|
||||
if (*chptr != '{') {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("{ expected after : in expression");
|
||||
if (errmsg) *errmsg = _("{ expected after : in expression");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
|
||||
token->u.cond.ifFormat = NULL;
|
||||
|
@ -2238,7 +2260,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
|
|||
return 1;
|
||||
if (!*end) {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("} expected in expression");
|
||||
if (errmsg) *errmsg = _("} expected in expression");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
|
||||
token->u.cond.ifFormat = NULL;
|
||||
|
@ -2248,7 +2270,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
|
|||
chptr = end;
|
||||
if (*chptr != '|') {
|
||||
/*@-observertrans@*/
|
||||
*errmsg = _("| expected at end of expression");
|
||||
if (errmsg) *errmsg = _("| expected at end of expression");
|
||||
/*@=observertrans@*/
|
||||
freeFormat(token->u.cond.ifFormat, token->u.cond.numIfTokens);
|
||||
token->u.cond.ifFormat = NULL;
|
||||
|
@ -2580,7 +2602,7 @@ static void freeExtensionCache(const struct headerSprintfExtension * extensions,
|
|||
char * headerSprintf(Header h, const char * origFmt,
|
||||
const struct headerTagTableEntry * tags,
|
||||
const struct headerSprintfExtension * extensions,
|
||||
const char ** errmsg)
|
||||
errmsg_t * errmsg)
|
||||
{
|
||||
char * fmtString;
|
||||
struct sprintfToken * format;
|
||||
|
@ -2671,16 +2693,17 @@ static char * hexFormat(int_32 type, const void * data,
|
|||
|
||||
static char * realDateFormat(int_32 type, const void * data,
|
||||
char * formatPrefix, int padding, /*@unused@*/int element,
|
||||
char * strftimeFormat)
|
||||
const char * strftimeFormat)
|
||||
/*@modifies formatPrefix @*/
|
||||
{
|
||||
char * val;
|
||||
struct tm * tstruct;
|
||||
char buf[50];
|
||||
|
||||
if (type != RPM_INT32_TYPE) {
|
||||
val = xstrdup(_("(not a number)"));
|
||||
} else {
|
||||
struct tm * tstruct;
|
||||
char buf[50];
|
||||
|
||||
val = xmalloc(50 + padding);
|
||||
strcat(formatPrefix, "s");
|
||||
|
||||
|
@ -2688,7 +2711,9 @@ static char * realDateFormat(int_32 type, const void * data,
|
|||
{ time_t dateint = *((int_32 *) data);
|
||||
tstruct = localtime(&dateint);
|
||||
}
|
||||
(void)strftime(buf, sizeof(buf) - 1, strftimeFormat, tstruct);
|
||||
buf[0] = '\0';
|
||||
if (tstruct)
|
||||
(void) strftime(buf, sizeof(buf) - 1, strftimeFormat, tstruct);
|
||||
sprintf(val, formatPrefix, buf);
|
||||
}
|
||||
|
||||
|
|
28
lib/header.h
28
lib/header.h
|
@ -181,7 +181,7 @@ enum hMagic {
|
|||
* @param magicp read (and verify) 8 bytes of (magic, 0)?
|
||||
* @return header (or NULL on error)
|
||||
*/
|
||||
Header headerRead(FD_t fd, enum hMagic magicp)
|
||||
/*@null@*/ Header headerRead(FD_t fd, enum hMagic magicp)
|
||||
/*@modifies fd @*/;
|
||||
|
||||
/** \ingroup header
|
||||
|
@ -191,7 +191,7 @@ Header headerRead(FD_t fd, enum hMagic magicp)
|
|||
* @param magicp prefix write with 8 bytes of (magic, 0)?
|
||||
* @return 0 on success, 1 on error
|
||||
*/
|
||||
int headerWrite(FD_t fd, Header h, enum hMagic magicp)
|
||||
int headerWrite(FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
|
||||
/*@modifies fd, h @*/;
|
||||
|
||||
/** \ingroup header
|
||||
|
@ -200,7 +200,7 @@ int headerWrite(FD_t fd, Header h, enum hMagic magicp)
|
|||
* @param magicp include size of 8 bytes for (magic, 0)?
|
||||
* @return size of on-disk header
|
||||
*/
|
||||
unsigned int headerSizeof(Header h, enum hMagic magicp)
|
||||
unsigned int headerSizeof(/*@null@*/ Header h, enum hMagic magicp)
|
||||
/*@modifies h @*/;
|
||||
|
||||
/** \ingroup header
|
||||
|
@ -208,14 +208,14 @@ unsigned int headerSizeof(Header h, enum hMagic magicp)
|
|||
* @param p on-disk header (with offsets)
|
||||
* @return header
|
||||
*/
|
||||
Header headerLoad(/*@kept@*/ void *p) /*@*/;
|
||||
/*@null@*/ Header headerLoad(/*@kept@*/ void * p) /*@*/;
|
||||
|
||||
/** \ingroup header
|
||||
* Make a copy and convert header to in-memory representation.
|
||||
* @param p on-disk header (with offsets)
|
||||
* @return header
|
||||
*/
|
||||
Header headerCopyLoad(void *p) /*@*/;
|
||||
/*@null@*/ Header headerCopyLoad(void * p) /*@*/;
|
||||
|
||||
/** \ingroup header
|
||||
* Convert header to on-disk representation.
|
||||
|
@ -232,7 +232,7 @@ Header headerCopyLoad(void *p) /*@*/;
|
|||
* @param tag region tag
|
||||
* @return on-disk header (with offsets)
|
||||
*/
|
||||
Header headerReload(/*@only@*/ Header h, int tag)
|
||||
/*@null@*/ Header headerReload(/*@only@*/ Header h, int tag)
|
||||
/*@modifies h @*/;
|
||||
|
||||
/** \ingroup header
|
||||
|
@ -272,7 +272,9 @@ void headerDump(Header h, FILE *f, int flags,
|
|||
const struct headerTagTableEntry * tags);
|
||||
#define HEADER_DUMP_INLINE 1
|
||||
|
||||
/*@-redef@*/ /* LCL: no clue */
|
||||
typedef const char * errmsg_t;
|
||||
/*@=redef@*/
|
||||
|
||||
/** \ingroup header
|
||||
* Return formatted output string from header tags.
|
||||
|
@ -288,7 +290,7 @@ typedef const char * errmsg_t;
|
|||
/*@only@*/ char * headerSprintf(Header h, const char * fmt,
|
||||
const struct headerTagTableEntry * tags,
|
||||
const struct headerSprintfExtension * extentions,
|
||||
/*@out@*/ errmsg_t * errmsg)
|
||||
/*@null@*/ /*@out@*/ errmsg_t * errmsg)
|
||||
/*@modifies *errmsg @*/;
|
||||
|
||||
/** \ingroup header
|
||||
|
@ -397,8 +399,8 @@ int headerAddOrAppendEntry(Header h, int_32 tag, int_32 type, void * p, int_32 c
|
|||
* @retval c address of number of values
|
||||
* @return 1 on success, 0 on failure
|
||||
*/
|
||||
int headerGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
|
||||
/*@out@*/ void **p, /*@out@*/int_32 *c)
|
||||
int headerGetEntry(Header h, int_32 tag, /*@null@*/ /*@out@*/ int_32 *type,
|
||||
/*@null@*/ /*@out@*/ void **p, /*@null@*/ /*@out@*/int_32 *c)
|
||||
/*@modifies *type, *p, *c @*/;
|
||||
|
||||
/** \ingroup header
|
||||
|
@ -439,7 +441,7 @@ int headerGetRawEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
|
|||
* @param tag tag
|
||||
* @return 1 on success, 0 on failure
|
||||
*/
|
||||
int headerIsEntry(Header h, int_32 tag) /*@*/;
|
||||
int headerIsEntry(/*@null@*/Header h, int_32 tag) /*@*/;
|
||||
|
||||
/** \ingroup header
|
||||
* Delete tag in header.
|
||||
|
@ -486,7 +488,7 @@ void headerFreeIterator( /*@only@*/ HeaderIterator iter);
|
|||
* @param h header
|
||||
* @return new header instance
|
||||
*/
|
||||
Header headerCopy(Header h)
|
||||
/*@null@*/ Header headerCopy(Header h)
|
||||
/*@modifies h @*/;
|
||||
|
||||
/** \ingroup header
|
||||
|
@ -536,8 +538,8 @@ typedef enum rpmTagType_e {
|
|||
* @param type type of data
|
||||
* @return NULL always
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/ void * headerFreeData(
|
||||
/*@only@*/ const void * data, rpmTagType type)
|
||||
/*@unused@*/ static inline /*@null@*/
|
||||
void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
|
||||
{
|
||||
if (data) {
|
||||
if (type < 0 ||
|
||||
|
|
|
@ -66,14 +66,16 @@ int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr)
|
|||
const char ** av = NULL;
|
||||
int argc = (argcPtr ? *argcPtr : 0);
|
||||
const char ** argv = (argvPtr ? *argvPtr : NULL);
|
||||
FILE * f = fdGetFp(fd);
|
||||
int rc = 0;
|
||||
int i;
|
||||
|
||||
if (f != NULL)
|
||||
while (1) {
|
||||
char line[BUFSIZ];
|
||||
|
||||
/* Read next line. */
|
||||
s = fgets(line, sizeof(line) - 1, fdGetFp(fd));
|
||||
s = fgets(line, sizeof(line) - 1, f);
|
||||
if (s == NULL) {
|
||||
/* XXX Ferror check needed */
|
||||
break;
|
||||
|
@ -129,6 +131,7 @@ int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr)
|
|||
memcpy(nav + ac, argv + i, (argc - i) * sizeof(*nav));
|
||||
nav[nac] = NULL;
|
||||
|
||||
if (argvPtr)
|
||||
*argvPtr = argv = _free(argv);
|
||||
av = _free(av);
|
||||
av = nav;
|
||||
|
@ -145,10 +148,13 @@ int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr)
|
|||
|
||||
exit:
|
||||
if (argvPtr == NULL || (rc != 0 && av)) {
|
||||
if (av)
|
||||
for (i = 0; i < ac; i++)
|
||||
/*@-unqualifiedtrans@*/av[i] = _free(av[i]); /*@=unqualifiedtrans@*/
|
||||
/*@-dependenttrans@*/ av = _free(av); /*@=dependenttrans@*/
|
||||
}
|
||||
freeStringBuf(sb);
|
||||
/*@-nullstate@*/
|
||||
return rc;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@ struct MD5Context {
|
|||
/*
|
||||
* This is needed to make RSAREF happy on some MS-DOS compilers.
|
||||
*/
|
||||
/*@-mutrep@*/ /* FIX: redefine as pointer */
|
||||
typedef /*@abstract@*/ struct MD5Context MD5_CTX;
|
||||
/*@=mutrep@*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -681,7 +681,8 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL);
|
|||
|
||||
exit:
|
||||
av = _free(av);
|
||||
if ((rc || argvPtr == NULL) && argv) {
|
||||
if (rc || argvPtr == NULL) {
|
||||
if (argv != NULL)
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] = _free(argv[i]);
|
||||
argv = _free(argv);
|
||||
|
|
|
@ -42,6 +42,7 @@ void headerMergeLegacySigs(Header h, const Header sig)
|
|||
continue;
|
||||
/*@notreached@*/ break;
|
||||
}
|
||||
if (ptr == NULL) continue; /* XXX can't happen */
|
||||
if (!headerIsEntry(h, tag))
|
||||
(void) headerAddEntry(h, tag, type, ptr, count);
|
||||
}
|
||||
|
@ -71,6 +72,7 @@ Header headerRegenSigHeader(const Header h)
|
|||
continue;
|
||||
/*@notreached@*/ break;
|
||||
}
|
||||
if (ptr == NULL) continue; /* XXX can't happen */
|
||||
if (!headerIsEntry(sig, stag))
|
||||
(void) headerAddEntry(sig, stag, type, ptr, count);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "build.h"
|
||||
#include "debug.h"
|
||||
|
||||
struct rpmBuildArguments rpmBTArgs;
|
||||
struct rpmBuildArguments_s rpmBTArgs;
|
||||
|
||||
#define POPT_USECATALOG 1000
|
||||
#define POPT_NOLANG 1001
|
||||
|
@ -59,7 +59,7 @@ static void buildArgCallback( /*@unused@*/ poptContext con,
|
|||
const struct poptOption * opt, const char * arg,
|
||||
/*@unused@*/ const void * data)
|
||||
{
|
||||
struct rpmBuildArguments * rba = &rpmBTArgs;
|
||||
BTA_t rba = &rpmBTArgs;
|
||||
|
||||
switch (opt->val) {
|
||||
case POPT_REBUILD:
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <rpmurl.h>
|
||||
#include "debug.h"
|
||||
|
||||
struct rpmQVArguments rpmQVArgs;
|
||||
struct rpmQVArguments_s rpmQVArgs;
|
||||
int specedit = 0;
|
||||
|
||||
/* ======================================================================== */
|
||||
|
@ -27,7 +27,7 @@ static void rpmQVSourceArgCallback( /*@unused@*/ poptContext con,
|
|||
const struct poptOption * opt, /*@unused@*/ const char * arg,
|
||||
/*@unused@*/ const void * data)
|
||||
{
|
||||
QVA_t *qva = &rpmQVArgs;
|
||||
QVA_t qva = &rpmQVArgs;
|
||||
|
||||
switch (opt->val) {
|
||||
case 'q':
|
||||
|
@ -99,7 +99,7 @@ static void queryArgCallback(/*@unused@*/poptContext con, /*@unused@*/enum poptC
|
|||
const struct poptOption * opt, const char * arg,
|
||||
/*@unused@*/ const void * data)
|
||||
{
|
||||
QVA_t *qva = &rpmQVArgs;
|
||||
QVA_t qva = &rpmQVArgs;
|
||||
|
||||
switch (opt->val) {
|
||||
case 'c': qva->qva_flags |= QUERY_FOR_CONFIG | QUERY_FOR_LIST; break;
|
||||
|
|
|
@ -107,74 +107,74 @@ static inline int snprintf(char * buf, int nb, const char * fmt, ...)
|
|||
|
||||
const char * rpmProblemString(rpmProblem prob) /*@*/
|
||||
{
|
||||
int nb = (prob->pkgNEVR ? strlen(prob->pkgNEVR) : 0) +
|
||||
(prob->str1 ? strlen(prob->str1) : 0) +
|
||||
(prob->altNEVR ? strlen(prob->altNEVR) : 0) +
|
||||
100;
|
||||
/*@observer@*/ const char * pkgNEVR = (prob->pkgNEVR ? prob->pkgNEVR : "");
|
||||
/*@observer@*/ const char * altNEVR = (prob->altNEVR ? prob->altNEVR : "");
|
||||
/*@observer@*/ const char * str1 = (prob->str1 ? prob->str1 : "");
|
||||
int nb = strlen(pkgNEVR) + strlen(str1) + strlen(altNEVR) + 100;
|
||||
char * buf = xmalloc(nb+1);
|
||||
|
||||
switch (prob->type) {
|
||||
case RPMPROB_BADARCH:
|
||||
(void) snprintf(buf, nb,
|
||||
_("package %s is for a different architecture"),
|
||||
prob->pkgNEVR);
|
||||
pkgNEVR);
|
||||
break;
|
||||
case RPMPROB_BADOS:
|
||||
(void) snprintf(buf, nb,
|
||||
_("package %s is for a different operating system"),
|
||||
prob->pkgNEVR);
|
||||
pkgNEVR);
|
||||
break;
|
||||
case RPMPROB_PKG_INSTALLED:
|
||||
(void) snprintf(buf, nb,
|
||||
_("package %s is already installed"),
|
||||
prob->pkgNEVR);
|
||||
pkgNEVR);
|
||||
break;
|
||||
case RPMPROB_BADRELOCATE:
|
||||
(void) snprintf(buf, nb,
|
||||
_("path %s in package %s is not relocateable"),
|
||||
prob->str1, prob->pkgNEVR);
|
||||
str1, pkgNEVR);
|
||||
break;
|
||||
case RPMPROB_NEW_FILE_CONFLICT:
|
||||
(void) snprintf(buf, nb,
|
||||
_("file %s conflicts between attempted installs of %s and %s"),
|
||||
prob->str1, prob->pkgNEVR, prob->altNEVR);
|
||||
str1, pkgNEVR, altNEVR);
|
||||
break;
|
||||
case RPMPROB_FILE_CONFLICT:
|
||||
(void) snprintf(buf, nb,
|
||||
_("file %s from install of %s conflicts with file from package %s"),
|
||||
prob->str1, prob->pkgNEVR, prob->altNEVR);
|
||||
str1, pkgNEVR, altNEVR);
|
||||
break;
|
||||
case RPMPROB_OLDPACKAGE:
|
||||
(void) snprintf(buf, nb,
|
||||
_("package %s (which is newer than %s) is already installed"),
|
||||
prob->altNEVR, prob->pkgNEVR);
|
||||
altNEVR, pkgNEVR);
|
||||
break;
|
||||
case RPMPROB_DISKSPACE:
|
||||
(void) snprintf(buf, nb,
|
||||
_("installing package %s needs %ld%cb on the %s filesystem"),
|
||||
prob->pkgNEVR,
|
||||
pkgNEVR,
|
||||
prob->ulong1 > (1024*1024)
|
||||
? (prob->ulong1 + 1024 * 1024 - 1) / (1024 * 1024)
|
||||
: (prob->ulong1 + 1023) / 1024,
|
||||
prob->ulong1 > (1024*1024) ? 'M' : 'K',
|
||||
prob->str1);
|
||||
str1);
|
||||
break;
|
||||
case RPMPROB_DISKNODES:
|
||||
(void) snprintf(buf, nb,
|
||||
_("installing package %s needs %ld inodes on the %s filesystem"),
|
||||
prob->pkgNEVR, (long)prob->ulong1, prob->str1);
|
||||
pkgNEVR, (long)prob->ulong1, str1);
|
||||
break;
|
||||
case RPMPROB_BADPRETRANS:
|
||||
(void) snprintf(buf, nb,
|
||||
_("package %s pre-transaction syscall(s): %s failed: %s"),
|
||||
prob->pkgNEVR, prob->str1, strerror(prob->ulong1));
|
||||
pkgNEVR, str1, strerror(prob->ulong1));
|
||||
break;
|
||||
case RPMPROB_REQUIRES:
|
||||
case RPMPROB_CONFLICT:
|
||||
default:
|
||||
(void) snprintf(buf, nb,
|
||||
_("unknown error %d encountered while manipulating package %s"),
|
||||
prob->type, prob->pkgNEVR);
|
||||
prob->type, pkgNEVR);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
45
lib/psm.c
45
lib/psm.c
|
@ -212,6 +212,10 @@ void freeFi(TFI_t fi)
|
|||
if (fi->h) {
|
||||
headerFree(fi->h); fi->h = NULL;
|
||||
}
|
||||
|
||||
/*@-nullstate@*/
|
||||
return;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
|
||||
/*@observer@*/ const char *const fiTypeString(TFI_t fi) {
|
||||
|
@ -282,7 +286,7 @@ static int rpmInstallLoadMacros(TFI_t fi, Header h)
|
|||
static int mergeFiles(TFI_t fi, Header h, Header newH)
|
||||
{
|
||||
HGE_t hge = (HGE_t)fi->hge;
|
||||
HFD_t hfd = fi->hfd;
|
||||
HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
||||
fileAction * actions = fi->actions;
|
||||
int i, j, k, fc;
|
||||
int_32 type = 0;
|
||||
|
@ -601,12 +605,16 @@ rpmRC rpmInstallSourcePackage(const char * rootDir, FD_t fd,
|
|||
}
|
||||
|
||||
(void) rpmtransAddPackage(ts, h, fd, NULL, 0, NULL);
|
||||
if (ts->addedPackages.list == NULL) { /* XXX can't happen */
|
||||
rc = RPMRC_FAIL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
fi->type = TR_ADDED;
|
||||
fi->ap = ts->addedPackages.list;
|
||||
loadFi(h, fi);
|
||||
hge = fi->hge;
|
||||
hfd = fi->hfd;
|
||||
hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
||||
headerFree(h); /* XXX reference held by transaction set */
|
||||
h = NULL;
|
||||
|
||||
|
@ -780,7 +788,7 @@ static int runScript(PSM_t psm, Header h,
|
|||
const rpmTransactionSet ts = psm->ts;
|
||||
TFI_t fi = psm->fi;
|
||||
HGE_t hge = fi->hge;
|
||||
HFD_t hfd = fi->hfd;
|
||||
HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
||||
const char ** argv = NULL;
|
||||
int argc = 0;
|
||||
const char ** prefixes = NULL;
|
||||
|
@ -879,6 +887,7 @@ static int runScript(PSM_t psm, Header h,
|
|||
out = fdDup(STDOUT_FILENO);
|
||||
out = fdLink(out, "runScript persist");
|
||||
}
|
||||
if (out == NULL) return 1; /* XXX can't happen */
|
||||
|
||||
if (!(child = fork())) {
|
||||
const char * rootDir;
|
||||
|
@ -925,7 +934,7 @@ static int runScript(PSM_t psm, Header h,
|
|||
}
|
||||
}
|
||||
|
||||
rootDir = ts->rootDir;
|
||||
if ((rootDir = ts->rootDir) != NULL) /* XXX can't happen */
|
||||
switch(urlIsURL(rootDir)) {
|
||||
case URL_IS_PATH:
|
||||
rootDir += sizeof("file://") - 1;
|
||||
|
@ -983,7 +992,7 @@ static rpmRC runInstScript(PSM_t psm)
|
|||
{
|
||||
TFI_t fi = psm->fi;
|
||||
HGE_t hge = fi->hge;
|
||||
HFD_t hfd = fi->hfd;
|
||||
HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
||||
void ** programArgv;
|
||||
int programArgc;
|
||||
const char ** argv;
|
||||
|
@ -1027,7 +1036,7 @@ static int handleOneTrigger(PSM_t psm, Header sourceH, Header triggeredH,
|
|||
const rpmTransactionSet ts = psm->ts;
|
||||
TFI_t fi = psm->fi;
|
||||
HGE_t hge = fi->hge;
|
||||
HFD_t hfd = fi->hfd;
|
||||
HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
||||
const char ** triggerNames;
|
||||
const char ** triggerEVR;
|
||||
const char ** triggerScripts;
|
||||
|
@ -1166,7 +1175,7 @@ static int runImmedTriggers(PSM_t psm)
|
|||
const rpmTransactionSet ts = psm->ts;
|
||||
TFI_t fi = psm->fi;
|
||||
HGE_t hge = fi->hge;
|
||||
HFD_t hfd = fi->hfd;
|
||||
HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
||||
const char ** triggerNames;
|
||||
int numTriggers;
|
||||
int_32 * triggerIndices;
|
||||
|
@ -1255,7 +1264,7 @@ int psmStage(PSM_t psm, pkgStage stage)
|
|||
const rpmTransactionSet ts = psm->ts;
|
||||
TFI_t fi = psm->fi;
|
||||
HGE_t hge = fi->hge;
|
||||
HFD_t hfd = fi->hfd;
|
||||
HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
||||
rpmRC rc = psm->rc;
|
||||
int saveerrno;
|
||||
|
||||
|
@ -1505,7 +1514,17 @@ assert(psm->mi == NULL);
|
|||
/* Retrieve type of payload compression. */
|
||||
rc = psmStage(psm, PSM_RPMIO_FLAGS);
|
||||
|
||||
if (alp->fd == NULL) { /* XXX can't happen */
|
||||
rc = RPMRC_FAIL;
|
||||
break;
|
||||
}
|
||||
/*@-nullpass@*/ /* LCL: alp->fd != NULL here. */
|
||||
psm->cfd = Fdopen(fdDup(Fileno(alp->fd)), psm->rpmio_flags);
|
||||
/*@=nullpass@*/
|
||||
if (psm->cfd == NULL) { /* XXX can't happen */
|
||||
rc = RPMRC_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
rc = fsmSetup(fi->fsm, FSM_PKGINSTALL, ts, fi,
|
||||
psm->cfd, NULL, &psm->failedFile);
|
||||
|
@ -1561,8 +1580,18 @@ assert(psm->mi == NULL);
|
|||
fi->action = FA_COPYOUT;
|
||||
fi->actions = NULL;
|
||||
|
||||
if (psm->fd == NULL) { /* XXX can't happen */
|
||||
rc = RPMRC_FAIL;
|
||||
break;
|
||||
}
|
||||
/*@-nullpass@*/ /* LCL: psm->fd != NULL here. */
|
||||
(void) Fflush(psm->fd);
|
||||
psm->cfd = Fdopen(fdDup(Fileno(psm->fd)), psm->rpmio_flags);
|
||||
/*@=nullpass@*/
|
||||
if (psm->cfd == NULL) { /* XXX can't happen */
|
||||
rc = RPMRC_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* XXX failedFile? */
|
||||
rc = fsmSetup(fi->fsm, FSM_PKGBUILD, ts, fi, psm->cfd, NULL, NULL);
|
||||
|
|
|
@ -187,7 +187,7 @@ void freeFi(TFI_t fi)
|
|||
* @param a package dispostion
|
||||
* @return formatted string
|
||||
*/
|
||||
/*@observer@*/ const char *const fiTypeString(TFI_t fi);
|
||||
/*@observer@*/ const char *const fiTypeString(/*@partial@*/TFI_t fi);
|
||||
|
||||
/**
|
||||
* Package state machine driver.
|
||||
|
@ -195,7 +195,7 @@ void freeFi(TFI_t fi)
|
|||
* @param stage next stage
|
||||
* @return 0 on success
|
||||
*/
|
||||
int psmStage(PSM_t psm, pkgStage stage)
|
||||
int psmStage(/*@partial@*/ PSM_t psm, pkgStage stage)
|
||||
/*@modifies psm @*/;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
19
lib/query.c
19
lib/query.c
|
@ -42,7 +42,7 @@ static void printFileInfo(char * te, const char * name,
|
|||
if (now == 0) {
|
||||
now = time(NULL);
|
||||
tm = localtime(&now);
|
||||
nowtm = *tm; /* structure assignment */
|
||||
if (tm) nowtm = *tm; /* structure assignment */
|
||||
}
|
||||
|
||||
if (owner)
|
||||
|
@ -78,6 +78,8 @@ static void printFileInfo(char * te, const char * name,
|
|||
|
||||
/* Convert file mtime to display format */
|
||||
tm = localtime(&when);
|
||||
timefield[0] = '\0';
|
||||
if (tm != NULL)
|
||||
{ const char *fmt;
|
||||
if (now > when + 6L * 30L * 24L * 60L * 60L || /* Old. */
|
||||
now < when - 60L * 60L) /* In the future. */
|
||||
|
@ -103,7 +105,7 @@ static void printFileInfo(char * te, const char * name,
|
|||
|
||||
/**
|
||||
*/
|
||||
static inline const char * queryHeader(Header h, const char * qfmt)
|
||||
static inline /*@null@*/ const char * queryHeader(Header h, const char * qfmt)
|
||||
{
|
||||
const char * errstr;
|
||||
const char * str;
|
||||
|
@ -134,7 +136,7 @@ static int countLinks(int_16 * fileRdevList, int_32 * fileInodeList, int nfiles,
|
|||
return nlink;
|
||||
}
|
||||
|
||||
int showQueryPackage(QVA_t *qva, /*@unused@*/rpmdb rpmdb, Header h)
|
||||
int showQueryPackage(QVA_t qva, /*@unused@*/rpmdb rpmdb, Header h)
|
||||
{
|
||||
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
||||
HFD_t hfd = headerFreeData;
|
||||
|
@ -451,7 +453,7 @@ void rpmDisplayQueryTags(FILE * f)
|
|||
}
|
||||
}
|
||||
|
||||
int showMatches(QVA_t *qva, rpmdbMatchIterator mi, QVF_t showPackage)
|
||||
int showMatches(QVA_t qva, rpmdbMatchIterator mi, QVF_t showPackage)
|
||||
{
|
||||
Header h;
|
||||
int ec = 0;
|
||||
|
@ -476,7 +478,7 @@ int (*parseSpecVec) (Spec *specp, const char *specFile, const char *rootdir,
|
|||
*/
|
||||
void (*freeSpecVec) (Spec spec) = NULL;
|
||||
|
||||
int rpmQueryVerify(QVA_t *qva, rpmQVSources source, const char * arg,
|
||||
int rpmQueryVerify(QVA_t qva, rpmQVSources source, const char * arg,
|
||||
rpmdb rpmdb, QVF_t showPackage)
|
||||
{
|
||||
rpmdbMatchIterator mi = NULL;
|
||||
|
@ -676,7 +678,10 @@ restart:
|
|||
if (*s == '\0') {
|
||||
char fnbuf[PATH_MAX];
|
||||
fn = /*@-unrecog@*/ realpath(arg, fnbuf) /*@=unrecog@*/;
|
||||
fn = xstrdup( (fn ? fn : arg) );
|
||||
if (fn)
|
||||
fn = xstrdup(fn);
|
||||
else
|
||||
fn = xstrdup(arg);
|
||||
} else
|
||||
fn = xstrdup(arg);
|
||||
(void) rpmCleanPath(fn);
|
||||
|
@ -749,7 +754,7 @@ restart:
|
|||
return retcode;
|
||||
}
|
||||
|
||||
int rpmQuery(QVA_t *qva, rpmQVSources source, const char * arg)
|
||||
int rpmQuery(QVA_t qva, rpmQVSources source, const char * arg)
|
||||
{
|
||||
rpmdb rpmdb = NULL;
|
||||
int rc;
|
||||
|
|
|
@ -99,7 +99,7 @@ exit:
|
|||
return rc;
|
||||
}
|
||||
|
||||
int rpmReSign(rpmResignFlags add, char *passPhrase, const char **argv)
|
||||
int rpmReSign(rpmResignFlags add, char * passPhrase, const char ** argv)
|
||||
{
|
||||
FD_t fd = NULL;
|
||||
FD_t ofd = NULL;
|
||||
|
@ -112,6 +112,8 @@ int rpmReSign(rpmResignFlags add, char *passPhrase, const char **argv)
|
|||
int res = EXIT_FAILURE;
|
||||
rpmRC rc;
|
||||
|
||||
if (argv == NULL) return 0;
|
||||
|
||||
tmprpm[0] = '\0';
|
||||
while ((rpm = *argv++) != NULL) {
|
||||
|
||||
|
@ -246,6 +248,8 @@ int rpmCheckSig(rpmCheckSigFlags flags, const char **argv)
|
|||
int res = 0;
|
||||
rpmRC rc;
|
||||
|
||||
if (argv == NULL) return 0;
|
||||
|
||||
while ((rpm = *argv++) != NULL) {
|
||||
|
||||
if (manageFile(&fd, &rpm, O_RDONLY, 0)) {
|
||||
|
@ -318,6 +322,7 @@ int rpmCheckSig(rpmCheckSigFlags flags, const char **argv)
|
|||
continue;
|
||||
/*@notreached@*/ break;
|
||||
}
|
||||
if (ptr == NULL) continue; /* XXX can't happen */
|
||||
|
||||
if ((res3 = rpmVerifySignature(sigtarget, tag, ptr, count,
|
||||
result))) {
|
||||
|
|
117
lib/rpmdb.c
117
lib/rpmdb.c
|
@ -35,7 +35,7 @@ int _filterDbDups = 0; /* Filter duplicate entries ? (bug in pre rpm-3.0.4) */
|
|||
#define _DBI_MAJOR -1
|
||||
|
||||
static int dbiTagsMax = 0;
|
||||
/*@only@*/ static int *dbiTags = NULL;
|
||||
/*@only@*/ /*@null@*/ static int *dbiTags = NULL;
|
||||
|
||||
/**
|
||||
* Return dbi index used for rpm tag.
|
||||
|
@ -46,7 +46,7 @@ static int dbiTagToDbix(int rpmtag)
|
|||
{
|
||||
int dbix;
|
||||
|
||||
if (!(dbiTagsMax > 0 && dbiTags))
|
||||
if (!(dbiTags != NULL && dbiTagsMax > 0))
|
||||
return -1;
|
||||
for (dbix = 0; dbix < dbiTagsMax; dbix++) {
|
||||
if (rpmtag == dbiTags[dbix])
|
||||
|
@ -131,9 +131,11 @@ extern struct _dbiVec db3vec;
|
|||
#define DB3vec NULL
|
||||
#endif
|
||||
|
||||
/*@-nullassign@*/
|
||||
static struct _dbiVec *mydbvecs[] = {
|
||||
DB1vec, DB1vec, DB2vec, DB3vec, NULL
|
||||
};
|
||||
/*@=nullassign@*/
|
||||
|
||||
INLINE int dbiSync(dbiIndex dbi, unsigned int flags) {
|
||||
if (_debug < 0 || dbi->dbi_debug)
|
||||
|
@ -222,7 +224,7 @@ INLINE int dbiPut(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen
|
|||
if (_debug < 0 || dbi->dbi_debug) {
|
||||
int dataval = 0xdeadbeef;
|
||||
if (datap) memcpy(&dataval, datap, sizeof(dataval));
|
||||
fprintf(stderr, " Put %s key (%p,%ld) data (%p,%ld) \"%s\" %x rc %d\n", tagName(dbi->dbi_rpmtag), keyp, (long)keylen, datap, (long)datalen, (dbi->dbi_rpmtag != RPMDBI_PACKAGES ? (char *)keyp : ""), (unsigned)dataval, rc);
|
||||
fprintf(stderr, " Put %s key (%p,%ld) data (%p,%ld) \"%s\" %x rc %d\n", tagName(dbi->dbi_rpmtag), keyp, (long)keylen, (datap ? datap : NULL), (long)datalen, (dbi->dbi_rpmtag != RPMDBI_PACKAGES ? (char *)keyp : ""), (unsigned)dataval, rc);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -241,10 +243,14 @@ dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag, /*@unused@*/ unsigned int flags)
|
|||
int _dbapi, _dbapi_rebuild, _dbapi_wanted;
|
||||
int rc = 0;
|
||||
|
||||
if (rpmdb == NULL)
|
||||
return NULL;
|
||||
|
||||
dbix = dbiTagToDbix(rpmtag);
|
||||
if (dbix < 0 || dbix >= dbiTagsMax)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* Is this index already open ? */
|
||||
if ((dbi = rpmdb->_dbi[dbix]) != NULL)
|
||||
return dbi;
|
||||
|
@ -385,6 +391,7 @@ static int dbiSearch(dbiIndex dbi, DBC * dbcursor,
|
|||
set = xmalloc(sizeof(*set));
|
||||
|
||||
/* Convert to database internal format */
|
||||
if (sdbir)
|
||||
switch (dbi->dbi_jlen) {
|
||||
default:
|
||||
case 2*sizeof(int_32):
|
||||
|
@ -425,7 +432,7 @@ static int dbiSearch(dbiIndex dbi, DBC * dbcursor,
|
|||
}
|
||||
break;
|
||||
}
|
||||
*setp = set;
|
||||
if (setp) *setp = set;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
@ -668,6 +675,9 @@ int rpmdbOpenAll (rpmdb rpmdb)
|
|||
{
|
||||
int dbix;
|
||||
|
||||
if (rpmdb == NULL) return -2;
|
||||
|
||||
if (dbiTags != NULL)
|
||||
for (dbix = 0; dbix < dbiTagsMax; dbix++) {
|
||||
if (rpmdb->_dbi[dbix] != NULL)
|
||||
continue;
|
||||
|
@ -681,6 +691,7 @@ int rpmdbClose (rpmdb rpmdb)
|
|||
{
|
||||
int dbix;
|
||||
|
||||
if (rpmdb == NULL) return 0;
|
||||
for (dbix = rpmdb->db_ndbi; --dbix >= 0; ) {
|
||||
if (rpmdb->_dbi[dbix] == NULL)
|
||||
continue;
|
||||
|
@ -701,6 +712,7 @@ int rpmdbSync(rpmdb rpmdb)
|
|||
{
|
||||
int dbix;
|
||||
|
||||
if (rpmdb == NULL) return 0;
|
||||
for (dbix = 0; dbix < rpmdb->db_ndbi; dbix++) {
|
||||
int xx;
|
||||
if (rpmdb->_dbi[dbix] == NULL)
|
||||
|
@ -710,7 +722,7 @@ int rpmdbSync(rpmdb rpmdb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static /*@only@*/ rpmdb newRpmdb(/*@kept@*/ const char * root,
|
||||
static /*@only@*/ rpmdb newRpmdb(/*@kept@*/ /*@null@*/ const char * root,
|
||||
/*@kept@*/ const char * home,
|
||||
int mode, int perms, int flags)
|
||||
{
|
||||
|
@ -746,8 +758,10 @@ static /*@only@*/ rpmdb newRpmdb(/*@kept@*/ const char * root,
|
|||
/*@-globstate@*/ return rpmdb; /*@=globstate@*/
|
||||
}
|
||||
|
||||
static int openDatabase(const char * prefix, const char * dbpath, int _dbapi,
|
||||
/*@out@*/ rpmdb *dbp, int mode, int perms, int flags)
|
||||
static int openDatabase(/*@null@*/ const char * prefix,
|
||||
/*@null@*/ const char * dbpath,
|
||||
int _dbapi, /*@null@*/ /*@out@*/ rpmdb *dbp,
|
||||
int mode, int perms, int flags)
|
||||
{
|
||||
rpmdb rpmdb;
|
||||
int rc;
|
||||
|
@ -777,6 +791,7 @@ static int openDatabase(const char * prefix, const char * dbpath, int _dbapi,
|
|||
{ int dbix;
|
||||
|
||||
rc = 0;
|
||||
if (dbiTags != NULL)
|
||||
for (dbix = 0; rc == 0 && dbix < dbiTagsMax; dbix++) {
|
||||
dbiIndex dbi;
|
||||
int rpmtag;
|
||||
|
@ -794,6 +809,10 @@ static int openDatabase(const char * prefix, const char * dbpath, int _dbapi,
|
|||
}
|
||||
|
||||
dbi = dbiOpen(rpmdb, rpmtag, 0);
|
||||
if (dbi == NULL) {
|
||||
rc = -2;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (rpmtag) {
|
||||
case RPMDBI_PACKAGES:
|
||||
|
@ -874,7 +893,7 @@ int rpmdbInit (const char * prefix, int perms)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
|
||||
static int rpmdbFindByFile(rpmdb rpmdb, /*@null@*/ const char * filespec,
|
||||
/*@out@*/ dbiIndexSet * matches)
|
||||
{
|
||||
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
||||
|
@ -893,6 +912,7 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
|
|||
int xx;
|
||||
|
||||
*matches = NULL;
|
||||
if (filespec == NULL) return -2;
|
||||
if ((baseName = strrchr(filespec, '/')) != NULL) {
|
||||
char * t;
|
||||
size_t len;
|
||||
|
@ -906,16 +926,22 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
|
|||
dirName = "";
|
||||
baseName = filespec;
|
||||
}
|
||||
if (baseName == NULL)
|
||||
return -2;
|
||||
|
||||
fpc = fpCacheCreate(20);
|
||||
fp1 = fpLookup(fpc, dirName, baseName, 1);
|
||||
|
||||
dbi = dbiOpen(rpmdb, RPMTAG_BASENAMES, 0);
|
||||
if (dbi != NULL) {
|
||||
dbcursor = NULL;
|
||||
xx = dbiCopen(dbi, &dbcursor, 0);
|
||||
rc = dbiSearch(dbi, dbcursor, baseName, strlen(baseName), &allMatches);
|
||||
xx = dbiCclose(dbi, dbcursor, 0);
|
||||
dbcursor = NULL;
|
||||
} else
|
||||
rc = -2;
|
||||
|
||||
if (rc) {
|
||||
dbiFreeIndexSet(allMatches);
|
||||
allMatches = NULL;
|
||||
|
@ -955,7 +981,9 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
|
|||
int num = dbiIndexRecordFileNumber(allMatches, i);
|
||||
|
||||
fp2 = fpLookup(fpc, dirNames[dirIndexes[num]], baseNames[num], 1);
|
||||
/*@-nullpass@*/
|
||||
if (FP_EQUAL(fp1, fp2)) {
|
||||
/*@=nullpass@*/
|
||||
rec->hdrNum = dbiIndexRecordOffset(allMatches, i);
|
||||
rec->tagNum = dbiIndexRecordFileNumber(allMatches, i);
|
||||
(void) dbiAppendSet(*matches, rec, 1, sizeof(*rec), 0);
|
||||
|
@ -1110,13 +1138,14 @@ exit:
|
|||
* @param matches
|
||||
* @return 0 on success, 1 on no mtches, 2 on error
|
||||
*/
|
||||
static int dbiFindByLabel(dbiIndex dbi, DBC * dbcursor, const char * arg, dbiIndexSet * matches)
|
||||
static int dbiFindByLabel(dbiIndex dbi, DBC * dbcursor,
|
||||
/*@null@*/ const char * arg, dbiIndexSet * matches)
|
||||
{
|
||||
char * localarg, * chptr;
|
||||
char * release;
|
||||
int rc;
|
||||
|
||||
if (!strlen(arg)) return 1;
|
||||
if (arg == NULL || strlen(arg) == 0) return 1;
|
||||
|
||||
/* did they give us just a name? */
|
||||
rc = dbiFindMatches(dbi, dbcursor, arg, NULL, NULL, matches);
|
||||
|
@ -1192,7 +1221,7 @@ struct _rpmdbMatchIterator {
|
|||
dbiIndexSet mi_set;
|
||||
DBC * mi_dbc;
|
||||
int mi_setx;
|
||||
Header mi_h;
|
||||
/*@null@*/ Header mi_h;
|
||||
int mi_sorted;
|
||||
int mi_modified;
|
||||
unsigned int mi_prevoffset;
|
||||
|
@ -1200,8 +1229,8 @@ struct _rpmdbMatchIterator {
|
|||
unsigned int mi_filenum;
|
||||
unsigned int mi_fpnum;
|
||||
unsigned int mi_dbnum;
|
||||
/*@only@*/ const char * mi_version;
|
||||
/*@only@*/ const char * mi_release;
|
||||
/*@only@*//*@null@*/ const char * mi_version;
|
||||
/*@only@*//*@null@*/ const char * mi_release;
|
||||
};
|
||||
|
||||
rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
|
||||
|
@ -1214,7 +1243,7 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
|
|||
|
||||
dbi = dbiOpen(mi->mi_rpmdb, RPMDBI_PACKAGES, 0);
|
||||
if (mi->mi_h) {
|
||||
if (mi->mi_modified && mi->mi_prevoffset) {
|
||||
if (dbi && mi->mi_modified && mi->mi_prevoffset) {
|
||||
DBC * dbcursor = NULL;
|
||||
xx = dbiCopen(dbi, &dbcursor, 0);
|
||||
(void) dbiUpdateRecord(dbi, dbcursor, mi->mi_prevoffset, mi->mi_h);
|
||||
|
@ -1224,21 +1253,20 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
|
|||
headerFree(mi->mi_h);
|
||||
mi->mi_h = NULL;
|
||||
}
|
||||
if (dbi->dbi_rmw) {
|
||||
if (dbi) {
|
||||
if (dbi->dbi_rmw)
|
||||
xx = dbiCclose(dbi, dbi->dbi_rmw, 0);
|
||||
dbi->dbi_rmw = NULL;
|
||||
}
|
||||
|
||||
mi->mi_release = _free(mi->mi_release);
|
||||
mi->mi_version = _free(mi->mi_version);
|
||||
if (mi->mi_dbc) {
|
||||
if (dbi && mi->mi_dbc)
|
||||
xx = dbiCclose(dbi, mi->mi_dbc, 1);
|
||||
mi->mi_dbc = NULL;
|
||||
}
|
||||
if (mi->mi_set) {
|
||||
if (mi->mi_set)
|
||||
dbiFreeIndexSet(mi->mi_set);
|
||||
mi->mi_set = NULL;
|
||||
}
|
||||
mi->mi_keyp = _free(mi->mi_keyp);
|
||||
mi = _free(mi);
|
||||
return mi;
|
||||
|
@ -1246,7 +1274,7 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
|
|||
|
||||
rpmdb rpmdbGetIteratorRpmDB(rpmdbMatchIterator mi) {
|
||||
if (mi == NULL)
|
||||
return 0;
|
||||
return NULL;
|
||||
return mi->mi_rpmdb;
|
||||
}
|
||||
|
||||
|
@ -1371,21 +1399,21 @@ if (dbi->dbi_api == 1 && dbi->dbi_rpmtag == RPMDBI_PACKAGES && rc == EFAULT) {
|
|||
mi->mi_h = NULL;
|
||||
}
|
||||
|
||||
mi->mi_h = headerCopyLoad(uh);
|
||||
mi->mi_h = (uh ? headerCopyLoad(uh) : NULL);
|
||||
/* XXX db1 with hybrid, simulated db interface on falloc.c needs free. */
|
||||
if (dbi->dbi_api <= 1) free(uh);
|
||||
if (dbi->dbi_api <= 1) uh = _free(uh);
|
||||
|
||||
if (mi->mi_release) {
|
||||
if (mi->mi_h && mi->mi_release) {
|
||||
const char *release;
|
||||
(void) headerNVR(mi->mi_h, NULL, NULL, &release);
|
||||
if (strcmp(mi->mi_release, release))
|
||||
if (mi->mi_release && strcmp(mi->mi_release, release))
|
||||
goto top;
|
||||
}
|
||||
|
||||
if (mi->mi_version) {
|
||||
if (mi->mi_h && mi->mi_version) {
|
||||
const char *version;
|
||||
(void) headerNVR(mi->mi_h, NULL, &version, NULL);
|
||||
if (strcmp(mi->mi_version, version))
|
||||
if (mi->mi_version && strcmp(mi->mi_version, version))
|
||||
goto top;
|
||||
}
|
||||
|
||||
|
@ -1404,7 +1432,7 @@ exit:
|
|||
/*@-compdef -usereleased@*/ return mi->mi_h; /*@=compdef =usereleased@*/
|
||||
}
|
||||
|
||||
static void rpmdbSortIterator(rpmdbMatchIterator mi) {
|
||||
static void rpmdbSortIterator(/*@null@*/ rpmdbMatchIterator mi) {
|
||||
if (mi && mi->mi_set && mi->mi_set->recs && mi->mi_set->count > 0) {
|
||||
qsort(mi->mi_set->recs, mi->mi_set->count, sizeof(*mi->mi_set->recs),
|
||||
hdrNumCmp);
|
||||
|
@ -1412,7 +1440,7 @@ static void rpmdbSortIterator(rpmdbMatchIterator mi) {
|
|||
}
|
||||
}
|
||||
|
||||
static int rpmdbGrowIterator(rpmdbMatchIterator mi,
|
||||
static int rpmdbGrowIterator(/*@null@*/ rpmdbMatchIterator mi,
|
||||
const void * keyp, size_t keylen, int fpNum)
|
||||
{
|
||||
dbiIndex dbi = NULL;
|
||||
|
@ -1489,6 +1517,8 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
|
|||
const void * mi_keyp = NULL;
|
||||
int isLabel = 0;
|
||||
|
||||
if (rpmdb == NULL)
|
||||
return NULL;
|
||||
/* XXX HACK to remove rpmdbFindByLabel/findMatches from the API */
|
||||
switch (rpmtag) {
|
||||
case RPMDBI_LABEL:
|
||||
|
@ -1526,7 +1556,9 @@ fprintf(stderr, "*** RMW %s %p\n", tagName(rpmtag), dbi->dbi_rmw);
|
|||
rc = rpmdbFindByFile(rpmdb, keyp, &set);
|
||||
} else {
|
||||
xx = dbiCopen(dbi, &dbcursor, 0);
|
||||
/*@-nullpass@*/ /* LCL: kep != NULL here. */
|
||||
rc = dbiSearch(dbi, dbcursor, keyp, keylen, &set);
|
||||
/*@=nullpass@*/
|
||||
xx = dbiCclose(dbi, dbcursor, 0);
|
||||
dbcursor = NULL;
|
||||
}
|
||||
|
@ -1644,6 +1676,7 @@ int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum)
|
|||
{ int dbix;
|
||||
dbiIndexItem rec = dbiIndexNewItem(hdrNum, 0);
|
||||
|
||||
if (dbiTags != NULL)
|
||||
for (dbix = 0; dbix < dbiTagsMax; dbix++) {
|
||||
dbiIndex dbi;
|
||||
DBC * dbcursor = NULL;
|
||||
|
@ -1668,12 +1701,14 @@ int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum)
|
|||
/*@notreached@*/ break;
|
||||
case RPMDBI_PACKAGES:
|
||||
dbi = dbiOpen(rpmdb, rpmtag, 0);
|
||||
if (dbi != NULL) {
|
||||
xx = dbiCopen(dbi, &dbcursor, 0);
|
||||
xx = dbiDel(dbi, dbcursor, &hdrNum, sizeof(hdrNum), 0);
|
||||
xx = dbiCclose(dbi, dbcursor, 0);
|
||||
dbcursor = NULL;
|
||||
if (!dbi->dbi_no_dbsync)
|
||||
xx = dbiSync(dbi, 0);
|
||||
}
|
||||
continue;
|
||||
/*@notreached@*/ break;
|
||||
}
|
||||
|
@ -1682,6 +1717,7 @@ int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum)
|
|||
continue;
|
||||
|
||||
dbi = dbiOpen(rpmdb, rpmtag, 0);
|
||||
if (dbi != NULL) {
|
||||
xx = dbiCopen(dbi, &dbcursor, 0);
|
||||
|
||||
if (rpmtype == RPM_STRING_TYPE) {
|
||||
|
@ -1749,6 +1785,7 @@ int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int hdrNum)
|
|||
|
||||
if (!dbi->dbi_no_dbsync)
|
||||
xx = dbiSync(dbi, 0);
|
||||
}
|
||||
|
||||
rpmvals = hfd(rpmvals, rpmtype);
|
||||
rpmtype = 0;
|
||||
|
@ -1816,7 +1853,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
|||
int count = 0;
|
||||
dbiIndex dbi;
|
||||
int dbix;
|
||||
unsigned int hdrNum;
|
||||
unsigned int hdrNum = 0;
|
||||
int rc = 0;
|
||||
int xx;
|
||||
|
||||
|
@ -1848,6 +1885,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
|||
size_t datalen = 0;
|
||||
|
||||
dbi = dbiOpen(rpmdb, RPMDBI_PACKAGES, 0);
|
||||
if (dbi != NULL) {
|
||||
|
||||
/* XXX db0: hack to pass sizeof header to fadAlloc */
|
||||
datap = h;
|
||||
|
@ -1877,6 +1915,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
|||
|
||||
xx = dbiCclose(dbi, dbcursor, 0);
|
||||
dbcursor = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1888,8 +1927,10 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
|||
|
||||
/* Now update the indexes */
|
||||
|
||||
if (hdrNum)
|
||||
{ dbiIndexItem rec = dbiIndexNewItem(hdrNum, 0);
|
||||
|
||||
if (dbiTags != NULL)
|
||||
for (dbix = 0; dbix < dbiTagsMax; dbix++) {
|
||||
DBC * dbcursor = NULL;
|
||||
const char *av[1];
|
||||
|
@ -1914,6 +1955,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
|||
/*@notreached@*/ break;
|
||||
case RPMDBI_PACKAGES:
|
||||
dbi = dbiOpen(rpmdb, rpmtag, 0);
|
||||
if (dbi != NULL) {
|
||||
xx = dbiCopen(dbi, &dbcursor, 0);
|
||||
xx = dbiUpdateRecord(dbi, dbcursor, hdrNum, h);
|
||||
xx = dbiCclose(dbi, dbcursor, 0);
|
||||
|
@ -1924,6 +1966,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
|||
(void) headerNVR(h, &n, &v, &r);
|
||||
rpmMessage(RPMMESS_DEBUG, " +++ %10u %s-%s-%s\n", hdrNum, n, v, r);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
/*@notreached@*/ break;
|
||||
/* XXX preserve legacy behavior */
|
||||
|
@ -1952,6 +1995,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
|||
}
|
||||
|
||||
dbi = dbiOpen(rpmdb, rpmtag, 0);
|
||||
if (dbi != NULL) {
|
||||
|
||||
xx = dbiCopen(dbi, &dbcursor, 0);
|
||||
if (rpmtype == RPM_STRING_TYPE) {
|
||||
|
@ -2040,6 +2084,7 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
|||
|
||||
if (!dbi->dbi_no_dbsync)
|
||||
xx = dbiSync(dbi, 0);
|
||||
}
|
||||
|
||||
/*@-observertrans@*/
|
||||
rpmvals = hfd(rpmvals, rpmtype);
|
||||
|
@ -2071,6 +2116,8 @@ int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList,
|
|||
Header h;
|
||||
int i;
|
||||
|
||||
if (rpmdb == NULL) return 0;
|
||||
|
||||
mi = rpmdbInitIterator(rpmdb, RPMTAG_BASENAMES, NULL, 0);
|
||||
|
||||
/* Gather all matches from the database */
|
||||
|
@ -2089,6 +2136,7 @@ int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList,
|
|||
/* iterator is now sorted by (recnum, filenum) */
|
||||
|
||||
/* For each set of files matched in a package ... */
|
||||
if (mi != NULL)
|
||||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
const char ** dirNames;
|
||||
const char ** baseNames;
|
||||
|
@ -2129,11 +2177,14 @@ int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList,
|
|||
|
||||
/* Add db (recnum,filenum) to list for fingerprint matches. */
|
||||
for (i = 0; i < num; i++, im++) {
|
||||
if (FP_EQUAL(fps[i], fpList[im->fpNum]))
|
||||
/*@-nullpass@*/
|
||||
if (FP_EQUAL(fps[i], fpList[im->fpNum])) {
|
||||
/*@=nullpass@*/
|
||||
/*@-usedef@*/
|
||||
(void) dbiAppendSet(matchList[im->fpNum], im, 1, sizeof(*im), 0);
|
||||
/*@=usedef@*/
|
||||
}
|
||||
}
|
||||
|
||||
fps = _free(fps);
|
||||
dirNames = hfd(dirNames, dnt);
|
||||
|
@ -2192,6 +2243,7 @@ static int rpmdbRemoveDatabase(const char * rootdir,
|
|||
|
||||
switch (_dbapi) {
|
||||
case 3:
|
||||
if (dbiTags != NULL)
|
||||
for (i = 0; i < dbiTagsMax; i++) {
|
||||
const char * base = tagName(dbiTags[i]);
|
||||
sprintf(filename, "%s/%s/%s", rootdir, dbpath, base);
|
||||
|
@ -2207,6 +2259,7 @@ static int rpmdbRemoveDatabase(const char * rootdir,
|
|||
case 2:
|
||||
case 1:
|
||||
case 0:
|
||||
if (dbiTags != NULL)
|
||||
for (i = 0; i < dbiTagsMax; i++) {
|
||||
const char * base = db1basename(dbiTags[i]);
|
||||
sprintf(filename, "%s/%s/%s", rootdir, dbpath, base);
|
||||
|
@ -2256,6 +2309,7 @@ static int rpmdbMoveDatabase(const char * rootdir,
|
|||
|
||||
switch (_olddbapi) {
|
||||
case 3:
|
||||
if (dbiTags != NULL)
|
||||
for (i = 0; i < dbiTagsMax; i++) {
|
||||
const char * base;
|
||||
int rpmtag;
|
||||
|
@ -2296,6 +2350,7 @@ static int rpmdbMoveDatabase(const char * rootdir,
|
|||
case 2:
|
||||
case 1:
|
||||
case 0:
|
||||
if (dbiTags != NULL)
|
||||
for (i = 0; i < dbiTagsMax; i++) {
|
||||
const char * base;
|
||||
int rpmtag;
|
||||
|
@ -2358,6 +2413,8 @@ int rpmdbRebuild(const char * rootdir)
|
|||
int _dbapi;
|
||||
int _dbapi_rebuild;
|
||||
|
||||
if (rootdir == NULL) rootdir = "/";
|
||||
|
||||
_dbapi = rpmExpandNumeric("%{_dbapi}");
|
||||
_dbapi_rebuild = rpmExpandNumeric("%{_dbapi_rebuild}");
|
||||
|
||||
|
|
38
lib/rpmdb.h
38
lib/rpmdb.h
|
@ -155,10 +155,10 @@ struct _dbiVec {
|
|||
* Describes an index database (implemented on Berkeley db[123] API).
|
||||
*/
|
||||
struct _dbiIndex {
|
||||
const char * dbi_root;
|
||||
const char * dbi_home;
|
||||
const char * dbi_file;
|
||||
const char * dbi_subfile;
|
||||
/*@null@*/ const char * dbi_root;
|
||||
/*@null@*/ const char * dbi_home;
|
||||
/*@null@*/ const char * dbi_file;
|
||||
/*@null@*/ const char * dbi_subfile;
|
||||
|
||||
int dbi_cflags; /*!< db_create/db_env_create flags */
|
||||
int dbi_oeflags; /*!< common (db,dbenv}->open flags */
|
||||
|
@ -183,7 +183,7 @@ struct _dbiIndex {
|
|||
|
||||
/* dbenv parameters */
|
||||
int dbi_lorder;
|
||||
void (*db_errcall) (const char *db_errpfx, char *buffer);
|
||||
/*@null@*/ void (*db_errcall) (const char *db_errpfx, char *buffer);
|
||||
/*@shared@*/ FILE * dbi_errfile;
|
||||
const char * dbi_errpfx;
|
||||
int dbi_verbose;
|
||||
|
@ -208,19 +208,19 @@ struct _dbiIndex {
|
|||
/* dbinfo parameters */
|
||||
int dbi_cachesize; /*!< */
|
||||
int dbi_pagesize; /*!< (fs blksize) */
|
||||
void * (*dbi_malloc) (size_t nbytes);
|
||||
/*@null@*/ void * (*dbi_malloc) (size_t nbytes);
|
||||
/* hash access parameters */
|
||||
unsigned int dbi_h_ffactor; /*!< */
|
||||
unsigned int (*dbi_h_hash_fcn) (const void *bytes, unsigned int length);
|
||||
/*@null@*/ unsigned int (*dbi_h_hash_fcn) (const void *bytes, unsigned int length);
|
||||
unsigned int dbi_h_nelem; /*!< */
|
||||
unsigned int dbi_h_flags; /*!< DB_DUP, DB_DUPSORT */
|
||||
int (*dbi_h_dup_compare_fcn) (const DBT *, const DBT *);
|
||||
/*@null@*/ int (*dbi_h_dup_compare_fcn) (const DBT *, const DBT *);
|
||||
/* btree access parameters */
|
||||
int dbi_bt_flags;
|
||||
int dbi_bt_minkey;
|
||||
int (*dbi_bt_compare_fcn)(const DBT *, const DBT *);
|
||||
int (*dbi_bt_dup_compare_fcn) (const DBT *, const DBT *);
|
||||
size_t (*dbi_bt_prefix_fcn) (const DBT *, const DBT *);
|
||||
/*@null@*/ int (*dbi_bt_compare_fcn)(const DBT *, const DBT *);
|
||||
/*@null@*/ int (*dbi_bt_dup_compare_fcn) (const DBT *, const DBT *);
|
||||
/*@null@*/ size_t (*dbi_bt_prefix_fcn) (const DBT *, const DBT *);
|
||||
/* recno access parameters */
|
||||
int dbi_re_flags;
|
||||
int dbi_re_delim;
|
||||
|
@ -234,10 +234,10 @@ struct _dbiIndex {
|
|||
|
||||
unsigned int dbi_lastoffset; /*!< db1 with falloc.c needs this */
|
||||
|
||||
void * dbi_db; /*!< dbi handle */
|
||||
void * dbi_dbenv;
|
||||
void * dbi_dbinfo;
|
||||
void * dbi_rmw; /*!< db cursor (with DB_WRITECURSOR) */
|
||||
/*@only@*//*@null@*/ void * dbi_db; /*!< dbi handle */
|
||||
/*@only@*//*@null@*/ void * dbi_dbenv;
|
||||
/*@only@*//*@null@*/ void * dbi_dbinfo;
|
||||
/*@only@*//*@null@*/ void * dbi_rmw; /*!< db cursor (with DB_WRITECURSOR) */
|
||||
|
||||
/*@observer@*/ const struct _dbiVec * dbi_vec; /*!< private methods */
|
||||
|
||||
|
@ -295,7 +295,7 @@ void db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi);
|
|||
* @param print_dbenv_flags format db env flags instead?
|
||||
* @return formatted flags (static buffer)
|
||||
*/
|
||||
/*@exposed@*/ const char *const prDbiOpenFlags(int dbflags,
|
||||
/*@exposed@*/ extern const char *const prDbiOpenFlags(int dbflags,
|
||||
int print_dbenv_flags);
|
||||
|
||||
/** \ingroup dbi
|
||||
|
@ -305,7 +305,7 @@ void db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi);
|
|||
* @param flags (unused)
|
||||
* @return index database handle
|
||||
*/
|
||||
/*@only@*/ /*@null@*/ dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag,
|
||||
/*@only@*/ /*@null@*/ dbiIndex dbiOpen(/*@null@*/ rpmdb rpmdb, int rpmtag,
|
||||
unsigned int flags);
|
||||
|
||||
/** \ingroup dbi
|
||||
|
@ -400,8 +400,8 @@ unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi);
|
|||
/** \ingroup rpmdb
|
||||
* @param rpmdb rpm database
|
||||
*/
|
||||
int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, /*@out@*/dbiIndexSet * matchList,
|
||||
int numItems);
|
||||
int rpmdbFindFpList(/*@null@*/ rpmdb rpmdb, fingerPrint * fpList,
|
||||
/*@out@*/dbiIndexSet * matchList, int numItems);
|
||||
|
||||
/** \ingroup dbi
|
||||
* Destroy set of index database items.
|
||||
|
|
|
@ -79,20 +79,24 @@ static void printHash(const unsigned long amount, const unsigned long total)
|
|||
|
||||
/**
|
||||
*/
|
||||
static void * showProgress(const void * arg, const rpmCallbackType what,
|
||||
static /*@null@*/
|
||||
void * showProgress(/*@null@*/ const void * arg, const rpmCallbackType what,
|
||||
const unsigned long amount,
|
||||
const unsigned long total,
|
||||
const void * pkgKey, void * data)
|
||||
/*@null@*/ const void * pkgKey,
|
||||
/*@null@*/ void * data)
|
||||
{
|
||||
Header h = (Header) arg;
|
||||
char * s;
|
||||
int flags = (int) ((long)data);
|
||||
void * rc = NULL;
|
||||
const char * filename = pkgKey;
|
||||
static FD_t fd;
|
||||
static FD_t fd = NULL;
|
||||
|
||||
switch (what) {
|
||||
case RPMCALLBACK_INST_OPEN_FILE:
|
||||
if (filename == NULL || filename[0] == '\0')
|
||||
return NULL;
|
||||
fd = Fopen(filename, "r.ufdio");
|
||||
if (fd)
|
||||
fd = fdLink(fd, "persist (showProgress)");
|
||||
|
@ -109,10 +113,11 @@ static void * showProgress(const void * arg, const rpmCallbackType what,
|
|||
|
||||
case RPMCALLBACK_INST_START:
|
||||
hashesPrinted = 0;
|
||||
if (!(flags & INSTALL_LABEL))
|
||||
if (h == NULL || !(flags & INSTALL_LABEL))
|
||||
break;
|
||||
if (flags & INSTALL_HASH) {
|
||||
s = headerSprintf(h, "%{NAME}", rpmTagTable, rpmHeaderFormats,NULL);
|
||||
s = headerSprintf(h, "%{NAME}",
|
||||
rpmTagTable, rpmHeaderFormats, NULL);
|
||||
#ifdef FANCY_HASH
|
||||
if (isatty (STDOUT_FILENO))
|
||||
fprintf(stdout, "%4d:%-23.23s", progressCurrent + 1, s);
|
||||
|
@ -121,13 +126,14 @@ static void * showProgress(const void * arg, const rpmCallbackType what,
|
|||
fprintf(stdout, "%-28s", s);
|
||||
#endif
|
||||
(void) fflush(stdout);
|
||||
s = _free(s);
|
||||
} else {
|
||||
s = headerSprintf(h, "%{NAME}-%{VERSION}-%{RELEASE}",
|
||||
rpmTagTable, rpmHeaderFormats, NULL);
|
||||
fprintf(stdout, "%s\n", s);
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
s = _free(s);
|
||||
}
|
||||
break;
|
||||
|
||||
case RPMCALLBACK_TRANS_PROGRESS:
|
||||
|
@ -208,6 +214,8 @@ int rpmInstall(const char * rootdir, const char ** fileArgv,
|
|||
int rc;
|
||||
int i;
|
||||
|
||||
if (fileArgv == NULL) return 0;
|
||||
|
||||
while (defaultReloc && defaultReloc->oldPath)
|
||||
defaultReloc++;
|
||||
if (defaultReloc && !defaultReloc->newPath) defaultReloc = NULL;
|
||||
|
@ -299,7 +307,7 @@ restart:
|
|||
if (numFailed) goto exit;
|
||||
|
||||
/* Continue processing file arguments, building transaction set. */
|
||||
for (fnp = pkgURL+prevx; *fnp; fnp++, prevx++) {
|
||||
for (fnp = pkgURL+prevx; *fnp != NULL; fnp++, prevx++) {
|
||||
const char * fileName;
|
||||
rpmRC rpmrc;
|
||||
int isSource;
|
||||
|
@ -452,7 +460,7 @@ restart:
|
|||
rc = rpmReadPackageManifest(fd, &argc, &argv);
|
||||
if (rc)
|
||||
rpmError(RPMERR_MANIFEST, _("%s: read manifest failed: %s\n"),
|
||||
fileURL, Fstrerror(fd));
|
||||
*fnp, Fstrerror(fd));
|
||||
(void) Fclose(fd);
|
||||
|
||||
/* If successful, restart the query loop. */
|
||||
|
@ -565,6 +573,8 @@ int rpmErase(const char * rootdir, const char ** argv,
|
|||
int numPackages = 0;
|
||||
rpmProblemSet probs;
|
||||
|
||||
if (argv == NULL) return 0;
|
||||
|
||||
if (transFlags & RPMTRANS_FLAG_TEST)
|
||||
mode = O_RDONLY;
|
||||
else
|
||||
|
@ -649,8 +659,11 @@ int rpmInstallSource(const char * rootdir, const char * arg,
|
|||
if (rpmIsVerbose())
|
||||
fprintf(stdout, _("Installing %s\n"), arg);
|
||||
|
||||
{ rpmRC rpmrc = rpmInstallSourcePackage(rootdir, fd, specFile, NULL, NULL,
|
||||
{
|
||||
/*@-mayaliasunique@*/
|
||||
rpmRC rpmrc = rpmInstallSourcePackage(rootdir, fd, specFile, NULL, NULL,
|
||||
cookie);
|
||||
/*@=mayaliasunique@*/
|
||||
rc = (rpmrc == RPMRC_OK ? 0 : 1);
|
||||
}
|
||||
if (rc != 0) {
|
||||
|
|
138
lib/rpmlib.h
138
lib/rpmlib.h
|
@ -442,7 +442,7 @@ typedef enum rpmsenseFlags_e {
|
|||
* @deprecated Use rpmExpand() with appropriate macro expression.
|
||||
* @todo Eliminate from API.
|
||||
*/
|
||||
const char * rpmGetVar(int var);
|
||||
/*@observer@*/ /*@null@*/ const char * rpmGetVar(int var) /*@*/;
|
||||
|
||||
/** \ingroup rpmrc
|
||||
* Set value of an rpmrc variable.
|
||||
|
@ -476,7 +476,8 @@ enum rpm_machtable_e {
|
|||
* @param target target platform (NULL uses default)
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
int rpmReadConfigFiles(const char * file, const char * target);
|
||||
int rpmReadConfigFiles(/*@null@*/ const char * file,
|
||||
/*@null@*/ const char * target);
|
||||
|
||||
/** \ingroup rpmrc
|
||||
* Read rpmrc (and macro) configuration file(s).
|
||||
|
@ -491,7 +492,9 @@ int rpmReadRC(const char * file);
|
|||
* @retval name address of arch name (or NULL)
|
||||
* @retval num address of arch number (or NULL)
|
||||
*/
|
||||
void rpmGetArchInfo( /*@out@*/ const char ** name, /*@out@*/ int * num);
|
||||
void rpmGetArchInfo( /*@null@*/ /*@out@*/ const char ** name,
|
||||
/*@null@*/ /*@out@*/ int * num)
|
||||
/*@modifies *name, *num @*/;
|
||||
|
||||
/** \ingroup rpmrc
|
||||
* Return current os name and/or number.
|
||||
|
@ -499,7 +502,9 @@ void rpmGetArchInfo( /*@out@*/ const char ** name, /*@out@*/ int * num);
|
|||
* @retval name address of os name (or NULL)
|
||||
* @retval num address of os number (or NULL)
|
||||
*/
|
||||
void rpmGetOsInfo( /*@out@*/ const char ** name, /*@out@*/ int * num);
|
||||
void rpmGetOsInfo( /*@null@*/ /*@out@*/ const char ** name,
|
||||
/*@null@*/ /*@out@*/ int * num)
|
||||
/*@modifies *name, *num @*/;
|
||||
|
||||
/** \ingroup rpmrc
|
||||
* Return arch/os score of a name.
|
||||
|
@ -541,7 +546,7 @@ void rpmSetTables(int archTable, int osTable); /* only used by build code */
|
|||
* @param arch arch name (or NULL)
|
||||
* @param os os name (or NULL)
|
||||
*/
|
||||
void rpmSetMachine(const char * arch, const char * os);
|
||||
void rpmSetMachine(/*@null@*/ const char * arch, /*@null@*/ const char * os);
|
||||
|
||||
/** \ingroup rpmrc
|
||||
* Return current arch/os names.
|
||||
|
@ -551,7 +556,9 @@ void rpmSetMachine(const char * arch, const char * os);
|
|||
* @retval arch address of arch name (or NULL)
|
||||
* @retval os address of os name (or NULL)
|
||||
*/
|
||||
void rpmGetMachine( /*@out@*/ const char **arch, /*@out@*/ const char **os);
|
||||
void rpmGetMachine( /*@null@*/ /*@out@*/ const char **arch,
|
||||
/*@null@*/ /*@out@*/ const char **os)
|
||||
/*@modifies *arch, *os @*/;
|
||||
|
||||
/** \ingroup rpmrc
|
||||
* Destroy rpmrc arch/os compatibility tables.
|
||||
|
@ -579,7 +586,9 @@ typedef /*@abstract@*/ struct _dbiIndexSet * dbiIndexSet;
|
|||
* @param perms database permissions
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmdbOpen (const char * root, /*@out@*/ rpmdb * dbp, int mode, int perms);
|
||||
int rpmdbOpen (/*@null@*/ const char * root, /*@null@*/ /*@out@*/ rpmdb * dbp,
|
||||
int mode, int perms)
|
||||
/*@modifies *dbp, fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Initialize database.
|
||||
|
@ -587,28 +596,32 @@ int rpmdbOpen (const char * root, /*@out@*/ rpmdb * dbp, int mode, int perms);
|
|||
* @param perms database permissions
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmdbInit(const char * root, int perms);
|
||||
int rpmdbInit(/*@null@*/ const char * root, int perms)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Close all database indices and free rpmdb.
|
||||
* @param rpmdb rpm database
|
||||
* @return 0 always
|
||||
*/
|
||||
int rpmdbClose ( /*@only@*/ rpmdb rpmdb);
|
||||
int rpmdbClose (/*@only@*/ /*@null@*/ rpmdb rpmdb)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Sync all database indices.
|
||||
* @param rpmdb rpm database
|
||||
* @return 0 always
|
||||
*/
|
||||
int rpmdbSync (rpmdb rpmdb);
|
||||
int rpmdbSync (/*@null@*/ rpmdb rpmdb)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Open all database indices.
|
||||
* @param rpmdb rpm database
|
||||
* @return 0 always
|
||||
*/
|
||||
int rpmdbOpenAll (rpmdb rpmdb);
|
||||
int rpmdbOpenAll (/*@null@*/ rpmdb rpmdb)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Return number of instances of package in rpm database.
|
||||
|
@ -616,7 +629,8 @@ int rpmdbOpenAll (rpmdb rpmdb);
|
|||
* @param name rpm package name
|
||||
* @return number of instances
|
||||
*/
|
||||
int rpmdbCountPackages(rpmdb db, const char *name);
|
||||
int rpmdbCountPackages(rpmdb db, const char * name)
|
||||
/*@*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
*/
|
||||
|
@ -627,7 +641,8 @@ typedef /*@abstract@*/ struct _rpmdbMatchIterator * rpmdbMatchIterator;
|
|||
* @param mi rpm database iterator
|
||||
* @return NULL always
|
||||
*/
|
||||
rpmdbMatchIterator rpmdbFreeIterator(/*@only@*//*@null@*/rpmdbMatchIterator mi)
|
||||
/*@null@*/ rpmdbMatchIterator rpmdbFreeIterator(
|
||||
/*@only@*//*@null@*/rpmdbMatchIterator mi)
|
||||
/*@modifies mi @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
|
@ -635,21 +650,21 @@ rpmdbMatchIterator rpmdbFreeIterator(/*@only@*//*@null@*/rpmdbMatchIterator mi)
|
|||
* @param mi rpm database iterator
|
||||
* @return rpm database handle
|
||||
*/
|
||||
/*@kept@*/ rpmdb rpmdbGetIteratorRpmDB(rpmdbMatchIterator mi) /*@*/;
|
||||
/*@kept@*/ rpmdb rpmdbGetIteratorRpmDB(/*@null@*/ rpmdbMatchIterator mi) /*@*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Return join key for current position of rpm database iterator.
|
||||
* @param mi rpm database iterator
|
||||
* @return current join key
|
||||
*/
|
||||
unsigned int rpmdbGetIteratorOffset(rpmdbMatchIterator mi) /*@*/;
|
||||
unsigned int rpmdbGetIteratorOffset(/*@null@*/ rpmdbMatchIterator mi) /*@*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Return number of elements in rpm database iterator.
|
||||
* @param mi rpm database iterator
|
||||
* @return number of elements
|
||||
*/
|
||||
int rpmdbGetIteratorCount(rpmdbMatchIterator mi) /*@*/;
|
||||
int rpmdbGetIteratorCount(/*@null@*/ rpmdbMatchIterator mi) /*@*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Append items to set of package instances to iterate.
|
||||
|
@ -658,8 +673,8 @@ int rpmdbGetIteratorCount(rpmdbMatchIterator mi) /*@*/;
|
|||
* @param nHdrNums number of elements in array
|
||||
* @return 0 on success, 1 on failure (bad args)
|
||||
*/
|
||||
int rpmdbAppendIterator(rpmdbMatchIterator mi, const int * hdrNums,
|
||||
int nHdrNums)
|
||||
int rpmdbAppendIterator(/*@null@*/ rpmdbMatchIterator mi,
|
||||
/*@null@*/ const int * hdrNums, int nHdrNums)
|
||||
/*@modifies mi @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
|
@ -670,8 +685,8 @@ int rpmdbAppendIterator(rpmdbMatchIterator mi, const int * hdrNums,
|
|||
* @param sorted is the array sorted? (array will be sorted on return)
|
||||
* @return 0 on success, 1 on failure (bad args)
|
||||
*/
|
||||
int rpmdbPruneIterator(rpmdbMatchIterator mi, int * hdrNums,
|
||||
int nHdrNums, int sorted)
|
||||
int rpmdbPruneIterator(/*@null@*/ rpmdbMatchIterator mi,
|
||||
/*@null@*/ int * hdrNums, int nHdrNums, int sorted)
|
||||
/*@modifies mi @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
|
@ -680,7 +695,8 @@ int rpmdbPruneIterator(rpmdbMatchIterator mi, int * hdrNums,
|
|||
* @param mi rpm database iterator
|
||||
* @param version version to check for
|
||||
*/
|
||||
void rpmdbSetIteratorVersion(rpmdbMatchIterator mi, const char * version)
|
||||
void rpmdbSetIteratorVersion(/*@null@*/ rpmdbMatchIterator mi,
|
||||
/*@null@*/ const char * version)
|
||||
/*@modifies mi @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
|
@ -689,7 +705,8 @@ void rpmdbSetIteratorVersion(rpmdbMatchIterator mi, const char * version)
|
|||
* @param mi rpm database iterator
|
||||
* @param release release to check for
|
||||
*/
|
||||
void rpmdbSetIteratorRelease(rpmdbMatchIterator mi, const char * release)
|
||||
void rpmdbSetIteratorRelease(/*@null@*/ rpmdbMatchIterator mi,
|
||||
/*@null@*/ const char * release)
|
||||
/*@modifies mi @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
|
@ -698,7 +715,7 @@ void rpmdbSetIteratorRelease(rpmdbMatchIterator mi, const char * release)
|
|||
* @param modified new value of modified
|
||||
* @return previous value
|
||||
*/
|
||||
int rpmdbSetIteratorModified(rpmdbMatchIterator mi, int modified)
|
||||
int rpmdbSetIteratorModified(/*@null@*/ rpmdbMatchIterator mi, int modified)
|
||||
/*@modifies mi @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
|
@ -723,8 +740,9 @@ int rpmdbSetIteratorModified(rpmdbMatchIterator mi, int modified)
|
|||
* @return NULL on failure
|
||||
*/
|
||||
/*@only@*/ /*@null@*/ rpmdbMatchIterator rpmdbInitIterator(
|
||||
/*@kept@*/ rpmdb rpmdb, int rpmtag,
|
||||
const void * key, size_t keylen);
|
||||
/*@kept@*/ /*@null@*/ rpmdb rpmdb, int rpmtag,
|
||||
/*@null@*/ const void * key, size_t keylen)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Add package header to rpm database and indices.
|
||||
|
@ -734,7 +752,7 @@ int rpmdbSetIteratorModified(rpmdbMatchIterator mi, int modified)
|
|||
* @return 0 on success
|
||||
*/
|
||||
int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
||||
/*@modifies h @*/;
|
||||
/*@modifies h, fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Remove package header from rpm database and indices.
|
||||
|
@ -743,13 +761,15 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
|
|||
* @param offset location in Packages dbi
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmdbRemove(rpmdb db, int rid, unsigned int offset);
|
||||
int rpmdbRemove(rpmdb rpmdb, int rid, unsigned int offset)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmdb
|
||||
* Rebuild database indices from package headers.
|
||||
* @param root path to top of install tree
|
||||
*/
|
||||
int rpmdbRebuild(const char * root);
|
||||
int rpmdbRebuild(/*@null@*/ const char * root)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/*@}*/
|
||||
/* ==================================================================== */
|
||||
|
@ -779,11 +799,11 @@ typedef enum rpmProblemType_e {
|
|||
typedef /*@abstract@*/ struct rpmProblem_s {
|
||||
/*@only@*/ /*@null@*/ const char * pkgNEVR;
|
||||
/*@only@*/ /*@null@*/ const char * altNEVR;
|
||||
/*@kept@*/ const void * key;
|
||||
Header h;
|
||||
/*@kept@*/ /*@null@*/ const void * key;
|
||||
/*@null@*/ Header h;
|
||||
rpmProblemType type;
|
||||
int ignoreProblem;
|
||||
/*@only@*/ const char * str1;
|
||||
/*@only@*/ /*@null@*/ const char * str1;
|
||||
unsigned long ulong1;
|
||||
} * rpmProblem;
|
||||
|
||||
|
@ -867,8 +887,9 @@ typedef /*@null@*/
|
|||
/**
|
||||
* Prototype for headerGetEntry() vector.
|
||||
*/
|
||||
typedef int (*HGE_t) (Header h, int_32 tag, /*@out@*/ int_32 * type,
|
||||
/*@out@*/ void ** p, /*@out@*/int_32 * c)
|
||||
typedef int (*HGE_t) (Header h, int_32 tag, /*@null@*/ /*@out@*/ int_32 * type,
|
||||
/*@null@*/ /*@out@*/ void ** p,
|
||||
/*@null@*/ /*@out@*/int_32 * c)
|
||||
/*@modifies *type, *p, *c @*/;
|
||||
|
||||
/**
|
||||
|
@ -1284,10 +1305,10 @@ int rpmGetFilesystemUsage(const char ** filelist, int_32 * fssizes,
|
|||
/** \ingroup rpmcli
|
||||
* Describe build command line request.
|
||||
*/
|
||||
struct rpmBuildArguments {
|
||||
struct rpmBuildArguments_s {
|
||||
int buildAmount; /*!< Bit(s) to control operation. */
|
||||
const char *buildRootOverride; /*!< from --buildroot */
|
||||
char *targets; /*!< Target platform(s), comma separated. */
|
||||
/*@null@*/ const char * buildRootOverride; /*!< from --buildroot */
|
||||
/*@null@*/ char * targets; /*!< Target platform(s), comma separated. */
|
||||
int force; /*!< from --force */
|
||||
int noBuild; /*!< from --nobuild */
|
||||
int noDeps; /*!< from --nodeps */
|
||||
|
@ -1297,15 +1318,15 @@ struct rpmBuildArguments {
|
|||
int useCatalog; /*!< from --usecatalog */
|
||||
char buildMode; /*!< Build mode (one of "btBC") */
|
||||
char buildChar; /*!< Build stage (one of "abcilps ") */
|
||||
/*@dependent@*/ const char *rootdir;
|
||||
/*@dependent@*/ /*@null@*/ const char * rootdir;
|
||||
};
|
||||
/** \ingroup rpmcli
|
||||
*/
|
||||
typedef struct rpmBuildArguments BTA_t;
|
||||
typedef struct rpmBuildArguments_s * BTA_t;
|
||||
|
||||
/** \ingroup rpmcli
|
||||
*/
|
||||
extern struct rpmBuildArguments rpmBTArgs;
|
||||
extern struct rpmBuildArguments_s rpmBTArgs;
|
||||
|
||||
/** \ingroup rpmcli
|
||||
*/
|
||||
|
@ -1357,7 +1378,7 @@ int rpmVerifyFile(const char * root, Header h, int filenum,
|
|||
* @param scriptFd file handle to use for stderr (or NULL)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmVerifyScript(const char * rootDir, Header h, FD_t scriptFd);
|
||||
int rpmVerifyScript(const char * rootDir, Header h, /*@null@*/ FD_t scriptFd);
|
||||
|
||||
/** \ingroup rpmcli
|
||||
* The command line argument will be used to retrieve header(s) ...
|
||||
|
@ -1399,20 +1420,20 @@ typedef enum rpmVerifyFlags_e {
|
|||
/** \ingroup rpmcli
|
||||
* Describe query/verify command line request.
|
||||
*/
|
||||
typedef struct rpmQVArguments {
|
||||
typedef struct rpmQVArguments_s {
|
||||
rpmQVSources qva_source; /*!< Identify CLI arg type. */
|
||||
int qva_sourceCount;/*!< Exclusive check (>1 is error). */
|
||||
int qva_flags; /*!< Bit(s) to control operation. */
|
||||
int qva_verbose; /*!< (unused) */
|
||||
/*@only@*/ const char *qva_queryFormat;/*!< Format for headerSprintf(). */
|
||||
/*@dependent@*/ const char *qva_prefix; /*!< Path to top of install tree. */
|
||||
/*@only@*/ /*@null@*/ const char * qva_queryFormat; /*!< Format for headerSprintf(). */
|
||||
/*@dependent@*/ /*@null@*/ 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;
|
||||
} * QVA_t;
|
||||
|
||||
/** \ingroup rpmcli
|
||||
*/
|
||||
extern QVA_t rpmQVArgs;
|
||||
extern struct rpmQVArguments_s rpmQVArgs;
|
||||
|
||||
/** \ingroup rpmcli
|
||||
*/
|
||||
|
@ -1423,7 +1444,7 @@ extern struct poptOption rpmQVSourcePoptTable[];
|
|||
* @param db rpm database
|
||||
* @param h header to use for query/verify
|
||||
*/
|
||||
typedef int (*QVF_t) (QVA_t *qva, rpmdb db, Header h);
|
||||
typedef int (*QVF_t) (QVA_t qva, rpmdb db, Header h);
|
||||
|
||||
/** \ingroup rpmcli
|
||||
* Display query/verify information for each header in iterator.
|
||||
|
@ -1432,7 +1453,7 @@ typedef int (*QVF_t) (QVA_t *qva, rpmdb db, Header h);
|
|||
* @param showPackage query/verify display routine
|
||||
* @return result of last non-zero showPackage() return
|
||||
*/
|
||||
int showMatches(QVA_t *qva, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi,
|
||||
int showMatches(QVA_t qva, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi,
|
||||
QVF_t showPackage);
|
||||
|
||||
/** \ingroup rpmcli
|
||||
|
@ -1458,7 +1479,7 @@ void rpmDisplayQueryTags(FILE * f);
|
|||
* @param showPackage query/verify specific display routine
|
||||
* @return showPackage() result, 1 if rpmdbInitIterator() is NULL
|
||||
*/
|
||||
int rpmQueryVerify(QVA_t *qva, rpmQVSources source, const char * arg,
|
||||
int rpmQueryVerify(QVA_t qva, rpmQVSources source, const char * arg,
|
||||
rpmdb db, QVF_t showPackage);
|
||||
|
||||
/** \ingroup rpmcli
|
||||
|
@ -1469,7 +1490,7 @@ int rpmQueryVerify(QVA_t *qva, rpmQVSources source, const char * arg,
|
|||
* @param h header to use for query
|
||||
* @return 0 always
|
||||
*/
|
||||
int showQueryPackage(QVA_t *qva, rpmdb db, Header h);
|
||||
int showQueryPackage(QVA_t qva, rpmdb db, Header h);
|
||||
|
||||
/** \ingroup rpmcli
|
||||
* Display package information.
|
||||
|
@ -1478,7 +1499,7 @@ int showQueryPackage(QVA_t *qva, rpmdb db, Header h);
|
|||
* @param arg name of source to query
|
||||
* @return rpmQueryVerify() result, or 1 on rpmdbOpen() failure
|
||||
*/
|
||||
int rpmQuery(QVA_t *qva, rpmQVSources source, const char * arg);
|
||||
int rpmQuery(QVA_t qva, rpmQVSources source, const char * arg);
|
||||
|
||||
/** \ingroup rpmcli
|
||||
*/
|
||||
|
@ -1491,7 +1512,7 @@ extern struct poptOption rpmVerifyPoptTable[];
|
|||
* @param h header to use for verify
|
||||
* @return result of last non-zero verify return
|
||||
*/
|
||||
int showVerifyPackage(QVA_t *qva, /*@only@*/ rpmdb db, Header h);
|
||||
int showVerifyPackage(QVA_t qva, /*@only@*/ rpmdb db, Header h);
|
||||
|
||||
/** \ingroup rpmcli
|
||||
* Verify package install.
|
||||
|
@ -1500,7 +1521,7 @@ int showVerifyPackage(QVA_t *qva, /*@only@*/ rpmdb db, Header h);
|
|||
* @param arg name of source to verify
|
||||
* @return rpmQueryVerify() result, or 1 on rpmdbOpen() failure
|
||||
*/
|
||||
int rpmVerify(QVA_t *qva, rpmQVSources source, const char *arg);
|
||||
int rpmVerify(QVA_t qva, rpmQVSources source, const char *arg);
|
||||
|
||||
/*@}*/
|
||||
/* ==================================================================== */
|
||||
|
@ -1532,11 +1553,11 @@ typedef enum rpmInstallInterfaceFlags_e {
|
|||
* @param relocations package file relocations
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmInstall(const char * rootdir, const char ** argv,
|
||||
int rpmInstall(/*@null@*/ const char * rootdir, /*@null@*/ const char ** argv,
|
||||
rpmtransFlags transFlags,
|
||||
rpmInstallInterfaceFlags interfaceFlags,
|
||||
rpmprobFilterFlags probFilter,
|
||||
rpmRelocation * relocations);
|
||||
/*@null@*/ rpmRelocation * relocations);
|
||||
|
||||
/** \ingroup rpmcli
|
||||
* Install source rpm package.
|
||||
|
@ -1566,7 +1587,7 @@ typedef enum rpmEraseInterfaceFlags_e {
|
|||
* @param interfaceFlags bits to control rpmInstall()
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmErase(const char * rootdir, const char ** argv,
|
||||
int rpmErase(/*@null@*/ const char * rootdir, /*@null@*/ const char ** argv,
|
||||
rpmtransFlags transFlags,
|
||||
rpmEraseInterfaceFlags interfaceFlags);
|
||||
|
||||
|
@ -1656,7 +1677,8 @@ typedef enum rpmCheckSigFlags_e {
|
|||
* @param argv array of package file names (NULL terminated)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmCheckSig(rpmCheckSigFlags flags, const char ** argv);
|
||||
int rpmCheckSig(rpmCheckSigFlags flags, /*@null@*/ const char ** argv)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/** \ingroup rpmcli
|
||||
* Bit(s) to control rpmReSign() operation.
|
||||
|
@ -1673,7 +1695,9 @@ typedef enum rpmResignFlags_e {
|
|||
* @param argv array of package file names (NULL terminated)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmReSign(rpmResignFlags add, char *passPhrase, const char ** argv);
|
||||
int rpmReSign(rpmResignFlags add, char * passPhrase,
|
||||
/*@null@*/ const char ** argv)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
|
178
lib/rpmrc.c
178
lib/rpmrc.c
|
@ -22,27 +22,27 @@ const char * macrofiles = MACROFILES;
|
|||
|
||||
typedef /*@owned@*/ const char * cptr_t;
|
||||
|
||||
struct machCacheEntry {
|
||||
typedef struct machCacheEntry_s {
|
||||
const char * name;
|
||||
int count;
|
||||
cptr_t * equivs;
|
||||
int visited;
|
||||
};
|
||||
} * machCacheEntry;
|
||||
|
||||
struct machCache {
|
||||
struct machCacheEntry * cache;
|
||||
typedef struct machCache_s {
|
||||
machCacheEntry cache;
|
||||
int size;
|
||||
};
|
||||
} * machCache;
|
||||
|
||||
struct machEquivInfo {
|
||||
typedef struct machEquivInfo_s {
|
||||
const char * name;
|
||||
int score;
|
||||
};
|
||||
} * machEquivInfo;
|
||||
|
||||
struct machEquivTable {
|
||||
typedef struct machEquivTable_s {
|
||||
int count;
|
||||
struct machEquivInfo * list;
|
||||
};
|
||||
machEquivInfo list;
|
||||
} * machEquivTable;
|
||||
|
||||
struct rpmvarValue {
|
||||
const char * value;
|
||||
|
@ -58,35 +58,35 @@ struct rpmOption {
|
|||
struct rpmOptionValue * value;
|
||||
};
|
||||
|
||||
struct defaultEntry {
|
||||
/*@owned@*/ const char * name;
|
||||
/*@owned@*/ const char * defName;
|
||||
};
|
||||
typedef struct defaultEntry_s {
|
||||
/*@owned@*/ /*@null@*/ const char * name;
|
||||
/*@owned@*/ /*@null@*/ const char * defName;
|
||||
} * defaultEntry;
|
||||
|
||||
struct canonEntry {
|
||||
typedef struct canonEntry_s {
|
||||
/*@owned@*/ const char * name;
|
||||
/*@owned@*/ const char * short_name;
|
||||
short num;
|
||||
};
|
||||
} * canonEntry;
|
||||
|
||||
/* tags are 'key'canon, 'key'translate, 'key'compat
|
||||
*
|
||||
* for giggles, 'key'_canon, 'key'_compat, and 'key'_canon will also work
|
||||
*/
|
||||
struct tableType {
|
||||
typedef struct tableType_s {
|
||||
const char * const key;
|
||||
const int hasCanon;
|
||||
const int hasTranslate;
|
||||
struct machEquivTable equiv;
|
||||
struct machCache cache;
|
||||
struct defaultEntry * defaults;
|
||||
struct canonEntry * canons;
|
||||
struct machEquivTable_s equiv;
|
||||
struct machCache_s cache;
|
||||
defaultEntry defaults;
|
||||
canonEntry canons;
|
||||
int defaultsLength;
|
||||
int canonsLength;
|
||||
};
|
||||
} * tableType;
|
||||
|
||||
/*@-fullinitblock@*/
|
||||
static struct tableType tables[RPM_MACHTABLE_COUNT] = {
|
||||
static struct tableType_s tables[RPM_MACHTABLE_COUNT] = {
|
||||
{ "arch", 1, 0 },
|
||||
{ "os", 1, 0 },
|
||||
{ "buildarch", 0, 1 },
|
||||
|
@ -115,18 +115,22 @@ static int defaultsInitialized = 0;
|
|||
|
||||
/* prototypes */
|
||||
static int doReadRC( /*@killref@*/ FD_t fd, const char * urlfn);
|
||||
static void rpmSetVarArch(int var, const char * val, const char * arch);
|
||||
static void rebuildCompatTables(int type, const char *name);
|
||||
static void rpmSetVarArch(int var, const char * val,
|
||||
/*@null@*/ const char * arch);
|
||||
static void rebuildCompatTables(int type, const char * name);
|
||||
|
||||
static int optionCompare(const void * a, const void * b) {
|
||||
static int optionCompare(const void * a, const void * b)
|
||||
/*@*/
|
||||
{
|
||||
return xstrcasecmp(((struct rpmOption *) a)->name,
|
||||
((struct rpmOption *) b)->name);
|
||||
}
|
||||
|
||||
static void rpmRebuildTargetVars(const char **target, const char ** canontarget);
|
||||
static void rpmRebuildTargetVars(/*@null@*/ const char **target, /*@null@*/ const char ** canontarget);
|
||||
|
||||
static /*@observer@*/ struct machCacheEntry *
|
||||
machCacheFindEntry(struct machCache * cache, const char * key)
|
||||
static /*@observer@*/ /*@null@*/ machCacheEntry
|
||||
machCacheFindEntry(const machCache cache, const char * key)
|
||||
/*@*/
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -137,12 +141,12 @@ machCacheFindEntry(struct machCache * cache, const char * key)
|
|||
}
|
||||
|
||||
static int machCompatCacheAdd(char * name, const char * fn, int linenum,
|
||||
struct machCache * cache)
|
||||
machCache cache)
|
||||
{
|
||||
char * chptr, * equivs;
|
||||
int delEntry = 0;
|
||||
int i;
|
||||
struct machCacheEntry * entry = NULL;
|
||||
machCacheEntry entry = NULL;
|
||||
|
||||
while (*name && xisspace(*name)) name++;
|
||||
|
||||
|
@ -203,8 +207,8 @@ static int machCompatCacheAdd(char * name, const char * fn, int linenum,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static /*@observer@*/ struct machEquivInfo *
|
||||
machEquivSearch(const struct machEquivTable * table, const char * name)
|
||||
static /*@observer@*/ /*@null@*/ machEquivInfo
|
||||
machEquivSearch(const machEquivTable table, const char * name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -215,10 +219,11 @@ static /*@observer@*/ struct machEquivInfo *
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void machAddEquiv(struct machEquivTable * table, const char * name,
|
||||
static void machAddEquiv(machEquivTable table, const char * name,
|
||||
int distance)
|
||||
/*@modifies table->list, table->count @*/
|
||||
{
|
||||
struct machEquivInfo * equiv;
|
||||
machEquivInfo equiv;
|
||||
|
||||
equiv = machEquivSearch(table, name);
|
||||
if (!equiv) {
|
||||
|
@ -233,12 +238,12 @@ static void machAddEquiv(struct machEquivTable * table, const char * name,
|
|||
}
|
||||
}
|
||||
|
||||
static void machCacheEntryVisit(struct machCache * cache,
|
||||
struct machEquivTable * table,
|
||||
static void machCacheEntryVisit(machCache cache,
|
||||
machEquivTable table,
|
||||
const char * name,
|
||||
int distance)
|
||||
{
|
||||
struct machCacheEntry * entry;
|
||||
machCacheEntry entry;
|
||||
int i;
|
||||
|
||||
entry = machCacheFindEntry(cache, name);
|
||||
|
@ -255,8 +260,7 @@ static void machCacheEntryVisit(struct machCache * cache,
|
|||
}
|
||||
}
|
||||
|
||||
static void machFindEquivs(struct machCache * cache,
|
||||
struct machEquivTable * table,
|
||||
static void machFindEquivs(machCache cache, machEquivTable table,
|
||||
const char * key)
|
||||
{
|
||||
int i;
|
||||
|
@ -276,14 +280,17 @@ static void machFindEquivs(struct machCache * cache,
|
|||
* Yuck. We have to start at a point at traverse it, remembering how
|
||||
* far away everything is.
|
||||
*/
|
||||
/*@-nullstate@*/ /* FIX: table->list may be NULL. */
|
||||
machAddEquiv(table, key, 1);
|
||||
machCacheEntryVisit(cache, table, key, 2);
|
||||
return;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
|
||||
static int addCanon(struct canonEntry ** table, int * tableLen, char * line,
|
||||
static int addCanon(canonEntry * table, int * tableLen, char * line,
|
||||
const char * fn, int lineNum)
|
||||
{
|
||||
struct canonEntry *t;
|
||||
canonEntry t;
|
||||
char *s, *s1;
|
||||
const char * tname;
|
||||
const char * tshort_name;
|
||||
|
@ -291,11 +298,11 @@ static int addCanon(struct canonEntry ** table, int * tableLen, char * line,
|
|||
|
||||
if (! *tableLen) {
|
||||
*tableLen = 2;
|
||||
*table = xmalloc(2 * sizeof(struct canonEntry));
|
||||
*table = xmalloc(2 * sizeof(struct canonEntry_s));
|
||||
} else {
|
||||
(*tableLen) += 2;
|
||||
/*@-unqualifiedtrans@*/
|
||||
*table = xrealloc(*table, sizeof(struct canonEntry) * (*tableLen));
|
||||
*table = xrealloc(*table, sizeof(struct canonEntry_s) * (*tableLen));
|
||||
/*@=unqualifiedtrans@*/
|
||||
}
|
||||
t = & ((*table)[*tableLen - 2]);
|
||||
|
@ -314,38 +321,40 @@ static int addCanon(struct canonEntry ** table, int * tableLen, char * line,
|
|||
return RPMERR_RPMRC;
|
||||
}
|
||||
|
||||
/*@-nullpass@*/ /* LCL: s != NULL here. */
|
||||
tnum = strtoul(s, &s1, 10);
|
||||
if ((*s1) || (s1 == s) || (tnum == ULONG_MAX)) {
|
||||
rpmError(RPMERR_RPMRC, _("Bad arch/os number: %s (%s:%d)\n"), s,
|
||||
fn, lineNum);
|
||||
return(RPMERR_RPMRC);
|
||||
}
|
||||
/*@=nullpass@*/
|
||||
|
||||
t[0].name = xstrdup(tname);
|
||||
t[0].short_name = xstrdup(tshort_name);
|
||||
t[0].short_name = (tshort_name ? xstrdup(tshort_name) : xstrdup(""));
|
||||
t[0].num = tnum;
|
||||
|
||||
/* From A B C entry */
|
||||
/* Add B B C entry */
|
||||
t[1].name = xstrdup(tshort_name);
|
||||
t[1].short_name = xstrdup(tshort_name);
|
||||
t[1].name = (tshort_name ? xstrdup(tshort_name) : xstrdup(""));
|
||||
t[1].short_name = (tshort_name ? xstrdup(tshort_name) : xstrdup(""));
|
||||
t[1].num = tnum;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int addDefault(struct defaultEntry **table, int *tableLen, char *line,
|
||||
static int addDefault(defaultEntry *table, int *tableLen, char *line,
|
||||
const char *fn, int lineNum)
|
||||
{
|
||||
struct defaultEntry *t;
|
||||
defaultEntry t;
|
||||
|
||||
if (! *tableLen) {
|
||||
*tableLen = 1;
|
||||
*table = xmalloc(sizeof(struct defaultEntry));
|
||||
*table = xmalloc(sizeof(struct defaultEntry_s));
|
||||
} else {
|
||||
(*tableLen)++;
|
||||
/*@-unqualifiedtrans@*/
|
||||
*table = xrealloc(*table, sizeof(struct defaultEntry) * (*tableLen));
|
||||
*table = xrealloc(*table, sizeof(struct defaultEntry_s) * (*tableLen));
|
||||
/*@=unqualifiedtrans@*/
|
||||
}
|
||||
t = & ((*table)[*tableLen - 1]);
|
||||
|
@ -365,14 +374,15 @@ static int addDefault(struct defaultEntry **table, int *tableLen, char *line,
|
|||
}
|
||||
|
||||
t->name = xstrdup(t->name);
|
||||
t->defName = xstrdup(t->defName);
|
||||
t->defName = (t->defName ? xstrdup(t->defName) : NULL);
|
||||
/*@=temptrans@*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static /*@null@*/ const struct canonEntry *lookupInCanonTable(const char *name,
|
||||
const struct canonEntry *table, int tableLen)
|
||||
static /*@null@*/ const canonEntry lookupInCanonTable(const char *name,
|
||||
const canonEntry table, int tableLen)
|
||||
/*@*/
|
||||
{
|
||||
while (tableLen) {
|
||||
tableLen--;
|
||||
|
@ -386,15 +396,15 @@ static /*@null@*/ const struct canonEntry *lookupInCanonTable(const char *name,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static /*@observer@*/ const char * lookupInDefaultTable(const char *name,
|
||||
const struct defaultEntry *table, int tableLen)
|
||||
static /*@observer@*/ /*@null@*/
|
||||
const char * lookupInDefaultTable(const char *name,
|
||||
const defaultEntry table, int tableLen)
|
||||
{
|
||||
while (tableLen) {
|
||||
tableLen--;
|
||||
if (!strcmp(name, table[tableLen].name)) {
|
||||
if (table[tableLen].name && !strcmp(name, table[tableLen].name))
|
||||
return table[tableLen].defName;
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
@ -422,7 +432,8 @@ int rpmReadConfigFiles(const char * file, const char * target)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void setVarDefault(int var, const char *macroname, const char *val, const char *body)
|
||||
static void setVarDefault(int var, const char *macroname, const char *val,
|
||||
/*@null@*/ const char *body)
|
||||
{
|
||||
if (var >= 0) { /* XXX Dying ... */
|
||||
if (rpmGetVar(var)) return;
|
||||
|
@ -530,7 +541,7 @@ int rpmReadRC(const char * rcfiles)
|
|||
|
||||
/* Read each file in rcfiles. */
|
||||
rc = 0;
|
||||
for (r = myrcfiles = xstrdup(rcfiles); *r != '\0'; r = re) {
|
||||
for (r = myrcfiles = xstrdup(rcfiles); r && *r != '\0'; r = re) {
|
||||
char fn[4096];
|
||||
FD_t fd;
|
||||
|
||||
|
@ -959,21 +970,24 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
|
|||
static struct utsname un;
|
||||
static int gotDefaults = 0;
|
||||
char * chptr;
|
||||
const struct canonEntry * canon;
|
||||
canonEntry canon;
|
||||
int rc;
|
||||
|
||||
if (!gotDefaults) {
|
||||
(void) uname(&un);
|
||||
rc = uname(&un);
|
||||
if (rc) return;
|
||||
|
||||
#if !defined(__linux__)
|
||||
#ifdef SNI
|
||||
/* USUALLY un.sysname on sinix does start with the word "SINIX"
|
||||
* let's be absolutely sure
|
||||
*/
|
||||
sprintf(un.sysname,"SINIX");
|
||||
strncpy(un.sysname, "SINIX", sizeof(un.sysname));
|
||||
#endif
|
||||
/*@-nullpass@*/
|
||||
if (!strcmp(un.sysname, "AIX")) {
|
||||
strcpy(un.machine, __power_pc() ? "ppc" : "rs6000");
|
||||
sprintf(un.sysname,"aix%s.%s",un.version,un.release);
|
||||
sprintf(un.sysname,"aix%s.%s", un.version, un.release);
|
||||
}
|
||||
else if (!strcmp(un.sysname, "SunOS")) {
|
||||
if (!strncmp(un.release,"4", 1)) /* SunOS 4.x */ {
|
||||
|
@ -995,10 +1009,10 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
|
|||
}
|
||||
else if (!strcmp(un.sysname, "HP-UX"))
|
||||
/*make un.sysname look like hpux9.05 for example*/
|
||||
sprintf(un.sysname, "hpux%s", strpbrk(un.release,"123456789"));
|
||||
sprintf(un.sysname, "hpux%s", strpbrk(un.release, "123456789"));
|
||||
else if (!strcmp(un.sysname, "OSF1"))
|
||||
/*make un.sysname look like osf3.2 for example*/
|
||||
sprintf(un.sysname,"osf%s",strpbrk(un.release,"123456789"));
|
||||
sprintf(un.sysname, "osf%s", strpbrk(un.release, "123456789"));
|
||||
else if (!strncmp(un.sysname, "IP", 2))
|
||||
un.sysname[2] = '\0';
|
||||
else if (!strncmp(un.sysname, "SINIX", 5)) {
|
||||
|
@ -1014,7 +1028,7 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
|
|||
char * prelid = NULL;
|
||||
FD_t fd = Fopen("/etc/.relid", "r.fdio");
|
||||
int gotit = 0;
|
||||
if (!Ferror(fd)) {
|
||||
if (fd != NULL && !Ferror(fd)) {
|
||||
chptr = xcalloc(1, 256);
|
||||
{ int irelid = Fread(chptr, sizeof(*chptr), 256, fd);
|
||||
(void) Fclose(fd);
|
||||
|
@ -1034,6 +1048,7 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
|
|||
/* wrong, just for now, find out how to look for i586 later*/
|
||||
strcpy(un.machine,"i486");
|
||||
}
|
||||
/*@=nullpass@*/
|
||||
#endif /* __linux__ */
|
||||
|
||||
/* get rid of the hyphens in the sysname */
|
||||
|
@ -1169,10 +1184,12 @@ static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char **
|
|||
if (os) *os = un.sysname;
|
||||
}
|
||||
|
||||
static const char * rpmGetVarArch(int var, const char * arch) {
|
||||
struct rpmvarValue * next;
|
||||
static /*@observer@*/ /*@null@*/
|
||||
const char * rpmGetVarArch(int var, /*@null@*/ const char * arch)
|
||||
{
|
||||
const struct rpmvarValue * next;
|
||||
|
||||
if (!arch) arch = current[ARCH];
|
||||
if (arch == NULL) arch = current[ARCH];
|
||||
|
||||
if (arch) {
|
||||
next = &values[var];
|
||||
|
@ -1188,7 +1205,7 @@ static const char * rpmGetVarArch(int var, const char * arch) {
|
|||
return next ? next->value : NULL;
|
||||
}
|
||||
|
||||
const char *rpmGetVar(int var)
|
||||
/*@observer@*/ /*@null@*/ const char *rpmGetVar(int var)
|
||||
{
|
||||
return rpmGetVarArch(var, NULL);
|
||||
}
|
||||
|
@ -1230,7 +1247,9 @@ static void rpmSetVarArch(int var, const char * val, const char * arch) {
|
|||
}
|
||||
}
|
||||
|
||||
/*@-nullpass@*/ /* LCL: arch != NULL here. */
|
||||
if (next->arch && arch && !strcmp(next->arch, arch)) {
|
||||
/*@=nullpass@*/
|
||||
next->value = _free(next->value);
|
||||
next->arch = _free(next->arch);
|
||||
} else if (next->arch || arch) {
|
||||
|
@ -1263,7 +1282,7 @@ void rpmSetTables(int archTable, int osTable) {
|
|||
}
|
||||
|
||||
int rpmMachineScore(int type, const char * name) {
|
||||
struct machEquivInfo * info = machEquivSearch(&tables[type].equiv, name);
|
||||
machEquivInfo info = machEquivSearch(&tables[type].equiv, name);
|
||||
return (info != NULL ? info->score : 0);
|
||||
}
|
||||
|
||||
|
@ -1288,6 +1307,7 @@ void rpmSetMachine(const char * arch, const char * os) {
|
|||
tables[currTables[ARCH]].defaults,
|
||||
tables[currTables[ARCH]].defaultsLength);
|
||||
}
|
||||
if (arch == NULL) return; /* XXX can't happen */
|
||||
|
||||
if (os == NULL) {
|
||||
os = host_os;
|
||||
|
@ -1296,6 +1316,7 @@ void rpmSetMachine(const char * arch, const char * os) {
|
|||
tables[currTables[OS]].defaults,
|
||||
tables[currTables[OS]].defaultsLength);
|
||||
}
|
||||
if (os == NULL) return; /* XXX can't happen */
|
||||
|
||||
if (!current[ARCH] || strcmp(arch, current[ARCH])) {
|
||||
current[ARCH] = _free(current[ARCH]);
|
||||
|
@ -1328,10 +1349,11 @@ static void rebuildCompatTables(int type, const char * name) {
|
|||
name);
|
||||
}
|
||||
|
||||
static void getMachineInfo(int type, /*@out@*/ const char ** name,
|
||||
/*@out@*/int * num)
|
||||
static void getMachineInfo(int type, /*@null@*/ /*@out@*/ const char ** name,
|
||||
/*@null@*/ /*@out@*/int * num)
|
||||
/*@modifies *name, *num @*/
|
||||
{
|
||||
const struct canonEntry * canon;
|
||||
canonEntry canon;
|
||||
int which = currTables[type];
|
||||
|
||||
/* use the normal canon tables, even if we're looking up build stuff */
|
||||
|
@ -1462,7 +1484,7 @@ void rpmFreeRpmrc(void)
|
|||
int i, j, k;
|
||||
|
||||
for (i = 0; i < RPM_MACHTABLE_COUNT; i++) {
|
||||
struct tableType *t;
|
||||
tableType t;
|
||||
t = tables + i;
|
||||
if (t->equiv.list) {
|
||||
for (j = 0; j < t->equiv.count; j++)
|
||||
|
@ -1472,7 +1494,7 @@ void rpmFreeRpmrc(void)
|
|||
}
|
||||
if (t->cache.cache) {
|
||||
for (j = 0; j < t->cache.size; j++) {
|
||||
struct machCacheEntry *e;
|
||||
machCacheEntry e;
|
||||
e = t->cache.cache + j;
|
||||
if (e == NULL) continue;
|
||||
e->name = _free(e->name);
|
||||
|
@ -1524,7 +1546,7 @@ int rpmShowRC(FILE *fp)
|
|||
{
|
||||
struct rpmOption *opt;
|
||||
int i;
|
||||
struct machEquivTable * equivTable;
|
||||
machEquivTable equivTable;
|
||||
|
||||
/* the caller may set the build arch which should be printed here */
|
||||
fprintf(fp, "ARCHITECTURE AND OS:\n");
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "debug.h"
|
||||
|
||||
/*@access Header@*/ /* XXX compared with NULL */
|
||||
/*@access FD_t@*/ /* XXX compared with NULL */
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
|
@ -98,7 +99,7 @@ const char * rpmDetectPGPVersion(pgpVersion * pgpVer)
|
|||
saved_pgp_version = PGP_NOTDETECTED;
|
||||
}
|
||||
|
||||
if (pgpbin && pgpVer)
|
||||
if (pgpVer && pgpbin)
|
||||
*pgpVer = saved_pgp_version;
|
||||
return pgpbin;
|
||||
}
|
||||
|
@ -199,7 +200,9 @@ rpmRC rpmReadSignature(FD_t fd, Header * headerp, sigType sig_type)
|
|||
}
|
||||
|
||||
if (rc == 0 && headerp)
|
||||
/*@-nullderef@*/
|
||||
*headerp = h;
|
||||
/*@=nullderef@*/
|
||||
else if (h)
|
||||
headerFree(h);
|
||||
|
||||
|
@ -238,7 +241,7 @@ void rpmFreeSignature(Header h)
|
|||
}
|
||||
|
||||
static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
|
||||
/*@out@*/ int_32 * size, const char * passPhrase)
|
||||
/*@out@*/ int_32 * size, /*@null@*/ const char * passPhrase)
|
||||
{
|
||||
char * sigfile = alloca(1024);
|
||||
int pid, status;
|
||||
|
@ -281,11 +284,13 @@ static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
|
|||
break;
|
||||
}
|
||||
}
|
||||
rpmError(RPMERR_EXEC, _("Couldn't exec pgp (%s)\n"), path);
|
||||
rpmError(RPMERR_EXEC, _("Couldn't exec pgp (%s)\n"),
|
||||
(path ? path : NULL));
|
||||
_exit(RPMERR_EXEC);
|
||||
}
|
||||
|
||||
(void) close(inpipe[0]);
|
||||
if (passPhrase)
|
||||
(void) write(inpipe[1], passPhrase, strlen(passPhrase));
|
||||
(void) write(inpipe[1], "\n", 1);
|
||||
(void) close(inpipe[1]);
|
||||
|
@ -298,7 +303,7 @@ static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
|
|||
|
||||
if (stat(sigfile, &st)) {
|
||||
/* PGP failed to write signature */
|
||||
(void) unlink(sigfile); /* Just in case */
|
||||
if (sigfile) (void) unlink(sigfile); /* Just in case */
|
||||
rpmError(RPMERR_SIGGEN, _("pgp failed to write signature\n"));
|
||||
return 1;
|
||||
}
|
||||
|
@ -308,11 +313,13 @@ static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
|
|||
*sig = xmalloc(*size);
|
||||
|
||||
{ FD_t fd;
|
||||
int rc;
|
||||
int rc = 0;
|
||||
fd = Fopen(sigfile, "r.fdio");
|
||||
if (fd != NULL && !Ferror(fd)) {
|
||||
rc = timedRead(fd, *sig, *size);
|
||||
(void) unlink(sigfile);
|
||||
if (sigfile) (void) unlink(sigfile);
|
||||
(void) Fclose(fd);
|
||||
}
|
||||
if (rc != *size) {
|
||||
*sig = _free(*sig);
|
||||
rpmError(RPMERR_SIGGEN, _("unable to read the signature\n"));
|
||||
|
@ -331,7 +338,7 @@ static int makePGPSignature(const char * file, /*@out@*/ void ** sig,
|
|||
* creation crop up.
|
||||
*/
|
||||
static int makeGPGSignature(const char * file, /*@out@*/ void ** sig,
|
||||
/*@out@*/ int_32 * size, const char * passPhrase)
|
||||
/*@out@*/ int_32 * size, /*@null@*/ const char * passPhrase)
|
||||
{
|
||||
char * sigfile = alloca(1024);
|
||||
int pid, status;
|
||||
|
@ -364,8 +371,10 @@ static int makeGPGSignature(const char * file, /*@out@*/ void ** sig,
|
|||
|
||||
fpipe = fdopen(inpipe[1], "w");
|
||||
(void) close(inpipe[0]);
|
||||
fprintf(fpipe, "%s\n", passPhrase);
|
||||
if (fpipe) {
|
||||
fprintf(fpipe, "%s\n", (passPhrase ? passPhrase : ""));
|
||||
(void) fclose(fpipe);
|
||||
}
|
||||
|
||||
(void)waitpid(pid, &status, 0);
|
||||
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
|
||||
|
@ -375,7 +384,7 @@ static int makeGPGSignature(const char * file, /*@out@*/ void ** sig,
|
|||
|
||||
if (stat(sigfile, &st)) {
|
||||
/* GPG failed to write signature */
|
||||
(void) unlink(sigfile); /* Just in case */
|
||||
if (sigfile) (void) unlink(sigfile); /* Just in case */
|
||||
rpmError(RPMERR_SIGGEN, _("gpg failed to write signature\n"));
|
||||
return 1;
|
||||
}
|
||||
|
@ -385,11 +394,13 @@ static int makeGPGSignature(const char * file, /*@out@*/ void ** sig,
|
|||
*sig = xmalloc(*size);
|
||||
|
||||
{ FD_t fd;
|
||||
int rc;
|
||||
int rc = 0;
|
||||
fd = Fopen(sigfile, "r.fdio");
|
||||
if (fd != NULL && !Ferror(fd)) {
|
||||
rc = timedRead(fd, *sig, *size);
|
||||
(void) unlink(sigfile);
|
||||
if (sigfile) (void) unlink(sigfile);
|
||||
(void) Fclose(fd);
|
||||
}
|
||||
if (rc != *size) {
|
||||
*sig = _free(*sig);
|
||||
rpmError(RPMERR_SIGGEN, _("unable to read the signature\n"));
|
||||
|
@ -500,7 +511,7 @@ verifyPGPSignature(const char * datafile, const void * sig, int count,
|
|||
{
|
||||
int pid, status, outpipe[2];
|
||||
FD_t sfd;
|
||||
char *sigfile;
|
||||
/*@observer@*/ const char * sigfile;
|
||||
byte buf[BUFSIZ];
|
||||
FILE *file;
|
||||
int res = RPMSIG_OK;
|
||||
|
@ -528,8 +539,10 @@ verifyPGPSignature(const char * datafile, const void * sig, int count,
|
|||
tmppath = _free(tmppath);
|
||||
}
|
||||
sfd = Fopen(sigfile, "w.fdio");
|
||||
(void)Fwrite(sig, sizeof(char), count, sfd);
|
||||
if (sfd != NULL && !Ferror(sfd)) {
|
||||
(void) Fwrite(sig, sizeof(char), count, sfd);
|
||||
(void) Fclose(sfd);
|
||||
}
|
||||
|
||||
/* Now run PGP */
|
||||
outpipe[0] = outpipe[1] = 0;
|
||||
|
@ -579,6 +592,7 @@ verifyPGPSignature(const char * datafile, const void * sig, int count,
|
|||
(void) close(outpipe[1]);
|
||||
file = fdopen(outpipe[0], "r");
|
||||
result[0] = '\0';
|
||||
if (file) {
|
||||
while (fgets(buf, 1024, file)) {
|
||||
if (strncmp("File '", buf, 6) &&
|
||||
strncmp("Text is assu", buf, 12) &&
|
||||
|
@ -596,9 +610,10 @@ verifyPGPSignature(const char * datafile, const void * sig, int count,
|
|||
res = RPMSIG_OK;
|
||||
}
|
||||
(void) fclose(file);
|
||||
}
|
||||
|
||||
(void) waitpid(pid, &status, 0);
|
||||
(void) unlink(sigfile);
|
||||
if (sigfile) (void) unlink(sigfile);
|
||||
if (!res && (!WIFEXITED(status) || WEXITSTATUS(status))) {
|
||||
res = RPMSIG_BAD;
|
||||
}
|
||||
|
@ -623,8 +638,10 @@ verifyGPGSignature(const char * datafile, const void * sig, int count,
|
|||
tmppath = _free(tmppath);
|
||||
}
|
||||
sfd = Fopen(sigfile, "w.fdio");
|
||||
if (sfd != NULL && !Ferror(sfd)) {
|
||||
(void) Fwrite(sig, sizeof(char), count, sfd);
|
||||
(void) Fclose(sfd);
|
||||
}
|
||||
|
||||
/* Now run GPG */
|
||||
outpipe[0] = outpipe[1] = 0;
|
||||
|
@ -652,6 +669,7 @@ verifyGPGSignature(const char * datafile, const void * sig, int count,
|
|||
(void) close(outpipe[1]);
|
||||
file = fdopen(outpipe[0], "r");
|
||||
result[0] = '\0';
|
||||
if (file) {
|
||||
while (fgets(buf, 1024, file)) {
|
||||
strcat(result, buf);
|
||||
if (!xstrncasecmp("gpg: Can't check signature: Public key not found", buf, 48)) {
|
||||
|
@ -659,9 +677,10 @@ verifyGPGSignature(const char * datafile, const void * sig, int count,
|
|||
}
|
||||
}
|
||||
(void) fclose(file);
|
||||
}
|
||||
|
||||
(void) waitpid(pid, &status, 0);
|
||||
(void) unlink(sigfile);
|
||||
if (sigfile) (void) unlink(sigfile);
|
||||
if (!res && (!WIFEXITED(status) || WEXITSTATUS(status))) {
|
||||
res = RPMSIG_BAD;
|
||||
}
|
||||
|
@ -757,7 +776,7 @@ static int checkPassPhrase(const char * passPhrase, const int sigTag)
|
|||
return 0;
|
||||
}
|
||||
|
||||
char *rpmGetPassPhrase(const char * prompt, const int sigTag)
|
||||
char * rpmGetPassPhrase(const char * prompt, const int sigTag)
|
||||
{
|
||||
char *pass;
|
||||
int aok;
|
||||
|
|
|
@ -40,7 +40,7 @@ extern "C" {
|
|||
* Return new, empty (signature) header instance.
|
||||
* @return signature header
|
||||
*/
|
||||
Header rpmNewSignature(void);
|
||||
Header rpmNewSignature(void) /*@*/;
|
||||
|
||||
/** \ingroup signature
|
||||
* Read (and verify header+archive size) signature header.
|
||||
|
@ -50,21 +50,24 @@ Header rpmNewSignature(void);
|
|||
* @param sig_type type of signature header to read (from lead).
|
||||
* @return rpmRC return code
|
||||
*/
|
||||
rpmRC rpmReadSignature(FD_t fd, /*@out@*/ Header *header, sigType sig_type);
|
||||
rpmRC rpmReadSignature(FD_t fd, /*@out@*/ Header *header, sigType sig_type)
|
||||
/*@modifies fd, *header @*/;
|
||||
|
||||
/** \ingroup signature
|
||||
* Write signature header.
|
||||
* @param fd file handle
|
||||
* @param header (signature) header
|
||||
* @param h (signature) header
|
||||
* @return 0 on success, 1 on error
|
||||
*/
|
||||
int rpmWriteSignature(FD_t fd, Header header);
|
||||
int rpmWriteSignature(FD_t fd, Header h)
|
||||
/*@modifies fd, h @*/;
|
||||
|
||||
/** \ingroup signature
|
||||
* Generate a signature of data in file, insert in header.
|
||||
*/
|
||||
int rpmAddSignature(Header h, const char *file,
|
||||
int_32 sigTag, const char *passPhrase);
|
||||
int rpmAddSignature(Header h, const char * file,
|
||||
int_32 sigTag, /*@null@*/ const char * passPhrase)
|
||||
/*@modifies h @*/;
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
|
@ -76,17 +79,21 @@ int rpmAddSignature(Header h, const char *file,
|
|||
/** \ingroup signature
|
||||
* Return type of signature in effect for building.
|
||||
*/
|
||||
int rpmLookupSignatureType(int action);
|
||||
int rpmLookupSignatureType(int action)
|
||||
/*@modifies internalState @*/;
|
||||
|
||||
/** \ingroup signature
|
||||
* Read a pass phrase from the user.
|
||||
*/
|
||||
char * rpmGetPassPhrase(const char *prompt, const int sigTag);
|
||||
/*@null@*/ char * rpmGetPassPhrase(const char *prompt, const int sigTag)
|
||||
/*@modifies fileSystem @*/;
|
||||
|
||||
/** \ingroup signature
|
||||
* Return path to pgp executable of given type, or NULL when not found.
|
||||
*/
|
||||
/*@null@*/ const char * rpmDetectPGPVersion( /*@out@*/ pgpVersion *pgpVersion);
|
||||
/*@null@*/ const char * rpmDetectPGPVersion(
|
||||
/*@null@*/ /*@out@*/ pgpVersion *pgpVersion)
|
||||
/*@modifies *pgpVersion, fileSystem @*/;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
|
|||
Header origH, fileAction * actions)
|
||||
{
|
||||
HGE_t hge = fi->hge;
|
||||
HFD_t hfd = fi->hfd;
|
||||
HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
||||
static int _printed = 0;
|
||||
rpmProblemSet probs = ts->probs;
|
||||
int allowBadRelocate = (ts->ignoreSet & RPMPROB_FILTER_FORCERELOCATE);
|
||||
|
@ -335,7 +335,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
|
|||
* should be added, but, since relocateFileList() can be called more
|
||||
* than once for the same header, don't bother if already present.
|
||||
*/
|
||||
if (numRelocations == 0) {
|
||||
if (rawRelocations == NULL || numRelocations == 0) {
|
||||
if (numValid) {
|
||||
if (!headerIsEntry(origH, RPMTAG_INSTPREFIXES))
|
||||
(void) headerAddEntry(origH, RPMTAG_INSTPREFIXES,
|
||||
|
@ -358,8 +358,11 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
|
|||
for (i = 0; i < numRelocations; i++) {
|
||||
char * t;
|
||||
|
||||
/* FIXME: default relocations (oldPath == NULL) need to be handled
|
||||
in the UI, not rpmlib */
|
||||
/*
|
||||
* Default relocations (oldPath == NULL) are handled in the UI,
|
||||
* not rpmlib.
|
||||
*/
|
||||
if (rawRelocations[i].oldPath == NULL) continue; /* XXX can't happen */
|
||||
|
||||
/* FIXME: Trailing /'s will confuse us greatly. Internal ones will
|
||||
too, but those are more trouble to fix up. :-( */
|
||||
|
@ -399,7 +402,9 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
|
|||
madeSwap = 0;
|
||||
for (j = 1; j < numRelocations; j++) {
|
||||
rpmRelocation tmpReloc;
|
||||
if (strcmp(relocations[j - 1].oldPath, relocations[j].oldPath) <= 0)
|
||||
if (relocations[j - 1].oldPath == NULL || /* XXX can't happen */
|
||||
relocations[j ].oldPath == NULL || /* XXX can't happen */
|
||||
strcmp(relocations[j - 1].oldPath, relocations[j].oldPath) <= 0)
|
||||
continue;
|
||||
tmpReloc = relocations[j - 1];
|
||||
relocations[j - 1] = relocations[j];
|
||||
|
@ -413,6 +418,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
|
|||
_printed = 1;
|
||||
rpmMessage(RPMMESS_DEBUG, _("========== relocations\n"));
|
||||
for (i = 0; i < numRelocations; i++) {
|
||||
if (relocations[i].oldPath == NULL) continue; /* XXX can't happen */
|
||||
if (relocations[i].newPath == NULL)
|
||||
rpmMessage(RPMMESS_DEBUG, _("%5d exclude %s\n"),
|
||||
i, relocations[i].oldPath);
|
||||
|
@ -431,7 +437,8 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
|
|||
numActual = 0;
|
||||
for (i = 0; i < numValid; i++) {
|
||||
for (j = 0; j < numRelocations; j++) {
|
||||
if (strcmp(validRelocations[i], relocations[j].oldPath))
|
||||
if (relocations[j].oldPath == NULL || /* XXX can't happen */
|
||||
strcmp(validRelocations[i], relocations[j].oldPath))
|
||||
continue;
|
||||
/* On install, a relocate to NULL means skip the path. */
|
||||
if (relocations[j].newPath) {
|
||||
|
@ -509,6 +516,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
|
|||
* relocation list be a good idea?
|
||||
*/
|
||||
for (j = numRelocations - 1; j >= 0; j--) {
|
||||
if (relocations[j].oldPath == NULL) continue; /* XXX can't happen */
|
||||
len = strcmp(relocations[j].oldPath, "/")
|
||||
? strlen(relocations[j].oldPath)
|
||||
: 0;
|
||||
|
@ -569,9 +577,11 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
|
|||
fnlen = te - fn;
|
||||
} else
|
||||
te = fn + strlen(fn);
|
||||
/*@-nullpass -nullderef@*/ /* LCL: te != NULL here. */
|
||||
if (strcmp(baseNames[i], te)) /* basename changed too? */
|
||||
baseNames[i] = alloca_strdup(te);
|
||||
*te = '\0'; /* terminate new directory name */
|
||||
/*@=nullpass =nullderef@*/
|
||||
}
|
||||
|
||||
/* Does this directory already exist in the directory list? */
|
||||
|
@ -612,6 +622,7 @@ static Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
|
|||
for (i = dirCount - 1; i >= 0; i--) {
|
||||
for (j = numRelocations - 1; j >= 0; j--) {
|
||||
|
||||
if (relocations[j].oldPath == NULL) continue; /* XXX can't happen */
|
||||
len = strcmp(relocations[j].oldPath, "/")
|
||||
? strlen(relocations[j].oldPath)
|
||||
: 0;
|
||||
|
@ -704,9 +715,11 @@ static int psTrim(rpmProblemSet filter, rpmProblemSet target)
|
|||
continue;
|
||||
}
|
||||
while ((t - target->probs) < target->numProblems) {
|
||||
/*@-nullpass@*/ /* LCL: looks good to me */
|
||||
if (f->h == t->h && f->type == t->type && t->key == f->key &&
|
||||
XSTRCMP(f->str1, t->str1))
|
||||
break;
|
||||
/*@=nullpass@*/
|
||||
t++;
|
||||
gotProblems = 1;
|
||||
}
|
||||
|
@ -851,14 +864,14 @@ static int filecmp(short mode1, const char * md51, const char * link1,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handleInstInstalledFiles(TFI_t fi, rpmdb db,
|
||||
static int handleInstInstalledFiles(TFI_t fi, /*@null@*/ rpmdb db,
|
||||
struct sharedFileInfo * shared,
|
||||
int sharedCount, int reportConflicts,
|
||||
rpmProblemSet probs,
|
||||
rpmtransFlags transFlags)
|
||||
{
|
||||
HGE_t hge = fi->hge;
|
||||
HFD_t hfd = fi->hfd;
|
||||
HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
||||
int oltype, omtype;
|
||||
Header h;
|
||||
int i;
|
||||
|
@ -945,7 +958,7 @@ static int handleInstInstalledFiles(TFI_t fi, rpmdb db,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handleRmvdInstalledFiles(TFI_t fi, rpmdb db,
|
||||
static int handleRmvdInstalledFiles(TFI_t fi, /*@null@*/ rpmdb db,
|
||||
struct sharedFileInfo * shared,
|
||||
int sharedCount)
|
||||
{
|
||||
|
@ -1065,8 +1078,10 @@ static void handleOverlappedFiles(TFI_t fi, hashTable ht,
|
|||
break;
|
||||
|
||||
/* Otherwise, compare fingerprints by value. */
|
||||
/*@-nullpass@*/ /* LCL: looks good to me */
|
||||
if (FP_EQUAL(fi->fps[i], recs[otherPkgNum]->fps[otherFileNum]))
|
||||
break;
|
||||
/*@=nullpass@*/
|
||||
|
||||
}
|
||||
/* XXX is this test still necessary? */
|
||||
|
@ -1356,7 +1371,9 @@ static void skipFiles(const rpmTransactionSet ts, TFI_t fi)
|
|||
}
|
||||
|
||||
if (netsharedPaths) freeSplitString(netsharedPaths);
|
||||
#ifdef DYING /* XXX freeFi will deal with this later. */
|
||||
fi->flangs = _free(fi->flangs);
|
||||
#endif
|
||||
if (languages) freeSplitString((char **)languages);
|
||||
}
|
||||
|
||||
|
@ -1559,6 +1576,7 @@ int rpmRunTransactions( rpmTransactionSet ts,
|
|||
* - count files.
|
||||
*/
|
||||
/* The ordering doesn't matter here */
|
||||
if (ts->addedPackages.list != NULL)
|
||||
for (alp = ts->addedPackages.list;
|
||||
(alp - ts->addedPackages.list) < ts->addedPackages.size;
|
||||
alp++)
|
||||
|
@ -1879,7 +1897,9 @@ int rpmRunTransactions( rpmTransactionSet ts,
|
|||
|
||||
ts->flList = freeFl(ts, ts->flList);
|
||||
ts->flEntries = 0;
|
||||
/*@-nullstate@*/
|
||||
return ts->orderCount;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
|
||||
/* ===============================================
|
||||
|
@ -1995,8 +2015,10 @@ assert(alp == fi->ap);
|
|||
ts->flList = freeFl(ts, ts->flList);
|
||||
ts->flEntries = 0;
|
||||
|
||||
/*@-nullstate@*/
|
||||
if (ourrc)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
|
|
13
lib/verify.c
13
lib/verify.c
|
@ -36,7 +36,7 @@ static void verifyArgCallback(/*@unused@*/poptContext con,
|
|||
const struct poptOption * opt, /*@unused@*/const char * arg,
|
||||
/*@unused@*/ const void * data)
|
||||
{
|
||||
QVA_t *qva = &rpmQVArgs;
|
||||
QVA_t qva = &rpmQVArgs;
|
||||
switch (opt->val) {
|
||||
case POPT_NODEPS: qva->qva_flags |= VERIFY_DEPS; break;
|
||||
case POPT_NOFILES: qva->qva_flags |= VERIFY_FILES; break;
|
||||
|
@ -300,7 +300,7 @@ int rpmVerifyFile(const char * prefix, Header h, int filenum,
|
|||
* @param scriptFd file handle to use for stderr (or NULL)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmVerifyScript(const char * rootDir, Header h, FD_t scriptFd)
|
||||
int rpmVerifyScript(const char * rootDir, Header h, /*@null@*/ FD_t scriptFd)
|
||||
{
|
||||
rpmdb rpmdb = NULL;
|
||||
rpmTransactionSet ts = rpmtransCreateSet(rpmdb, rootDir);
|
||||
|
@ -326,7 +326,7 @@ int rpmVerifyScript(const char * rootDir, Header h, FD_t scriptFd)
|
|||
}
|
||||
|
||||
/* ======================================================================== */
|
||||
static int verifyHeader(QVA_t *qva, Header h)
|
||||
static int verifyHeader(QVA_t qva, Header h)
|
||||
{
|
||||
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
||||
char buf[BUFSIZ];
|
||||
|
@ -467,7 +467,7 @@ static int verifyDependencies(rpmdb rpmdb, Header h)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int showVerifyPackage(QVA_t *qva, rpmdb rpmdb, Header h)
|
||||
int showVerifyPackage(QVA_t qva, rpmdb rpmdb, Header h)
|
||||
{
|
||||
FD_t fdo;
|
||||
int ec = 0;
|
||||
|
@ -483,11 +483,12 @@ int showVerifyPackage(QVA_t *qva, rpmdb rpmdb, Header h)
|
|||
if ((qva->qva_flags & VERIFY_SCRIPT) &&
|
||||
(rc = rpmVerifyScript(qva->qva_prefix, h, fdo)) != 0)
|
||||
ec = rc;
|
||||
(void) Fclose(fdo);
|
||||
if (fdo)
|
||||
rc = Fclose(fdo);
|
||||
return ec;
|
||||
}
|
||||
|
||||
int rpmVerify(QVA_t *qva, rpmQVSources source, const char *arg)
|
||||
int rpmVerify(QVA_t qva, rpmQVSources source, const char *arg)
|
||||
{
|
||||
rpmdb rpmdb = NULL;
|
||||
int rc;
|
||||
|
|
1116
po/eu_ES.po
1116
po/eu_ES.po
File diff suppressed because it is too large
Load Diff
1116
po/pt_BR.po
1116
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1116
po/zh_CN.GB2312.po
1116
po/zh_CN.GB2312.po
File diff suppressed because it is too large
Load Diff
|
@ -34,6 +34,10 @@ libpopt_la_SOURCES = popt.c findme.c poptparse.c poptconfig.c popthelp.c
|
|||
|
||||
man_MANS = popt.3
|
||||
|
||||
.PHONY: sources
|
||||
sources:
|
||||
@echo $(libpopt_la_SOURCES:%=popt/%)
|
||||
|
||||
.PHONY: lclint
|
||||
lclint:
|
||||
lclint ${DEFS} ${INCLUDES} ${libpopt_la_SOURCES}
|
||||
|
|
6
rpm.c
6
rpm.c
|
@ -114,9 +114,9 @@ extern const char * rpmNAME;
|
|||
extern const char * rpmEVR;
|
||||
extern int rpmFLAGS;
|
||||
|
||||
extern MacroContext rpmCLIMacroContext;
|
||||
extern struct MacroContext_s rpmCLIMacroContext;
|
||||
|
||||
extern struct rpmBuildArguments rpmBTArgs;
|
||||
extern struct rpmBuildArguments_s rpmBTArgs;
|
||||
|
||||
/* the structure describing the options we take and the defaults */
|
||||
static struct poptOption optionsTable[] = {
|
||||
|
@ -575,7 +575,7 @@ static void printHelp(void) {
|
|||
int main(int argc, const char ** argv)
|
||||
{
|
||||
enum modes bigMode = MODE_UNKNOWN;
|
||||
QVA_t *qva = &rpmQVArgs;
|
||||
QVA_t qva = &rpmQVArgs;
|
||||
int arg;
|
||||
rpmtransFlags transFlags = RPMTRANS_FLAG_NONE;
|
||||
rpmInstallInterfaceFlags installInterfaceFlags = INSTALL_NONE;
|
||||
|
|
|
@ -22,7 +22,10 @@ install-data-local:
|
|||
sed -e "s|^dependency_libs='|& -lpopt|" < librpmio.la > .librpmio.la && \
|
||||
mv .librpmio.la librpmio.la
|
||||
|
||||
.PHONY: lclint
|
||||
.PHONY: sources
|
||||
sources:
|
||||
@echo $(librpmio_la_SOURCES:%=rpmio/%)
|
||||
|
||||
.PHONY: lclint
|
||||
lclint:
|
||||
lclint $(DEFS) $(INCLUDES) $(librpmio_la_SOURCES)
|
||||
|
|
193
rpmio/macro.c
193
rpmio/macro.c
|
@ -13,7 +13,6 @@ static int _debug = 0;
|
|||
#define iseol(_c) ((_c) == '\n' || (_c) == '\r')
|
||||
|
||||
#define STREQ(_t, _f, _fn) ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn)))
|
||||
#define FREE(_x) { if (_x) free((void *)_x); (_x) = NULL; }
|
||||
|
||||
#ifdef DEBUG_MACROS
|
||||
#include <sys/types.h>
|
||||
|
@ -56,8 +55,8 @@ typedef FILE * FD_t;
|
|||
/*@access MacroContext@*/
|
||||
/*@access MacroEntry@*/
|
||||
|
||||
struct MacroContext rpmGlobalMacroContext;
|
||||
struct MacroContext rpmCLIMacroContext;
|
||||
struct MacroContext_s rpmGlobalMacroContext;
|
||||
struct MacroContext_s rpmCLIMacroContext;
|
||||
|
||||
/**
|
||||
* Macro expansion state.
|
||||
|
@ -70,7 +69,7 @@ typedef struct MacroBuf {
|
|||
int macro_trace; /*!< Pre-print macro to expand? */
|
||||
int expand_trace; /*!< Post-print macro expansion? */
|
||||
/*@shared@*/ void *spec; /*!< (future) %file expansion info. */
|
||||
/*@dependent@*/ MacroContext *mc;
|
||||
/*@dependent@*/ MacroContext mc;
|
||||
} MacroBuf;
|
||||
|
||||
#define SAVECHAR(_mb, _c) { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; }
|
||||
|
@ -90,6 +89,16 @@ int print_expand_trace = 0;
|
|||
|
||||
#define MACRO_CHUNK_SIZE 16
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
/**
|
||||
|
@ -101,8 +110,8 @@ int print_expand_trace = 0;
|
|||
static int
|
||||
compareMacroName(const void *ap, const void *bp)
|
||||
{
|
||||
MacroEntry *ame = *((MacroEntry **)ap);
|
||||
MacroEntry *bme = *((MacroEntry **)bp);
|
||||
MacroEntry ame = *((MacroEntry *)ap);
|
||||
MacroEntry bme = *((MacroEntry *)bp);
|
||||
|
||||
if (ame == NULL && bme == NULL)
|
||||
return 0;
|
||||
|
@ -118,16 +127,16 @@ compareMacroName(const void *ap, const void *bp)
|
|||
* @param mc macro context
|
||||
*/
|
||||
static void
|
||||
expandMacroTable(MacroContext *mc)
|
||||
expandMacroTable(MacroContext mc)
|
||||
{
|
||||
if (mc->macroTable == NULL) {
|
||||
mc->macrosAllocated = MACRO_CHUNK_SIZE;
|
||||
mc->macroTable = (MacroEntry **)
|
||||
mc->macroTable = (MacroEntry *)
|
||||
xmalloc(sizeof(*(mc->macroTable)) * mc->macrosAllocated);
|
||||
mc->firstFree = 0;
|
||||
} else {
|
||||
mc->macrosAllocated += MACRO_CHUNK_SIZE;
|
||||
mc->macroTable = (MacroEntry **)
|
||||
mc->macroTable = (MacroEntry *)
|
||||
xrealloc(mc->macroTable, sizeof(*(mc->macroTable)) *
|
||||
mc->macrosAllocated);
|
||||
}
|
||||
|
@ -139,10 +148,13 @@ expandMacroTable(MacroContext *mc)
|
|||
* @param mc macro context
|
||||
*/
|
||||
static void
|
||||
sortMacroTable(MacroContext *mc)
|
||||
sortMacroTable(MacroContext mc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (mc == NULL || mc->macroTable == NULL)
|
||||
return;
|
||||
|
||||
qsort(mc->macroTable, mc->firstFree, sizeof(*(mc->macroTable)),
|
||||
compareMacroName);
|
||||
|
||||
|
@ -156,20 +168,19 @@ sortMacroTable(MacroContext *mc)
|
|||
}
|
||||
|
||||
void
|
||||
rpmDumpMacroTable(MacroContext * mc, FILE * fp)
|
||||
rpmDumpMacroTable(MacroContext mc, FILE * fp)
|
||||
{
|
||||
int i;
|
||||
int nempty = 0;
|
||||
int nactive = 0;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (fp == NULL)
|
||||
fp = stderr;
|
||||
if (mc == NULL) mc = &rpmGlobalMacroContext;
|
||||
if (fp == NULL) fp = stderr;
|
||||
|
||||
fprintf(fp, "========================\n");
|
||||
if (mc->macroTable != NULL) {
|
||||
int i;
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry *me;
|
||||
MacroEntry me;
|
||||
if ((me = mc->macroTable[i]) == NULL) {
|
||||
/* XXX this should never happen */
|
||||
nempty++;
|
||||
|
@ -184,6 +195,7 @@ rpmDumpMacroTable(MacroContext * mc, FILE * fp)
|
|||
fprintf(fp, "\n");
|
||||
nactive++;
|
||||
}
|
||||
}
|
||||
fprintf(fp, _("======================== active %d empty %d\n"),
|
||||
nactive, nempty);
|
||||
}
|
||||
|
@ -195,15 +207,15 @@ rpmDumpMacroTable(MacroContext * mc, FILE * fp)
|
|||
* @param namelen no. of byes
|
||||
* @return address of slot in macro table with name (or NULL)
|
||||
*/
|
||||
/*@dependent@*/ static MacroEntry **
|
||||
findEntry(MacroContext *mc, const char *name, size_t namelen)
|
||||
/*@dependent@*/ /*@null@*/ static MacroEntry *
|
||||
findEntry(MacroContext mc, const char *name, size_t namelen)
|
||||
{
|
||||
MacroEntry keybuf, *key, **ret;
|
||||
MacroEntry key, *ret;
|
||||
struct MacroEntry_s keybuf;
|
||||
char namebuf[1024];
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (! mc->firstFree)
|
||||
if (mc == NULL) mc = &rpmGlobalMacroContext;
|
||||
if (mc->macroTable == NULL || mc->firstFree == 0)
|
||||
return NULL;
|
||||
|
||||
if (namelen > 0) {
|
||||
|
@ -217,7 +229,7 @@ findEntry(MacroContext *mc, const char *name, size_t namelen)
|
|||
/*@-temptrans@*/
|
||||
key->name = (char *)name;
|
||||
/*@=temptrans@*/
|
||||
ret = (MacroEntry **)bsearch(&key, mc->macroTable, mc->firstFree,
|
||||
ret = (MacroEntry *) bsearch(&key, mc->macroTable, mc->firstFree,
|
||||
sizeof(*(mc->macroTable)), compareMacroName);
|
||||
/* XXX TODO: find 1st empty slot and return that */
|
||||
return ret;
|
||||
|
@ -234,11 +246,13 @@ rdcl(char *buf, size_t size, FD_t fd, int escapes)
|
|||
char *q = buf;
|
||||
size_t nb = 0;
|
||||
size_t nread = 0;
|
||||
FILE * f = fdGetFILE(fd);
|
||||
|
||||
*q = '\0';
|
||||
if (f != NULL)
|
||||
do {
|
||||
/* read next line */
|
||||
if (fgets(q, size, fdGetFILE(fd)) == NULL)
|
||||
if (fgets(q, size, f) == NULL)
|
||||
break;
|
||||
nb = strlen(q);
|
||||
nread += nb;
|
||||
|
@ -617,7 +631,7 @@ doDefine(MacroBuf *mb, const char *se, int level, int expandbody)
|
|||
* @return address to continue parsing
|
||||
*/
|
||||
/*@dependent@*/ static const char *
|
||||
doUndefine(MacroContext *mc, const char *se)
|
||||
doUndefine(MacroContext mc, const char *se)
|
||||
{
|
||||
const char *s = se;
|
||||
char buf[BUFSIZ], *n = buf, *ne = n;
|
||||
|
@ -644,7 +658,7 @@ doUndefine(MacroContext *mc, const char *se)
|
|||
|
||||
#ifdef DYING
|
||||
static void
|
||||
dumpME(const char *msg, MacroEntry *me)
|
||||
dumpME(const char *msg, MacroEntry me)
|
||||
{
|
||||
if (msg)
|
||||
fprintf(stderr, "%s", msg);
|
||||
|
@ -665,10 +679,14 @@ dumpME(const char *msg, MacroEntry *me)
|
|||
* @param level macro recursion level
|
||||
*/
|
||||
static void
|
||||
pushMacro(MacroEntry **mep, const char *n, const char *o, const char *b, int level)
|
||||
pushMacro(/*@out@*/ MacroEntry *mep,
|
||||
const char *n, /*@null@*/ const char *o,
|
||||
/*@null@*/ const char *b, int level)
|
||||
{
|
||||
MacroEntry *prev = (*mep ? *mep : NULL);
|
||||
MacroEntry *me = (MacroEntry *) xmalloc(sizeof(*me));
|
||||
/*@-usedef@*/
|
||||
MacroEntry prev = (mep && *mep ? *mep : NULL);
|
||||
/*@=usedef@*/
|
||||
MacroEntry me = (MacroEntry) xmalloc(sizeof(*me));
|
||||
|
||||
me->prev = prev;
|
||||
me->name = (prev ? prev->name : xstrdup(n));
|
||||
|
@ -676,7 +694,10 @@ pushMacro(MacroEntry **mep, const char *n, const char *o, const char *b, int lev
|
|||
me->body = xstrdup(b ? b : "");
|
||||
me->used = 0;
|
||||
me->level = level;
|
||||
if (mep)
|
||||
*mep = me;
|
||||
else
|
||||
me = _free(me);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -684,18 +705,18 @@ pushMacro(MacroEntry **mep, const char *n, const char *o, const char *b, int lev
|
|||
* @param mep address of macro entry slot
|
||||
*/
|
||||
static void
|
||||
popMacro(MacroEntry **mep)
|
||||
popMacro(MacroEntry *mep)
|
||||
{
|
||||
MacroEntry *me = (*mep ? *mep : NULL);
|
||||
MacroEntry me = (*mep ? *mep : NULL);
|
||||
|
||||
if (me) {
|
||||
/* XXX cast to workaround const */
|
||||
/*@-onlytrans@*/
|
||||
if ((*mep = me->prev) == NULL)
|
||||
FREE(me->name);
|
||||
FREE(me->opts);
|
||||
FREE(me->body);
|
||||
FREE(me);
|
||||
me->name = _free(me->name);
|
||||
me->opts = _free(me->opts);
|
||||
me->body = _free(me->body);
|
||||
me = _free(me);
|
||||
/*@=onlytrans@*/
|
||||
}
|
||||
}
|
||||
|
@ -707,13 +728,16 @@ popMacro(MacroEntry **mep)
|
|||
static void
|
||||
freeArgs(MacroBuf *mb)
|
||||
{
|
||||
MacroContext *mc = mb->mc;
|
||||
MacroContext mc = mb->mc;
|
||||
int ndeleted = 0;
|
||||
int i;
|
||||
|
||||
if (mc == NULL || mc->macroTable == NULL)
|
||||
return;
|
||||
|
||||
/* Delete dynamic macro definitions */
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry **mep, *me;
|
||||
MacroEntry *mep, me;
|
||||
int skiptest = 0;
|
||||
mep = &mc->macroTable[i];
|
||||
me = *mep;
|
||||
|
@ -724,8 +748,7 @@ freeArgs(MacroBuf *mb)
|
|||
continue;
|
||||
if (strlen(me->name) == 1 && strchr("#*0", *me->name)) {
|
||||
if (*me->name == '*' && me->used > 0)
|
||||
skiptest = 1;
|
||||
/* XXX skip test for %# %* %0 */
|
||||
skiptest = 1; /* XXX skip test for %# %* %0 */
|
||||
} else if (!skiptest && me->used <= 0) {
|
||||
#if NOTYET
|
||||
rpmError(RPMERR_BADSPEC,
|
||||
|
@ -752,7 +775,7 @@ freeArgs(MacroBuf *mb)
|
|||
* @return address to continue parsing
|
||||
*/
|
||||
/*@dependent@*/ static const char *
|
||||
grabArgs(MacroBuf *mb, const MacroEntry *me, const char *se, char lastc)
|
||||
grabArgs(MacroBuf *mb, const MacroEntry me, const char *se, char lastc)
|
||||
{
|
||||
char buf[BUFSIZ], *b, *be;
|
||||
char aname[16];
|
||||
|
@ -762,6 +785,7 @@ grabArgs(MacroBuf *mb, const MacroEntry *me, const char *se, char lastc)
|
|||
int c;
|
||||
|
||||
/* Copy macro name as argv[0], save beginning of args. */
|
||||
buf[0] = '\0';
|
||||
b = be = stpcpy(buf, me->name);
|
||||
|
||||
addMacro(mb->mc, "0", NULL, buf, mb->depth);
|
||||
|
@ -828,7 +852,9 @@ grabArgs(MacroBuf *mb, const MacroEntry *me, const char *se, char lastc)
|
|||
}
|
||||
*be++ = '-';
|
||||
*be++ = c;
|
||||
/*@-usedef@*/
|
||||
if (o[1] == ':') {
|
||||
/*@=usedef@*/
|
||||
*be++ = ' ';
|
||||
be = stpcpy(be, optarg);
|
||||
}
|
||||
|
@ -847,6 +873,7 @@ grabArgs(MacroBuf *mb, const MacroEntry *me, const char *se, char lastc)
|
|||
addMacro(mb->mc, "#", NULL, aname, mb->depth);
|
||||
|
||||
/* Add macro for each arg. Concatenate args for %*. */
|
||||
if (be) {
|
||||
*be = '\0';
|
||||
for (c = optind; c < argc; c++) {
|
||||
sprintf(aname, "%d", (c - optind + 1));
|
||||
|
@ -854,6 +881,7 @@ grabArgs(MacroBuf *mb, const MacroEntry *me, const char *se, char lastc)
|
|||
*be++ = ' ';
|
||||
be = stpcpy(be, argv[c]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add unexpanded args as macro. */
|
||||
addMacro(mb->mc, "*", NULL, b, mb->depth);
|
||||
|
@ -987,8 +1015,8 @@ doFoo(MacroBuf *mb, int negate, const char *f, size_t fn, const char *g, size_t
|
|||
static int
|
||||
expandMacro(MacroBuf *mb)
|
||||
{
|
||||
MacroEntry **mep;
|
||||
MacroEntry *me;
|
||||
MacroEntry *mep;
|
||||
MacroEntry me;
|
||||
const char *s = mb->s, *se;
|
||||
const char *f, *fe;
|
||||
const char *g, *ge;
|
||||
|
@ -1216,7 +1244,7 @@ expandMacro(MacroBuf *mb)
|
|||
if (g && g < ge) { /* Expand X in %{-f:X} */
|
||||
rc = expandT(mb, g, gn);
|
||||
} else
|
||||
if (me->body && *me->body) { /* Expand %{-f}/%{-f*} */
|
||||
if (me && me->body && *me->body) {/* Expand %{-f}/%{-f*} */
|
||||
rc = expandT(mb, me->body, strlen(me->body));
|
||||
}
|
||||
s = se;
|
||||
|
@ -1300,7 +1328,7 @@ expandMacro(MacroBuf *mb)
|
|||
/* =============================================================== */
|
||||
|
||||
int
|
||||
expandMacros(void *spec, MacroContext *mc, char *s, size_t slen)
|
||||
expandMacros(void *spec, MacroContext mc, char *s, size_t slen)
|
||||
{
|
||||
MacroBuf macrobuf, *mb = ¯obuf;
|
||||
char *tbuf;
|
||||
|
@ -1308,8 +1336,7 @@ expandMacros(void *spec, MacroContext *mc, char *s, size_t slen)
|
|||
|
||||
if (s == NULL || slen <= 0)
|
||||
return 0;
|
||||
if (mc == NULL)
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (mc == NULL) mc = &rpmGlobalMacroContext;
|
||||
|
||||
tbuf = alloca(slen + 1);
|
||||
memset(tbuf, 0, (slen + 1));
|
||||
|
@ -1340,12 +1367,11 @@ expandMacros(void *spec, MacroContext *mc, char *s, size_t slen)
|
|||
}
|
||||
|
||||
void
|
||||
addMacro(MacroContext *mc, const char *n, const char *o, const char *b, int level)
|
||||
addMacro(MacroContext mc, const char *n, const char *o, const char *b, int level)
|
||||
{
|
||||
MacroEntry **mep;
|
||||
MacroEntry *mep;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (mc == NULL) mc = &rpmGlobalMacroContext;
|
||||
|
||||
/* If new name, expand macro table */
|
||||
if ((mep = findEntry(mc, n, 0)) == NULL) {
|
||||
|
@ -1363,12 +1389,11 @@ addMacro(MacroContext *mc, const char *n, const char *o, const char *b, int leve
|
|||
}
|
||||
|
||||
void
|
||||
delMacro(MacroContext *mc, const char *n)
|
||||
delMacro(MacroContext mc, const char *n)
|
||||
{
|
||||
MacroEntry **mep;
|
||||
MacroEntry *mep;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (mc == NULL) mc = &rpmGlobalMacroContext;
|
||||
/* If name exists, pop entry */
|
||||
if ((mep = findEntry(mc, n, 0)) != NULL) {
|
||||
popMacro(mep);
|
||||
|
@ -1379,7 +1404,7 @@ delMacro(MacroContext *mc, const char *n)
|
|||
}
|
||||
|
||||
int
|
||||
rpmDefineMacro(MacroContext *mc, const char *macro, int level)
|
||||
rpmDefineMacro(MacroContext mc, const char *macro, int level)
|
||||
{
|
||||
MacroBuf macrobuf, *mb = ¯obuf;
|
||||
|
||||
|
@ -1393,15 +1418,16 @@ rpmDefineMacro(MacroContext *mc, const char *macro, int level)
|
|||
}
|
||||
|
||||
void
|
||||
rpmLoadMacros(MacroContext * mc, int level)
|
||||
rpmLoadMacros(MacroContext mc, int level)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (mc == NULL || mc == &rpmGlobalMacroContext)
|
||||
return;
|
||||
|
||||
if (mc->macroTable != NULL) {
|
||||
int i;
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry **mep, *me;
|
||||
MacroEntry *mep, me;
|
||||
mep = &mc->macroTable[i];
|
||||
me = *mep;
|
||||
|
||||
|
@ -1409,19 +1435,19 @@ rpmLoadMacros(MacroContext * mc, int level)
|
|||
continue;
|
||||
addMacro(NULL, me->name, me->opts, me->body, (level - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rpmInitMacros(MacroContext *mc, const char *macrofiles)
|
||||
rpmInitMacros(MacroContext mc, const char *macrofiles)
|
||||
{
|
||||
char *m, *mfile, *me;
|
||||
|
||||
if (macrofiles == NULL)
|
||||
return;
|
||||
if (mc == NULL)
|
||||
mc = &rpmGlobalMacroContext;
|
||||
if (mc == NULL) mc = &rpmGlobalMacroContext;
|
||||
|
||||
for (mfile = m = xstrdup(macrofiles); *mfile != '\0'; mfile = me) {
|
||||
for (mfile = m = xstrdup(macrofiles); mfile && *mfile != '\0'; mfile = me) {
|
||||
FD_t fd;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
|
@ -1470,10 +1496,7 @@ rpmInitMacros(MacroContext *mc, const char *macrofiles)
|
|||
}
|
||||
(void) Fclose(fd);
|
||||
}
|
||||
if (m) {
|
||||
free(m);
|
||||
m = NULL;
|
||||
}
|
||||
m = _free(m);
|
||||
|
||||
/* Reload cmdline macros */
|
||||
rpmLoadMacros(&rpmCLIMacroContext, RMIL_CMDLINE);
|
||||
|
@ -1481,27 +1504,28 @@ rpmInitMacros(MacroContext *mc, const char *macrofiles)
|
|||
|
||||
/*@-globstate@*/
|
||||
void
|
||||
rpmFreeMacros(MacroContext *mc)
|
||||
rpmFreeMacros(MacroContext mc)
|
||||
{
|
||||
|
||||
if (mc == NULL) mc = &rpmGlobalMacroContext;
|
||||
|
||||
if (mc->macroTable != NULL) {
|
||||
int i;
|
||||
|
||||
if (mc == NULL)
|
||||
mc = &rpmGlobalMacroContext;
|
||||
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry *me;
|
||||
MacroEntry me;
|
||||
while ((me = mc->macroTable[i]) != NULL) {
|
||||
/* XXX cast to workaround const */
|
||||
/*@-onlytrans@*/
|
||||
if ((mc->macroTable[i] = me->prev) == NULL)
|
||||
FREE(me->name);
|
||||
me->name = _free(me->name);
|
||||
/*@=onlytrans@*/
|
||||
FREE(me->opts);
|
||||
FREE(me->body);
|
||||
FREE(me);
|
||||
me->opts = _free(me->opts);
|
||||
me->body = _free(me->body);
|
||||
me = _free(me);
|
||||
}
|
||||
}
|
||||
FREE(mc->macroTable);
|
||||
mc->macroTable = _free(mc->macroTable);
|
||||
}
|
||||
memset(mc, 0, sizeof(*mc));
|
||||
}
|
||||
/*@=globstate@*/
|
||||
|
@ -1601,7 +1625,7 @@ rpmExpandNumeric(const char *arg)
|
|||
if (!(end && *end == '\0'))
|
||||
rc = 0;
|
||||
}
|
||||
free((void *)val);
|
||||
val = _free(val);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -1613,6 +1637,9 @@ char *rpmCleanPath(char * path)
|
|||
char *se, *t, *te;
|
||||
int begin = 1;
|
||||
|
||||
if (path == NULL)
|
||||
return NULL;
|
||||
|
||||
/*fprintf(stderr, "*** RCP %s ->\n", path); */
|
||||
s = t = te = path;
|
||||
while (*s != '\0') {
|
||||
|
@ -1767,9 +1794,9 @@ fprintf(stderr, "*** RGP ut %d file %s nurl %d\n", ut, file, nurl);
|
|||
|
||||
result = rpmGetPath(url, root, "/", mdir, "/", file, NULL);
|
||||
|
||||
free((void *)xroot);
|
||||
free((void *)xmdir);
|
||||
free((void *)xfile);
|
||||
xroot = _free(xroot);
|
||||
xmdir = _free(xmdir);
|
||||
xfile = _free(xfile);
|
||||
if (_debug)
|
||||
fprintf(stderr, "*** RGP result %s\n", result);
|
||||
return result;
|
||||
|
@ -1814,7 +1841,7 @@ main(int argc, char *argv[])
|
|||
val = rpmGetPath(argv[optind], NULL);
|
||||
if (val) {
|
||||
fprintf(stdout, "%s:\t%s\n", argv[optind], val);
|
||||
free((void *)val);
|
||||
val = _free(val);
|
||||
}
|
||||
}
|
||||
rpmFreeMacros(NULL);
|
||||
|
|
|
@ -65,6 +65,7 @@ typedef enum rpmerrCode_e {
|
|||
RPMERR_OLDDB = _em(41), /*!< old format database */
|
||||
|
||||
RPMERR_UNMATCHEDIF = _em(107), /*!< unclosed %ifarch or %ifos */
|
||||
RPMERR_RELOAD = _em(108), /*!< */
|
||||
RPMERR_BADARG = _em(109), /*!< */
|
||||
RPMERR_SCRIPT = _em(110), /*!< errors related to script exec */
|
||||
RPMERR_READ = _em(111), /*!< */
|
||||
|
|
140
rpmio/rpmio.c
140
rpmio/rpmio.c
|
@ -105,12 +105,16 @@ int _rpmio_debug = 0;
|
|||
|
||||
/* =============================================================== */
|
||||
|
||||
static /*@observer@*/ const char * fdbg(FD_t fd)
|
||||
static /*@observer@*/ const char * fdbg(/*@null@*/ FD_t fd)
|
||||
{
|
||||
static char buf[BUFSIZ];
|
||||
char *be = buf;
|
||||
int i;
|
||||
|
||||
buf[0] = '\0';
|
||||
if (fd == NULL)
|
||||
return buf;
|
||||
|
||||
#if DYING
|
||||
sprintf(be, "fd %p", fd); be += strlen(be);
|
||||
if (fd->rd_timeoutsecs >= 0) {
|
||||
|
@ -194,7 +198,7 @@ FD_t fdDup(int fdno) {
|
|||
return NULL;
|
||||
fd = fdNew("open (fdDup)");
|
||||
fdSetFdno(fd, nfdno);
|
||||
DBGIO(fd, (stderr, "==> fdDup(%d) fd %p %s\n", fdno, fd, fdbg(fd)));
|
||||
DBGIO(fd, (stderr, "==> fdDup(%d) fd %p %s\n", fdno, (fd ? fd : NULL), fdbg(fd)));
|
||||
/*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/
|
||||
}
|
||||
|
||||
|
@ -227,7 +231,7 @@ DBGIO(fd, (stderr, "==> fdFdopen(%p,\"%s\") fdno %d -> fp %p fdno %d\n", cookie,
|
|||
#endif
|
||||
|
||||
/* =============================================================== */
|
||||
static inline FD_t XfdLink(void * cookie, const char *msg, const char *file, unsigned line) {
|
||||
static inline /*@null@*/ FD_t XfdLink(void * cookie, const char *msg, const char *file, unsigned line) {
|
||||
FD_t fd;
|
||||
if (cookie == NULL)
|
||||
DBGREFS(0, (stderr, "--> fd %p ++ %d %s at %s:%u\n", cookie, FDNREFS(cookie)+1, msg, file, line));
|
||||
|
@ -256,7 +260,7 @@ DBGREFS(fd, (stderr, "--> fd %p -- %d %s at %s:%u %s\n", fd, fd->nrefs, msg, fi
|
|||
|
||||
static inline /*@null@*/ FD_t XfdNew(const char *msg, const char *file, unsigned line) {
|
||||
FD_t fd = (FD_t) xmalloc(sizeof(struct _FD_s));
|
||||
if (fd == NULL)
|
||||
if (fd == NULL) /* XXX xmalloc never returns NULL */
|
||||
return NULL;
|
||||
fd->nrefs = 0;
|
||||
fd->flags = 0;
|
||||
|
@ -372,7 +376,7 @@ int fdClose( /*@only@*/ void * cookie) {
|
|||
rc = ((fdno >= 0) ? close(fdno) : -2);
|
||||
fdstat_exit(fd, FDSTAT_CLOSE, rc);
|
||||
|
||||
DBGIO(fd, (stderr, "==>\tfdClose(%p) rc %lx %s\n", fd, (unsigned long)rc, fdbg(fd)));
|
||||
DBGIO(fd, (stderr, "==>\tfdClose(%p) rc %lx %s\n", (fd ? fd : NULL), (unsigned long)rc, fdbg(fd)));
|
||||
|
||||
fd = fdFree(fd, "open (fdClose)");
|
||||
return rc;
|
||||
|
@ -418,9 +422,9 @@ int fdWritable(FD_t fd, int secs)
|
|||
tvp->tv_usec = 0;
|
||||
}
|
||||
errno = 0;
|
||||
/*@-compdef@*/
|
||||
/*@-compdef -nullpass@*/
|
||||
rc = select(fdno + 1, NULL, &wrfds, NULL, tvp);
|
||||
/*@=compdef@*/
|
||||
/*@=compdef =nullpass@*/
|
||||
|
||||
if (_rpmio_debug && !(rc == 1 && errno == 0))
|
||||
fprintf(stderr, "*** fdWritable fdno %d rc %d %s\n", fdno, rc, strerror(errno));
|
||||
|
@ -458,9 +462,9 @@ int fdReadable(FD_t fd, int secs)
|
|||
tvp->tv_usec = 0;
|
||||
}
|
||||
errno = 0;
|
||||
/*@-compdef@*/
|
||||
/*@-compdef -nullpass@*/
|
||||
rc = select(fdno + 1, &rdfds, NULL, NULL, tvp);
|
||||
/*@=compdef@*/
|
||||
/*@=compdef =nullpass@*/
|
||||
|
||||
if (rc < 0) {
|
||||
switch (errno) {
|
||||
|
@ -615,7 +619,9 @@ static int mygethostbyname(const char * host, struct in_addr * address)
|
|||
hostinfo = /*@-unrecog@*/ gethostbyname(host) /*@=unrecog@*/;
|
||||
if (!hostinfo) return 1;
|
||||
|
||||
/*@-nullderef@*/
|
||||
memcpy(address, hostinfo->h_addr_list[0], sizeof(*address));
|
||||
/*@=nullderef@*/
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -923,8 +929,9 @@ static int ftpLogin(urlinfo u)
|
|||
user = "anonymous";
|
||||
|
||||
if ((password = u->password) == NULL) {
|
||||
if (getuid()) {
|
||||
struct passwd * pw = getpwuid(getuid());
|
||||
uid_t uid = getuid();
|
||||
struct passwd * pw;
|
||||
if (uid && (pw = getpwuid(uid)) != NULL) {
|
||||
char *myp = alloca(strlen(pw->pw_name) + sizeof("@"));
|
||||
strcpy(myp, pw->pw_name);
|
||||
strcat(myp, "@");
|
||||
|
@ -1192,7 +1199,7 @@ static int urlConnect(const char * url, /*@out@*/ urlinfo * uret)
|
|||
|
||||
if (fdFileno(u->ctrl) < 0) {
|
||||
rpmMessage(RPMMESS_DEBUG, _("logging into %s as %s, pw %s\n"),
|
||||
u->host,
|
||||
u->host ? u->host : "???",
|
||||
u->user ? u->user : "ftp",
|
||||
u->password ? u->password : "(username)");
|
||||
|
||||
|
@ -1367,6 +1374,7 @@ static int httpReq(FD_t ctrl, const char * httpCmd, const char * httpArg)
|
|||
|
||||
if ((port = (u->proxyp > 0 ? u->proxyp : u->port)) < 0) port = 80;
|
||||
path = (u->proxyh || u->proxyp > 0) ? u->url : httpArg;
|
||||
if (path == NULL) path = "";
|
||||
|
||||
reopen:
|
||||
if (fdFileno(ctrl) >= 0 && (rc = fdWritable(ctrl, 0)) < 1) {
|
||||
|
@ -1621,11 +1629,11 @@ int ufdClose( /*@only@*/ void * cookie)
|
|||
|
||||
/* XXX if not using libio, lose the fp from fpio */
|
||||
{ FILE * fp;
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
fp = fdGetFILE(fd);
|
||||
if (noLibio && fp)
|
||||
fdSetFp(fd, NULL);
|
||||
/*@=voidabstract@*/
|
||||
/*@=voidabstract =nullpass@*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1634,9 +1642,7 @@ int ufdClose( /*@only@*/ void * cookie)
|
|||
* "grab data (ufdOpen FTP)" rpmio.c:892
|
||||
* "open data (ftpReq)" ftp.c:633
|
||||
* "fopencookie" rpmio.c:1507
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Normal FTP has 5 refs on the ctrl fd:
|
||||
* "persist ctrl" url.c:176
|
||||
* "grab ctrl (urlConnect FTP)" rpmio.c:404
|
||||
|
@ -1664,7 +1670,8 @@ int ufdClose( /*@only@*/ void * cookie)
|
|||
}
|
||||
}
|
||||
|
||||
if (!strcmp(u->service, "http")) {
|
||||
/* XXX Why not (u->urltype == URL_IS_HTTP) ??? */
|
||||
if (u->service != NULL && !strcmp(u->service, "http")) {
|
||||
if (fd->wr_chunked) {
|
||||
int rc;
|
||||
/* XXX HTTP PUT requires terminating 0 length chunk. */
|
||||
|
@ -1695,11 +1702,11 @@ fprintf(stderr, "-> \r\n");
|
|||
|
||||
/* XXX if not using libio, lose the fp from fpio */
|
||||
{ FILE * fp;
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
fp = fdGetFILE(fd);
|
||||
if (noLibio && fp)
|
||||
fdSetFp(fd, NULL);
|
||||
/*@=voidabstract@*/
|
||||
/*@=voidabstract =nullpass@*/
|
||||
}
|
||||
|
||||
if (fd->persist && u->httpVersion &&
|
||||
|
@ -1910,7 +1917,7 @@ static /*@null@*/ FD_t gzdOpen(const char *path, const char *fmode) {
|
|||
fd = fdNew("open (gzdOpen)");
|
||||
fdPop(fd); fdPush(fd, gzdio, gzfile, -1);
|
||||
|
||||
DBGIO(fd, (stderr, "==>\tgzdOpen(\"%s\", \"%s\") fd %p %s\n", path, fmode, fd, fdbg(fd)));
|
||||
DBGIO(fd, (stderr, "==>\tgzdOpen(\"%s\", \"%s\") fd %p %s\n", path, fmode, (fd ? fd : NULL), fdbg(fd)));
|
||||
return fdLink(fd, "gzdOpen");
|
||||
}
|
||||
|
||||
|
@ -1941,11 +1948,13 @@ static ssize_t gzdRead(void * cookie, /*@out@*/ char * buf, size_t count) {
|
|||
gzFile *gzfile;
|
||||
ssize_t rc;
|
||||
|
||||
if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
|
||||
if (fd == NULL || fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
|
||||
gzfile = gzdFileno(fd);
|
||||
fdstat_enter(fd, FDSTAT_READ);
|
||||
rc = gzread(gzfile, buf, count);
|
||||
/*@-compdef@*/
|
||||
DBGIO(fd, (stderr, "==>\tgzdRead(%p,%p,%u) rc %lx %s\n", cookie, buf, (unsigned)count, (unsigned long)rc, fdbg(fd)));
|
||||
/*@=compdef@*/
|
||||
if (rc < 0) {
|
||||
int zerror = 0;
|
||||
fd->errcookie = gzerror(gzfile, &zerror);
|
||||
|
@ -1955,7 +1964,9 @@ DBGIO(fd, (stderr, "==>\tgzdRead(%p,%p,%u) rc %lx %s\n", cookie, buf, (unsigned)
|
|||
}
|
||||
} else if (rc >= 0) {
|
||||
fdstat_exit(fd, FDSTAT_READ, rc);
|
||||
/*@-compdef@*/
|
||||
if (fd->digest && rc > 0) rpmDigestUpdate(fd->digest, buf, rc);
|
||||
/*@=compdef@*/
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
@ -1965,7 +1976,7 @@ static ssize_t gzdWrite(void * cookie, const char * buf, size_t count) {
|
|||
gzFile *gzfile;
|
||||
ssize_t rc;
|
||||
|
||||
if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
|
||||
if (fd == NULL || fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
|
||||
|
||||
if (fd->digest && count > 0) rpmDigestUpdate(fd->digest, buf, count);
|
||||
|
||||
|
@ -1998,6 +2009,7 @@ static inline int gzdSeek(void * cookie, _libio_pos_t pos, int whence) {
|
|||
FD_t fd = c2f(cookie);
|
||||
gzFile *gzfile;
|
||||
|
||||
if (fd == NULL) return -2;
|
||||
assert(fd->bytesRemain == -1); /* XXX FIXME */
|
||||
gzfile = gzdFileno(fd);
|
||||
fdstat_enter(fd, FDSTAT_SEEK);
|
||||
|
@ -2078,7 +2090,7 @@ FDIO_t gzdio = /*@-compmempass@*/ &gzdio_s /*@=compmempass@*/ ;
|
|||
# define bzwrite BZ2_bzwrite
|
||||
#endif /* HAVE_BZ2_1_0 */
|
||||
|
||||
static inline /*@dependent@*/ /*@null@*/ void * bzdFileno(FD_t fd) {
|
||||
static inline /*@dependent@*/ void * bzdFileno(FD_t fd) {
|
||||
void * rc = NULL;
|
||||
int i;
|
||||
|
||||
|
@ -2129,18 +2141,24 @@ static int bzdFlush(FD_t fd) {
|
|||
static ssize_t bzdRead(void * cookie, /*@out@*/ char * buf, size_t count) {
|
||||
FD_t fd = c2f(cookie);
|
||||
BZFILE *bzfile;
|
||||
ssize_t rc;
|
||||
ssize_t rc = 0;
|
||||
|
||||
if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
|
||||
bzfile = bzdFileno(fd);
|
||||
fdstat_enter(fd, FDSTAT_READ);
|
||||
if (bzfile)
|
||||
/*@-compdef@*/
|
||||
rc = bzread(bzfile, buf, count);
|
||||
/*@=compdef@*/
|
||||
if (rc == -1) {
|
||||
int zerror = 0;
|
||||
if (bzfile)
|
||||
fd->errcookie = bzerror(bzfile, &zerror);
|
||||
} else if (rc >= 0) {
|
||||
fdstat_exit(fd, FDSTAT_READ, rc);
|
||||
/*@-compdef@*/
|
||||
if (fd->digest && rc > 0) rpmDigestUpdate(fd->digest, buf, rc);
|
||||
/*@=compdef@*/
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
@ -2256,16 +2274,18 @@ size_t Fread(void *buf, size_t size, size_t nmemb, FD_t fd) {
|
|||
#ifdef __LCLINT__
|
||||
*(char *)buf = '\0';
|
||||
#endif
|
||||
DBGIO(fd, (stderr, "==> Fread(%p,%u,%u,%p) %s\n", buf, (unsigned)size, (unsigned)nmemb, fd, fdbg(fd)));
|
||||
DBGIO(fd, (stderr, "==> Fread(%p,%u,%u,%p) %s\n", buf, (unsigned)size, (unsigned)nmemb, (fd ? fd : NULL), fdbg(fd)));
|
||||
|
||||
if (fdGetIo(fd) == fpio) {
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
rc = fread(buf, size, nmemb, fdGetFILE(fd));
|
||||
/*@=voidabstract@*/
|
||||
/*@=voidabstract =nullpass@*/
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*@-nullderef@*/
|
||||
_read = FDIOVEC(fd, read);
|
||||
/*@=nullderef@*/
|
||||
|
||||
rc = (_read ? (*_read) (fd, buf, size * nmemb) : -2);
|
||||
return rc;
|
||||
|
@ -2276,16 +2296,18 @@ size_t Fwrite(const void *buf, size_t size, size_t nmemb, FD_t fd) {
|
|||
int rc;
|
||||
|
||||
FDSANE(fd);
|
||||
DBGIO(fd, (stderr, "==> Fwrite(%p,%u,%u,%p) %s\n", buf, (unsigned)size, (unsigned)nmemb, fd, fdbg(fd)));
|
||||
DBGIO(fd, (stderr, "==> Fwrite(%p,%u,%u,%p) %s\n", buf, (unsigned)size, (unsigned)nmemb, (fd ? fd : NULL), fdbg(fd)));
|
||||
|
||||
if (fdGetIo(fd) == fpio) {
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
rc = fwrite(buf, size, nmemb, fdGetFILE(fd));
|
||||
/*@=voidabstract@*/
|
||||
/*@=voidabstract =nullpass@*/
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*@-nullderef@*/
|
||||
_write = FDIOVEC(fd, write);
|
||||
/*@=nullderef@*/
|
||||
|
||||
rc = (_write ? _write(fd, buf, size * nmemb) : -2);
|
||||
return rc;
|
||||
|
@ -2308,24 +2330,26 @@ DBGIO(fd, (stderr, "==> Fseek(%p,%ld,%d) %s\n", fd, (long)offset, whence, fdbg(f
|
|||
if (fdGetIo(fd) == fpio) {
|
||||
FILE *fp;
|
||||
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
fp = fdGetFILE(fd);
|
||||
/*@=voidabstract@*/
|
||||
rc = fseek(fp, offset, whence);
|
||||
/*@=voidabstract =nullpass@*/
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*@-nullderef@*/
|
||||
_seek = FDIOVEC(fd, seek);
|
||||
/*@=nullderef@*/
|
||||
|
||||
rc = (_seek ? _seek(fd, pos, whence) : -2);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int Fclose(FD_t fd) {
|
||||
int rc, ec = 0;
|
||||
int rc = 0, ec = 0;
|
||||
|
||||
FDSANE(fd);
|
||||
DBGIO(fd, (stderr, "==> Fclose(%p) %s\n", fd, fdbg(fd)));
|
||||
DBGIO(fd, (stderr, "==> Fclose(%p) %s\n", (fd ? fd : NULL), fdbg(fd)));
|
||||
|
||||
fd = fdLink(fd, "Fclose");
|
||||
while (fd->nfps >= 0) {
|
||||
|
@ -2335,17 +2359,18 @@ DBGIO(fd, (stderr, "==> Fclose(%p) %s\n", fd, fdbg(fd)));
|
|||
FILE *fp;
|
||||
int fpno;
|
||||
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
fp = fdGetFILE(fd);
|
||||
/*@=voidabstract@*/
|
||||
fpno = fileno(fp);
|
||||
/*@=voidabstract =nullpass@*/
|
||||
/* XXX persistent HTTP/1.1 returns the previously opened fp */
|
||||
if (fd->nfps > 0 && fpno == -1 &&
|
||||
fd->fps[fd->nfps-1].io == ufdio &&
|
||||
fd->fps[fd->nfps-1].fp == fp &&
|
||||
fd->fps[fd->nfps-1].fdno >= 0)
|
||||
{
|
||||
(void) fflush(fp);
|
||||
if (fp)
|
||||
rc = fflush(fp);
|
||||
fd->nfps--;
|
||||
/*@-refcounttrans@*/
|
||||
rc = ufdClose(fd);
|
||||
|
@ -2355,11 +2380,13 @@ DBGIO(fd, (stderr, "==> Fclose(%p) %s\n", fd, fdbg(fd)));
|
|||
break;
|
||||
fdSetFp(fd, NULL);
|
||||
fd->nfps++;
|
||||
if (fp)
|
||||
rc = fclose(fp);
|
||||
fdPop(fd);
|
||||
if (noLibio)
|
||||
fdSetFp(fd, NULL);
|
||||
} else {
|
||||
if (fp)
|
||||
rc = fclose(fp);
|
||||
if (fpno == -1) {
|
||||
fd = fdFree(fd, "fopencookie (Fclose)");
|
||||
|
@ -2367,7 +2394,9 @@ DBGIO(fd, (stderr, "==> Fclose(%p) %s\n", fd, fdbg(fd)));
|
|||
}
|
||||
}
|
||||
} else {
|
||||
/*@-nullderef@*/
|
||||
fdio_close_function_t * _close = FDIOVEC(fd, close);
|
||||
/*@=nullderef@*/
|
||||
rc = _close(fd);
|
||||
}
|
||||
if (fd->nfps == 0)
|
||||
|
@ -2501,10 +2530,10 @@ fprintf(stderr, "*** Fdopen(%p,%s) %s\n", fd, fmode, fdbg(fd));
|
|||
if (noLibio) {
|
||||
int fdno = Fileno(fd);
|
||||
FILE * fp = fdopen(fdno, stdio);
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Fdopen fpio fp %p\n", (void *)fp);
|
||||
/*@=voidabstract@*/
|
||||
/*@=voidabstract =nullpass@*/
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
/* XXX gzdio/bzdio use fp for private data */
|
||||
|
@ -2542,16 +2571,16 @@ DBGIO(fd, (stderr, "==> fopencookie(%p,\"%s\",*%p) returns fp %p\n", fd, stdio,
|
|||
|
||||
if (fp) {
|
||||
/* XXX gzdio/bzdio use fp for private data */
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
if (fdGetFp(fd) == NULL)
|
||||
fdSetFp(fd, fp);
|
||||
fdPush(fd, fpio, fp, fileno(fp)); /* Push fpio onto stack */
|
||||
/*@=voidabstract@*/
|
||||
/*@=voidabstract =nullpass@*/
|
||||
fd = fdLink(fd, "fopencookie");
|
||||
}
|
||||
}
|
||||
|
||||
DBGIO(fd, (stderr, "==> Fdopen(%p,\"%s\") returns fd %p %s\n", ofd, fmode, fd, fdbg(fd)));
|
||||
DBGIO(fd, (stderr, "==> Fdopen(%p,\"%s\") returns fd %p %s\n", ofd, fmode, (fd ? fd : NULL), fdbg(fd)));
|
||||
/*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/
|
||||
}
|
||||
|
||||
|
@ -2575,7 +2604,7 @@ if (_rpmio_debug)
|
|||
fprintf(stderr, "*** Fopen fdio path %s fmode %s\n", path, fmode);
|
||||
fd = fdOpen(path, flags, perms);
|
||||
if (fdFileno(fd) < 0) {
|
||||
(void) fdClose(fd);
|
||||
if (fd) (void) fdClose(fd);
|
||||
return NULL;
|
||||
}
|
||||
} else if (!strcmp(end, "fadio")) {
|
||||
|
@ -2623,23 +2652,28 @@ fprintf(stderr, "*** Fopen WTFO path %s fmode %s\n", path, fmode);
|
|||
}
|
||||
}
|
||||
|
||||
if (fd)
|
||||
fd = Fdopen(fd, fmode);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int Fflush(FD_t fd)
|
||||
{
|
||||
void * vh;
|
||||
if (fd == NULL) return -1;
|
||||
if (fdGetIo(fd) == fpio)
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
return fflush(fdGetFILE(fd));
|
||||
/*@=voidabstract@*/
|
||||
if (fdGetIo(fd) == gzdio)
|
||||
return gzdFlush(fdGetFp(fd));
|
||||
/*@=voidabstract =nullpass@*/
|
||||
|
||||
vh = fdGetFp(fd);
|
||||
if (vh && fdGetIo(fd) == gzdio)
|
||||
return gzdFlush(vh);
|
||||
#if HAVE_BZLIB_H
|
||||
if (fdGetIo(fd) == bzdio)
|
||||
return bzdFlush(fdGetFp(fd));
|
||||
if (vh && fdGetIo(fd) == bzdio)
|
||||
return bzdFlush(vh);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2652,9 +2686,9 @@ int Ferror(FD_t fd) {
|
|||
int ec;
|
||||
|
||||
if (fps->io == fpio) {
|
||||
/*@+voidabstract@*/
|
||||
/*@+voidabstract -nullpass@*/
|
||||
ec = ferror(fdGetFILE(fd));
|
||||
/*@=voidabstract@*/
|
||||
/*@=voidabstract =nullpass@*/
|
||||
} else if (fps->io == gzdio) {
|
||||
ec = (fd->syserrno || fd->errcookie != NULL) ? -1 : 0;
|
||||
#if HAVE_BZLIB_H
|
||||
|
@ -2679,7 +2713,7 @@ int Fileno(FD_t fd) {
|
|||
for (i = fd->nfps ; rc == -1 && i >= 0; i--) {
|
||||
rc = fd->fps[i].fdno;
|
||||
}
|
||||
DBGIO(fd, (stderr, "==> Fileno(%p) rc %d %s\n", fd, rc, fdbg(fd)));
|
||||
DBGIO(fd, (stderr, "==> Fileno(%p) rc %d %s\n", (fd ? fd : NULL), rc, fdbg(fd)));
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ struct FDIO_s {
|
|||
/** \ingroup rpmio
|
||||
* strerror(3) clone.
|
||||
*/
|
||||
/*@observer@*/ const char * Fstrerror(FD_t fd);
|
||||
/*@observer@*/ const char * Fstrerror(/*@null@*/ FD_t fd);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* fread(3) clone.
|
||||
|
@ -165,7 +165,7 @@ size_t Fread (/*@out@*/ void * buf, size_t size, size_t nmemb, FD_t fd);
|
|||
/** \ingroup rpmio
|
||||
* fwrite(3) clone.
|
||||
*/
|
||||
size_t Fwrite (const void *buf, size_t size, size_t nmemb, FD_t fd);
|
||||
size_t Fwrite (const void * buf, size_t size, size_t nmemb, FD_t fd);
|
||||
|
||||
|
||||
/** \ingroup rpmio
|
||||
|
@ -180,23 +180,23 @@ int Fclose ( /*@killref@*/ FD_t fd);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
FD_t Fdopen (FD_t fd, const char * fmode);
|
||||
/*@null@*/ FD_t Fdopen (FD_t fd, const char * fmode);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* fopen(3) clone.
|
||||
*/
|
||||
FD_t Fopen (const char * path, const char * fmode);
|
||||
/*@null@*/ FD_t Fopen (/*@null@*/ const char * path, /*@null@*/ const char * fmode);
|
||||
|
||||
|
||||
/** \ingroup rpmio
|
||||
* fflush(3) clone.
|
||||
*/
|
||||
int Fflush (FD_t fd);
|
||||
int Fflush (/*@null@*/ FD_t fd);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* ferror(3) clone.
|
||||
*/
|
||||
int Ferror (FD_t fd);
|
||||
int Ferror (/*@null@*/ FD_t fd);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* fileno(3) clone.
|
||||
|
@ -292,17 +292,17 @@ void Globfree( /*@only@*/ glob_t * pglob);
|
|||
/** \ingroup rpmrpc
|
||||
* opendir(3) clone.
|
||||
*/
|
||||
DIR * Opendir (const char * name);
|
||||
/*@null@*/ DIR * Opendir (const char * name);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* readdir(3) clone.
|
||||
*/
|
||||
struct dirent * Readdir (DIR * dir);
|
||||
/*@null@*/ struct dirent * Readdir (DIR * dir);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* closedir(3) clone.
|
||||
*/
|
||||
int Closedir(DIR * dir);
|
||||
int Closedir(/*@only@*/ DIR * dir);
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
/*@-shadow@*/
|
||||
static inline int fdFileno(void * cookie);
|
||||
static inline int fdFileno(/*@null@*/ void * cookie);
|
||||
/*@=shadow@*/
|
||||
|
||||
#include <rpmio.h>
|
||||
|
@ -85,8 +85,9 @@ void rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len);
|
|||
* @retval lenp address of digest length
|
||||
* @param asAscii return digest as ascii string?
|
||||
*/
|
||||
void rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx, /*@out@*/ void ** datap,
|
||||
/*@out@*/ size_t *lenp, int asAscii);
|
||||
void rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx,
|
||||
/*@null@*/ /*@out@*/ void ** datap,
|
||||
/*@null@*/ /*@out@*/ size_t *lenp, int asAscii);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* The FD_t File Handle data structure.
|
||||
|
@ -147,21 +148,24 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/ const FDIO_t fdGetIo(FD_t fd) {
|
||||
/*@unused@*/ static inline
|
||||
/*@null@*/ const FDIO_t fdGetIo(FD_t fd) {
|
||||
FDSANE(fd);
|
||||
return fd->fps[fd->nfps].io;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdSetIo(FD_t fd, FDIO_t io) {
|
||||
/*@unused@*/ static inline
|
||||
void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io) {
|
||||
FDSANE(fd);
|
||||
fd->fps[fd->nfps].io = io;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline /*@dependent@*/ /*@null@*/ FILE * fdGetFILE(FD_t fd) {
|
||||
/*@unused@*/ static inline
|
||||
/*@dependent@*/ /*@null@*/ FILE * fdGetFILE(FD_t fd) {
|
||||
FDSANE(fd);
|
||||
/*@+voidabstract@*/
|
||||
return ((FILE *)fd->fps[fd->nfps].fp);
|
||||
|
@ -170,35 +174,40 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline /*@dependent@*/ /*@null@*/ void * fdGetFp(FD_t fd) {
|
||||
/*@unused@*/ static inline
|
||||
/*@dependent@*/ /*@null@*/ void * fdGetFp(FD_t fd) {
|
||||
FDSANE(fd);
|
||||
return fd->fps[fd->nfps].fp;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdSetFp(FD_t fd, /*@kept@*/ void * fp) {
|
||||
/*@unused@*/ static inline
|
||||
void fdSetFp(FD_t fd, /*@kept@*/ /*@null@*/ void * fp) {
|
||||
FDSANE(fd);
|
||||
fd->fps[fd->nfps].fp = fp;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline int fdGetFdno(FD_t fd) {
|
||||
/*@unused@*/ static inline
|
||||
int fdGetFdno(FD_t fd) {
|
||||
FDSANE(fd);
|
||||
return fd->fps[fd->nfps].fdno;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdSetFdno(FD_t fd, int fdno) {
|
||||
/*@unused@*/ static inline
|
||||
void fdSetFdno(FD_t fd, int fdno) {
|
||||
FDSANE(fd);
|
||||
fd->fps[fd->nfps].fdno = fdno;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdSetContentLength(FD_t fd, ssize_t contentLength)
|
||||
/*@unused@*/ static inline
|
||||
void fdSetContentLength(FD_t fd, ssize_t contentLength)
|
||||
{
|
||||
FDSANE(fd);
|
||||
fd->contentLength = fd->bytesRemain = contentLength;
|
||||
|
@ -206,8 +215,8 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdPush(FD_t fd, FDIO_t io,
|
||||
void * fp, int fdno)
|
||||
/*@unused@*/ static inline
|
||||
void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno)
|
||||
{
|
||||
FDSANE(fd);
|
||||
if (fd->nfps >= (sizeof(fd->fps)/sizeof(fd->fps[0]) - 1))
|
||||
|
@ -231,16 +240,17 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdstat_enter(FD_t fd, int opx)
|
||||
/*@unused@*/ static inline void fdstat_enter(/*@null@*/ FD_t fd, int opx)
|
||||
{
|
||||
if (fd->stats == NULL) return;
|
||||
if (fd == NULL || fd->stats == NULL) return;
|
||||
fd->stats->ops[opx].count++;
|
||||
(void) gettimeofday(&fd->stats->begin, NULL);
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline time_t tvsub(struct timeval *etv, struct timeval *btv) {
|
||||
/*@unused@*/ static inline
|
||||
time_t tvsub(struct timeval * etv, struct timeval * btv) {
|
||||
time_t secs, usecs;
|
||||
if (!(etv && btv)) return 0;
|
||||
secs = etv->tv_sec - btv->tv_sec;
|
||||
|
@ -254,9 +264,11 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdstat_exit(FD_t fd, int opx, ssize_t rc)
|
||||
/*@unused@*/ static inline
|
||||
void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc)
|
||||
{
|
||||
struct timeval end;
|
||||
if (fd == NULL) return;
|
||||
if (rc == -1) fd->syserrno = errno;
|
||||
if (fd->stats == NULL) return;
|
||||
(void) gettimeofday(&end, NULL);
|
||||
|
@ -277,9 +289,10 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdstat_print(FD_t fd, const char * msg, FILE * fp) {
|
||||
/*@unused@*/ static inline
|
||||
void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp) {
|
||||
int opx;
|
||||
if (fd->stats == NULL) return;
|
||||
if (fd == NULL || fd->stats == NULL) return;
|
||||
for (opx = 0; opx < 4; opx++) {
|
||||
OPSTAT_t *ops = &fd->stats->ops[opx];
|
||||
if (ops->count <= 0) continue;
|
||||
|
@ -306,7 +319,8 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdSetSyserrno(FD_t fd, int syserrno, /*@kept@*/ const void * errcookie) {
|
||||
/*@unused@*/ static inline
|
||||
void fdSetSyserrno(FD_t fd, int syserrno, /*@kept@*/ const void * errcookie) {
|
||||
FDSANE(fd);
|
||||
fd->syserrno = syserrno;
|
||||
fd->errcookie = errcookie;
|
||||
|
@ -314,28 +328,32 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline int fdGetRdTimeoutSecs(FD_t fd) {
|
||||
/*@unused@*/ static inline
|
||||
int fdGetRdTimeoutSecs(FD_t fd) {
|
||||
FDSANE(fd);
|
||||
return fd->rd_timeoutsecs;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline long int fdGetCpioPos(FD_t fd) {
|
||||
/*@unused@*/ static inline
|
||||
long int fdGetCpioPos(FD_t fd) {
|
||||
FDSANE(fd);
|
||||
return fd->fd_cpioPos;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdSetCpioPos(FD_t fd, long int cpioPos) {
|
||||
/*@unused@*/ static inline
|
||||
void fdSetCpioPos(FD_t fd, long int cpioPos) {
|
||||
FDSANE(fd);
|
||||
fd->fd_cpioPos = cpioPos;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline FD_t c2f(void * cookie) {
|
||||
/*@mayexit@*/ /*@unused@*/ static inline
|
||||
FD_t c2f(/*@null@*/ void * cookie) {
|
||||
FD_t fd = (FD_t) cookie;
|
||||
FDSANE(fd);
|
||||
/*@-refcounttrans@*/ return fd; /*@=refcounttrans@*/
|
||||
|
@ -343,7 +361,8 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdInitMD5(FD_t fd, int flags) {
|
||||
/*@unused@*/ static inline
|
||||
void fdInitMD5(FD_t fd, int flags) {
|
||||
if (flags) flags = RPMDIGEST_NATIVE;
|
||||
flags |= RPMDIGEST_MD5;
|
||||
fd->digest = rpmDigestInit(flags);
|
||||
|
@ -351,13 +370,15 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdInitSHA1(FD_t fd) {
|
||||
/*@unused@*/ static inline
|
||||
void fdInitSHA1(FD_t fd) {
|
||||
fd->digest = rpmDigestInit(RPMDIGEST_SHA1);
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdFiniMD5(FD_t fd, void **datap, size_t *lenp, int asAscii) {
|
||||
/*@unused@*/ static inline
|
||||
void fdFiniMD5(FD_t fd, void **datap, size_t *lenp, int asAscii) {
|
||||
if (fd->digest == NULL) {
|
||||
if (datap) *datap = NULL;
|
||||
if (lenp) *lenp = 0;
|
||||
|
@ -371,7 +392,8 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline void fdFiniSHA1(FD_t fd, void **datap, size_t *lenp, int asAscii) {
|
||||
/*@unused@*/ static inline
|
||||
void fdFiniSHA1(FD_t fd, void **datap, size_t *lenp, int asAscii) {
|
||||
if (fd->digest == NULL) {
|
||||
if (datap) *datap = NULL;
|
||||
if (lenp) *lenp = 0;
|
||||
|
@ -386,7 +408,8 @@ int ufdClose( /*@only@*/ void * cookie);
|
|||
/*@-shadow@*/
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline int fdFileno(void * cookie) {
|
||||
/*@unused@*/ static inline
|
||||
int fdFileno(/*@null@*/ void * cookie) {
|
||||
FD_t fd;
|
||||
if (cookie == NULL) return -2;
|
||||
fd = c2f(cookie);
|
||||
|
|
|
@ -12,6 +12,16 @@
|
|||
static int nrecs = 0;
|
||||
static /*@only@*/ /*@null@*/ rpmlogRec recs = NULL;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
int rpmlogGetNrecs(void)
|
||||
{
|
||||
return nrecs;
|
||||
|
@ -19,7 +29,7 @@ int rpmlogGetNrecs(void)
|
|||
|
||||
int rpmlogCode(void)
|
||||
{
|
||||
if (nrecs > 0)
|
||||
if (recs != NULL && nrecs > 0)
|
||||
return recs[nrecs-1].code;
|
||||
return -1;
|
||||
}
|
||||
|
@ -27,7 +37,7 @@ int rpmlogCode(void)
|
|||
|
||||
const char * rpmlogMessage(void)
|
||||
{
|
||||
if (nrecs > 0)
|
||||
if (recs != NULL && nrecs > 0)
|
||||
return recs[nrecs-1].message;
|
||||
return _("(no error)");
|
||||
}
|
||||
|
@ -52,13 +62,9 @@ void rpmlogClose (void)
|
|||
|
||||
for (i = 0; i < nrecs; i++) {
|
||||
rpmlogRec rec = recs + i;
|
||||
if (rec->message) {
|
||||
free((void *)rec->message);
|
||||
rec->message = NULL;
|
||||
rec->message = _free(rec->message);
|
||||
}
|
||||
}
|
||||
free(recs);
|
||||
recs = NULL;
|
||||
recs = _free(recs);
|
||||
nrecs = 0;
|
||||
}
|
||||
|
||||
|
@ -112,10 +118,8 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
|
|||
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;
|
||||
|
||||
if ((mask & rpmlogMask) == 0)
|
||||
return;
|
||||
|
@ -126,7 +130,7 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
|
|||
/* Allocate a sufficently large buffer for output. */
|
||||
while (1) {
|
||||
va_list apc;
|
||||
/*@-sysunrecog@*/ __va_copy(apc, ap); /*@=sysunrecog@*/
|
||||
/*@-sysunrecog -usedef@*/ __va_copy(apc, ap); /*@=sysunrecog =usedef@*/
|
||||
/*@-unrecog@*/ nb = vsnprintf(msgbuf, msgnb, fmt, apc); /*@=unrecog@*/
|
||||
if (nb > -1 && nb < msgnb)
|
||||
break;
|
||||
|
@ -146,14 +150,13 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
|
|||
recs = xmalloc((nrecs+2) * sizeof(*recs));
|
||||
else
|
||||
recs = xrealloc(recs, (nrecs+2) * sizeof(*recs));
|
||||
recs[nrecs].code = code;
|
||||
recs[nrecs].message = msg = msgbuf;
|
||||
msgbuf = NULL;
|
||||
recs[nrecs+1].code = 0;
|
||||
recs[nrecs+1].message = NULL;
|
||||
rec = recs + nrecs;
|
||||
++nrecs;
|
||||
|
||||
rec->code = code;
|
||||
rec->message = msgbuf;
|
||||
freeMsgbuf = 0;
|
||||
|
||||
if (_rpmlogCallback) {
|
||||
_rpmlogCallback();
|
||||
|
@ -183,8 +186,7 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
|
|||
|
||||
(void) fputs(msg, msgout);
|
||||
(void) fflush(msgout);
|
||||
if (freeMsgbuf)
|
||||
free(msgbuf);
|
||||
msgbuf = _free(msgbuf);
|
||||
if (pri <= RPMLOG_CRIT)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ typedef void (*rpmlogCallback) (void);
|
|||
*/
|
||||
typedef /*@abstract@*/ struct rpmlogRec_s {
|
||||
int code;
|
||||
const char * message;
|
||||
/*@owned@*/ /*@null@*/ const char * message;
|
||||
} * rpmlogRec;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -171,7 +171,7 @@ int rpmlogGetNrecs(void);
|
|||
* Return text of last rpmError() message.
|
||||
* @return text of last message
|
||||
*/
|
||||
/*@observer@*/ const char * rpmlogMessage(void);
|
||||
/*@observer@*/ /*@null@*/ const char * rpmlogMessage(void);
|
||||
|
||||
/**
|
||||
* Return error code from last rpmError() message.
|
||||
|
@ -219,21 +219,21 @@ rpmlogCallback rpmlogSetCallback(rpmlogCallback cb);
|
|||
* Set rpmlog callback function.
|
||||
* @deprecated gnorpm needs, use rpmlogSetCallback() instead.
|
||||
*/
|
||||
rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb);
|
||||
extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb);
|
||||
|
||||
/**
|
||||
* Return error code from last rpmError() message.
|
||||
* @deprecated Perl-RPM needs, use rpmlogCode() instead.
|
||||
* @return code from last message
|
||||
*/
|
||||
int rpmErrorCode(void);
|
||||
extern int rpmErrorCode(void);
|
||||
|
||||
/**
|
||||
* Return text of last rpmError() message.
|
||||
* @deprecated gnorpm needs, use rpmlogMessage() instead.
|
||||
* @return text of last message
|
||||
*/
|
||||
/*@observer@*/ const char * rpmErrorString(void);
|
||||
/*@observer@*/ /*@null@*/ extern const char * rpmErrorString(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -6,21 +6,21 @@
|
|||
*/
|
||||
|
||||
/*! The structure used to store a macro. */
|
||||
typedef /*@abstract@*/ struct MacroEntry {
|
||||
struct MacroEntry *prev;/*!< Macro entry stack. */
|
||||
typedef /*@abstract@*/ struct MacroEntry_s {
|
||||
struct MacroEntry_s *prev;/*!< Macro entry stack. */
|
||||
const char *name; /*!< Macro name. */
|
||||
const char *opts; /*!< Macro parameters (a la getopt) */
|
||||
const char *body; /*!< Macro body. */
|
||||
int used; /*!< No. of expansions. */
|
||||
int level; /*!< Scoping level. */
|
||||
} MacroEntry;
|
||||
} * MacroEntry;
|
||||
|
||||
/*! The structure used to store the set of macros in a context. */
|
||||
typedef /*@abstract@*/ struct MacroContext {
|
||||
MacroEntry **macroTable; /*!< Macro entry table for context. */
|
||||
typedef /*@abstract@*/ struct MacroContext_s {
|
||||
/*@owned@*//*@null@*/ MacroEntry *macroTable; /*!< Macro entry table for context. */
|
||||
int macrosAllocated;/*!< No. of allocated macros. */
|
||||
int firstFree; /*!< No. of macros. */
|
||||
} MacroContext;
|
||||
} * MacroContext;
|
||||
|
||||
/**
|
||||
* Markers for sources of macros added throughout rpm.
|
||||
|
@ -42,9 +42,11 @@ extern "C" {
|
|||
/**
|
||||
* Print macros to file stream.
|
||||
* @param mc macro context (NULL uses global context).
|
||||
* @param fp file stream
|
||||
* @param fp file stream (NULL uses stderr).
|
||||
*/
|
||||
void rpmDumpMacroTable (MacroContext * mc, FILE * fp);
|
||||
void rpmDumpMacroTable (/*@null@*/ MacroContext mc,
|
||||
/*@null@*/ FILE * fp)
|
||||
/*@modifies *fp, fileSystem @*/;
|
||||
|
||||
/**
|
||||
* Expand macro into buffer.
|
||||
|
@ -56,8 +58,10 @@ void rpmDumpMacroTable (MacroContext * mc, FILE * fp);
|
|||
* @param sbuflen size of buffer
|
||||
* @return 0 on success
|
||||
*/
|
||||
int expandMacros (void * spec, MacroContext * mc, char * sbuf,
|
||||
size_t sbuflen);
|
||||
int expandMacros (/*@null@*/ void * spec, /*@null@*/ MacroContext mc,
|
||||
/*@in@*/ /*@out@*/ char * sbuf,
|
||||
size_t sbuflen)
|
||||
/*@modifies *sbuf, internalState @*/;
|
||||
|
||||
/**
|
||||
* Add macro to context.
|
||||
|
@ -68,15 +72,18 @@ int expandMacros (void * spec, MacroContext * mc, char * sbuf,
|
|||
* @param b macro body
|
||||
* @param level macro recursion level (0 is entry API)
|
||||
*/
|
||||
void addMacro (MacroContext * mc, const char * n, const char * o,
|
||||
const char * b, int level);
|
||||
void addMacro (/*@null@*/ MacroContext mc, const char * n,
|
||||
/*@null@*/ const char * o,
|
||||
/*@null@*/ const char * b, int level)
|
||||
/*@modifies mc, internalState @*/;
|
||||
|
||||
/**
|
||||
* Delete macro from context.
|
||||
* @param mc macro context (NULL uses global context).
|
||||
* @param n macro name
|
||||
*/
|
||||
void delMacro (MacroContext * mc, const char * n);
|
||||
void delMacro (/*@null@*/ MacroContext mc, const char * n)
|
||||
/*@modifies mc, internalState @*/;
|
||||
|
||||
/**
|
||||
* Define macro in context.
|
||||
|
@ -85,27 +92,32 @@ void delMacro (MacroContext * mc, const char * n);
|
|||
* @param level macro recursion level (0 is entry API)
|
||||
* @return @todo Document.
|
||||
*/
|
||||
int rpmDefineMacro (MacroContext * mc, const char * macro, int level);
|
||||
int rpmDefineMacro (/*@null@*/ MacroContext mc, const char * macro,
|
||||
int level)
|
||||
/*@modifies mc, internalState @*/;
|
||||
|
||||
/**
|
||||
* Load macros from context into global context.
|
||||
* @param mc macro context (NULL does nothing).
|
||||
* @param level macro recursion level (0 is entry API)
|
||||
*/
|
||||
void rpmLoadMacros (MacroContext *mc, int level);
|
||||
void rpmLoadMacros (/*@null@*/ MacroContext mc, int level)
|
||||
/*@modifies mc, internalState @*/;
|
||||
|
||||
/**
|
||||
* Initialize macro context from set of macrofile(s).
|
||||
* @param mc macro context (NULL uses global context).
|
||||
* @param macrofiles colon separated list of macro files (NULL does nothing)
|
||||
*/
|
||||
void rpmInitMacros (MacroContext * mc, const char * macrofiles);
|
||||
void rpmInitMacros (/*@null@*/ MacroContext mc, const char * macrofiles)
|
||||
/*@modifies mc, internalState, fileSystem @*/;
|
||||
|
||||
/**
|
||||
* Destroy macro context.
|
||||
* @param mc macro context (NULL uses global context).
|
||||
*/
|
||||
void rpmFreeMacros (MacroContext * mc);
|
||||
void rpmFreeMacros (/*@null@*/ MacroContext mc)
|
||||
/*@modifies mc, internalState @*/;
|
||||
|
||||
typedef enum rpmCompressedMagic_e {
|
||||
COMPRESSED_NOT = 0, /*!< not compressed */
|
||||
|
@ -120,28 +132,33 @@ typedef enum rpmCompressedMagic_e {
|
|||
* @retval compressed address of compression type
|
||||
* @return 0 on success, 1 on I/O error
|
||||
*/
|
||||
int isCompressed (const char * file, rpmCompressedMagic * compressed);
|
||||
int isCompressed (const char * file,
|
||||
/*@out@*/ rpmCompressedMagic * compressed)
|
||||
/*@modifies *compressed, fileSystem @*/;
|
||||
|
||||
/**
|
||||
* Return (malloc'ed) concatenated macro expansion(s).
|
||||
* @param arg macro(s) to expand (NULL terminates list)
|
||||
* @return macro expansion (malloc'ed)
|
||||
*/
|
||||
char * rpmExpand (const char * arg, ...);
|
||||
char * rpmExpand (/*@null@*/ const char * arg, ...)
|
||||
/*@*/;
|
||||
|
||||
/**
|
||||
* Canonicalize file path.
|
||||
* @param path path to canonicalize (in-place)
|
||||
* @return canonicalized path (malloc'ed)
|
||||
*/
|
||||
char * rpmCleanPath (char * path);
|
||||
/*@null@*/ char * rpmCleanPath (/*@null@*/ char * path)
|
||||
/*@modifies *path @*/;
|
||||
|
||||
/**
|
||||
* Return (malloc'ed) expanded, canonicalized, file path.
|
||||
* @param path macro(s) to expand (NULL terminates list)
|
||||
* @return canonicalized path (malloc'ed)
|
||||
*/
|
||||
const char *rpmGetPath (const char * path, ...);
|
||||
const char *rpmGetPath (/*@null@*/ const char * path, ...)
|
||||
/*@*/;
|
||||
|
||||
/**
|
||||
* Merge 3 args into path, any or all of which may be a url.
|
||||
|
@ -153,8 +170,10 @@ const char *rpmGetPath (const char * path, ...);
|
|||
* @param file file URL (often a file, or NULL)
|
||||
* @return expanded, merged, canonicalized path (malloc'ed)
|
||||
*/
|
||||
const char *rpmGenPath (const char * root, const char * mdir,
|
||||
const char * file);
|
||||
const char *rpmGenPath (/*@null@*/ const char * root,
|
||||
/*@null@*/ const char * mdir,
|
||||
/*@null@*/ const char * file)
|
||||
/*@*/;
|
||||
|
||||
/**
|
||||
* Return macro expansion as a numeric value.
|
||||
|
@ -163,7 +182,8 @@ const char *rpmGenPath (const char * root, const char * mdir,
|
|||
* @param arg macro to expand
|
||||
* @return numeric value
|
||||
*/
|
||||
int rpmExpandNumeric (const char * arg);
|
||||
int rpmExpandNumeric (const char * arg)
|
||||
/*@*/;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -56,12 +56,14 @@ extern "C" {
|
|||
|
||||
/**
|
||||
*/
|
||||
typedef void * (*rpmCallbackFunction)(const void * h,
|
||||
typedef /*@only@*/ /*@null@*/
|
||||
void * (*rpmCallbackFunction)
|
||||
(/*@null@*/ const void * h,
|
||||
const rpmCallbackType what,
|
||||
const unsigned long amount,
|
||||
const unsigned long total,
|
||||
const void * pkgKey,
|
||||
rpmCallbackData data);
|
||||
/*@null@*/ const void * pkgKey,
|
||||
/*@null@*/ rpmCallbackData data);
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
|
@ -274,22 +274,22 @@ is_num (int idx)
|
|||
}
|
||||
|
||||
static int
|
||||
is_dos_date(char *str)
|
||||
is_dos_date(/*@null@*/ const char *str)
|
||||
{
|
||||
if (strlen(str) == 8 && str[2] == str[5] && strchr("\\-/", (int)str[2]) != NULL)
|
||||
if (str != NULL && strlen(str) == 8 &&
|
||||
str[2] == str[5] && strchr("\\-/", (int)str[2]) != NULL)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
is_week (const char * str, /*@out@*/ struct tm * tim)
|
||||
is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
||||
{
|
||||
/*@observer@*/ static const char * week = "SunMonTueWedThuFriSat";
|
||||
const char * pos;
|
||||
|
||||
/*@-observertrans -mayaliasunique@*/
|
||||
if ((pos=strstr(week, str)) != NULL) {
|
||||
if (str != NULL && (pos=strstr(week, str)) != NULL) {
|
||||
/*@=observertrans =mayaliasunique@*/
|
||||
if (tim != NULL)
|
||||
tim->tm_wday = (pos - week)/3;
|
||||
|
@ -299,13 +299,13 @@ is_week (const char * str, /*@out@*/ struct tm * tim)
|
|||
}
|
||||
|
||||
static int
|
||||
is_month (const char * str, /*@out@*/ struct tm * tim)
|
||||
is_month (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
||||
{
|
||||
/*@observer@*/ static const char * month = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
const char * pos;
|
||||
|
||||
/*@-observertrans -mayaliasunique@*/
|
||||
if ((pos=strstr(month, str)) != NULL) {
|
||||
if (str != NULL && (pos = strstr(month, str)) != NULL) {
|
||||
/*@=observertrans -mayaliasunique@*/
|
||||
if (tim != NULL)
|
||||
tim->tm_mon = (pos - month)/3;
|
||||
|
@ -315,34 +315,35 @@ is_month (const char * str, /*@out@*/ struct tm * tim)
|
|||
}
|
||||
|
||||
static int
|
||||
is_time (const char * str, /*@out@*/ struct tm * tim)
|
||||
is_time (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
||||
{
|
||||
const char * p, * p2;
|
||||
|
||||
if ((p=strchr(str, ':')) && (p2=strrchr(str, ':'))) {
|
||||
if (str != NULL && (p = strchr(str, ':')) && (p2 = strrchr(str, ':'))) {
|
||||
if (p != p2) {
|
||||
if (sscanf (str, "%2d:%2d:%2d", &tim->tm_hour, &tim->tm_min, &tim->tm_sec) != 3)
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (sscanf (str, "%2d:%2d", &tim->tm_hour, &tim->tm_min) != 2)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int is_year(const char * str, /*@out@*/ struct tm * tim)
|
||||
static int is_year(/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
||||
{
|
||||
long year;
|
||||
|
||||
if (str == NULL)
|
||||
return 0;
|
||||
|
||||
if (strchr(str,':'))
|
||||
return 0;
|
||||
|
||||
if (strlen(str)!=4)
|
||||
if (strlen(str) != 4)
|
||||
return 0;
|
||||
|
||||
if (sscanf(str, "%ld", &year) != 1)
|
||||
|
@ -816,6 +817,11 @@ static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if (bn == NULL || nbn <= 0) {
|
||||
rc = -2;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (ftpBufAlloced == 0 || ftpBuf == NULL) {
|
||||
ftpBufAlloced = url_iobuf_size;
|
||||
ftpBuf = xcalloc(ftpBufAlloced, sizeof(ftpBuf[0]));
|
||||
|
|
|
@ -26,21 +26,21 @@ typedef enum {
|
|||
*/
|
||||
typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo {
|
||||
/*@refs@*/ int nrefs; /*!< no. of references */
|
||||
const char * url; /*!< copy of original url */
|
||||
const char * service;
|
||||
const char * user;
|
||||
const char * password;
|
||||
const char * host;
|
||||
const char * portstr;
|
||||
const char * proxyu; /*!< FTP: proxy user */
|
||||
const char * proxyh; /*!< FTP/HTTP: proxy host */
|
||||
/*@owned@*//*@null@*/ const char * url; /*!< copy of original url */
|
||||
/*@owned@*//*@null@*/ const char * service;
|
||||
/*@owned@*//*@null@*/ const char * user;
|
||||
/*@owned@*//*@null@*/ const char * password;
|
||||
/*@owned@*//*@null@*/ const char * host;
|
||||
/*@owned@*//*@null@*/ const char * portstr;
|
||||
/*@owned@*//*@null@*/ const char * proxyu; /*!< FTP: proxy user */
|
||||
/*@owned@*//*@null@*/ const char * proxyh; /*!< FTP/HTTP: proxy host */
|
||||
int proxyp; /*!< FTP/HTTP: proxy port */
|
||||
int port;
|
||||
int urltype;
|
||||
FD_t ctrl; /*!< control channel */
|
||||
FD_t data; /*!< per-xfer data channel */
|
||||
int bufAlloced; /*!< sizeof I/O buffer */
|
||||
char *buf; /*!< I/O buffer */
|
||||
/*@owned@*/ char *buf; /*!< I/O buffer */
|
||||
int openError; /*!< Type of open failure */
|
||||
int httpVersion;
|
||||
int httpHasRange;
|
||||
|
@ -118,7 +118,7 @@ int urlSplit(const char * url, /*@out@*/ urlinfo * u)
|
|||
* @param dest file name of destination
|
||||
* @return 0 on success, otherwise FTPERR_* code
|
||||
*/
|
||||
int urlGetFile(const char * url, const char * dest);
|
||||
int urlGetFile(const char * url, /*@null@*/ const char * dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
103
rpmio/url.c
103
rpmio/url.c
|
@ -39,6 +39,16 @@ int _url_debug = 0;
|
|||
/*@only@*/ /*@null@*/ static urlinfo *uCache = NULL;
|
||||
static int uCount = 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;
|
||||
}
|
||||
|
||||
urlinfo XurlLink(urlinfo u, const char *msg, const char *file, unsigned line)
|
||||
{
|
||||
URLSANE(u);
|
||||
|
@ -89,7 +99,8 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file,
|
|||
/*@-usereleased@*/
|
||||
if (u->ctrl)
|
||||
fprintf(stderr, _("warning: u %p ctrl %p nrefs != 0 (%s %s)\n"),
|
||||
u, u->ctrl, u->host, u->service);
|
||||
u, u->ctrl, (u->host ? u->host : ""),
|
||||
(u->service ? u->service : ""));
|
||||
/*@=usereleased@*/
|
||||
}
|
||||
if (u->data) {
|
||||
|
@ -108,53 +119,55 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file,
|
|||
/*@-usereleased@*/
|
||||
if (u->data)
|
||||
fprintf(stderr, _("warning: u %p data %p nrefs != 0 (%s %s)\n"),
|
||||
u, u->data, u->host, u->service);
|
||||
u, u->data, (u->host ? u->host : ""),
|
||||
(u->service ? u->service : ""));
|
||||
/*@=usereleased@*/
|
||||
}
|
||||
if (u->buf) {
|
||||
free(u->buf);
|
||||
u->buf = NULL;
|
||||
}
|
||||
if (u->url) free((void *)u->url);
|
||||
if (u->service) free((void *)u->service);
|
||||
if (u->user) free((void *)u->user);
|
||||
if (u->password) free((void *)u->password);
|
||||
if (u->host) free((void *)u->host);
|
||||
if (u->portstr) free((void *)u->portstr);
|
||||
if (u->proxyu) free((void *)u->proxyu);
|
||||
if (u->proxyh) free((void *)u->proxyh);
|
||||
u->buf = _free(u->buf);
|
||||
u->url = _free(u->url);
|
||||
u->service = _free((void *)u->service);
|
||||
u->user = _free((void *)u->user);
|
||||
u->password = _free((void *)u->password);
|
||||
u->host = _free((void *)u->host);
|
||||
u->portstr = _free((void *)u->portstr);
|
||||
u->proxyu = _free((void *)u->proxyu);
|
||||
u->proxyh = _free((void *)u->proxyh);
|
||||
|
||||
/*@-refcounttrans@*/ free((void *)u); /*@-refcounttrans@*/
|
||||
/*@-refcounttrans@*/ u = _free(u); /*@-refcounttrans@*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void urlFreeCache(void)
|
||||
{
|
||||
if (uCache) {
|
||||
int i;
|
||||
for (i = 0; i < uCount; i++) {
|
||||
if (uCache[i] == NULL) continue;
|
||||
uCache[i] = urlFree(uCache[i], "uCache");
|
||||
if (uCache[i])
|
||||
fprintf(stderr, _("warning: uCache[%d] %p nrefs(%d) != 1 (%s %s)\n"),
|
||||
fprintf(stderr,
|
||||
_("warning: uCache[%d] %p nrefs(%d) != 1 (%s %s)\n"),
|
||||
i, uCache[i], uCache[i]->nrefs,
|
||||
uCache[i]->host, uCache[i]->service);
|
||||
(uCache[i]->host ? uCache[i]->host : ""),
|
||||
(uCache[i]->service ? uCache[i]->service : ""));
|
||||
}
|
||||
if (uCache)
|
||||
free(uCache);
|
||||
uCache = NULL;
|
||||
}
|
||||
uCache = _free(uCache);
|
||||
uCount = 0;
|
||||
}
|
||||
|
||||
static int urlStrcmp(const char *str1, const char *str2)
|
||||
static int urlStrcmp(/*@null@*/ const char * str1, /*@null@*/ const char * str2)
|
||||
{
|
||||
if (str1 && str2)
|
||||
return (strcmp(str1, str2));
|
||||
/*@-nullpass@*/ /* LCL: 2nd arg claims to be NULL */
|
||||
return strcmp(str1, str2);
|
||||
/*@=nullpass@*/
|
||||
if (str1 != str2)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void urlFind(urlinfo *uret, int mustAsk)
|
||||
static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo *uret, int mustAsk)
|
||||
{
|
||||
urlinfo u;
|
||||
int ucx;
|
||||
|
@ -163,6 +176,11 @@ static void urlFind(urlinfo *uret, int mustAsk)
|
|||
if (uret == NULL)
|
||||
return;
|
||||
|
||||
if (uCache == NULL) {
|
||||
*uret = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
u = *uret;
|
||||
URLSANE(u);
|
||||
|
||||
|
@ -215,19 +233,18 @@ static void urlFind(urlinfo *uret, int mustAsk)
|
|||
|
||||
/* Zap proxy host and port in case they have been reset */
|
||||
u->proxyp = -1;
|
||||
if (u->proxyh) {
|
||||
free((void *)u->proxyh);
|
||||
u->proxyh = NULL;
|
||||
}
|
||||
u->proxyh = _free(u->proxyh);
|
||||
|
||||
/* Perform one-time FTP initialization */
|
||||
if (u->urltype == URL_IS_FTP) {
|
||||
|
||||
if (mustAsk || (u->user != NULL && u->password == NULL)) {
|
||||
/*@observer@*/ const char * host = (u->host ? u->host : "");
|
||||
/*@observer@*/ const char * user = (u->user ? u->user : "");
|
||||
char * prompt;
|
||||
prompt = alloca(strlen(u->host) + strlen(u->user) + 256);
|
||||
sprintf(prompt, _("Password for %s@%s: "), u->user, u->host);
|
||||
if (u->password) free((void *)u->password);
|
||||
prompt = alloca(strlen(host) + strlen(user) + 256);
|
||||
sprintf(prompt, _("Password for %s@%s: "), user, host);
|
||||
u->password = _free(u->password);
|
||||
u->password = /*@-unrecog@*/ getpass(prompt) /*@=unrecog@*/;
|
||||
u->password = xstrdup(u->password); /* XXX xstrdup has side effects. */
|
||||
}
|
||||
|
@ -235,13 +252,14 @@ static void urlFind(urlinfo *uret, int mustAsk)
|
|||
if (u->proxyh == NULL) {
|
||||
const char *proxy = rpmExpand("%{_ftpproxy}", NULL);
|
||||
if (proxy && *proxy != '%') {
|
||||
/*@observer@*/ const char * host = (u->host ? u->host : "");
|
||||
const char *uu = (u->user ? u->user : "anonymous");
|
||||
char *nu = xmalloc(strlen(uu) + sizeof("@") + strlen(u->host));
|
||||
(void) stpcpy( stpcpy( stpcpy(nu, uu), "@"), u->host);
|
||||
char *nu = xmalloc(strlen(uu) + sizeof("@") + strlen(host));
|
||||
(void) stpcpy( stpcpy( stpcpy(nu, uu), "@"), host);
|
||||
u->proxyu = nu;
|
||||
u->proxyh = xstrdup(proxy);
|
||||
}
|
||||
free((void *)proxy);
|
||||
proxy = _free(proxy);
|
||||
}
|
||||
|
||||
if (u->proxyp < 0) {
|
||||
|
@ -251,12 +269,12 @@ static void urlFind(urlinfo *uret, int mustAsk)
|
|||
int port = strtol(proxy, &end, 0);
|
||||
if (!(end && *end == '\0')) {
|
||||
fprintf(stderr, _("error: %sport must be a number\n"),
|
||||
u->service);
|
||||
(u->service ? u->service : ""));
|
||||
return;
|
||||
}
|
||||
u->proxyp = port;
|
||||
}
|
||||
free((void *)proxy);
|
||||
proxy = _free(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +285,7 @@ static void urlFind(urlinfo *uret, int mustAsk)
|
|||
const char *proxy = rpmExpand("%{_httpproxy}", NULL);
|
||||
if (proxy && *proxy != '%')
|
||||
u->proxyh = xstrdup(proxy);
|
||||
free((void *)proxy);
|
||||
proxy = _free(proxy);
|
||||
}
|
||||
|
||||
if (u->proxyp < 0) {
|
||||
|
@ -277,12 +295,12 @@ static void urlFind(urlinfo *uret, int mustAsk)
|
|||
int port = strtol(proxy, &end, 0);
|
||||
if (!(end && *end == '\0')) {
|
||||
fprintf(stderr, _("error: %sport must be a number\n"),
|
||||
u->service);
|
||||
(u->service ? u->service : ""));
|
||||
return;
|
||||
}
|
||||
u->proxyp = port;
|
||||
}
|
||||
free((void *)proxy);
|
||||
proxy = _free(proxy);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -415,7 +433,7 @@ int urlSplit(const char * url, urlinfo *uret)
|
|||
u->port = strtol(u->portstr, &end, 0);
|
||||
if (!(end && *end == '\0')) {
|
||||
rpmMessage(RPMMESS_ERROR, _("url port must be a number\n"));
|
||||
if (myurl) free(myurl);
|
||||
myurl = _free(myurl);
|
||||
u = urlFree(u, "urlSplit (error #3)");
|
||||
return -1;
|
||||
}
|
||||
|
@ -434,7 +452,7 @@ int urlSplit(const char * url, urlinfo *uret)
|
|||
u->port = IPPORT_HTTP;
|
||||
}
|
||||
|
||||
if (myurl) free(myurl);
|
||||
myurl = _free(myurl);
|
||||
if (uret) {
|
||||
*uret = u;
|
||||
urlFind(uret, 0);
|
||||
|
@ -466,9 +484,12 @@ int urlGetFile(const char * url, const char * dest) {
|
|||
dest = sfuPath;
|
||||
}
|
||||
|
||||
if (dest == NULL)
|
||||
return FTPERR_UNKNOWN;
|
||||
|
||||
tfd = Fopen(dest, "w.ufdio");
|
||||
if (_url_debug)
|
||||
fprintf(stderr, "*** urlGetFile sfd %p %s tfd %p %s\n", sfd, url, tfd, dest);
|
||||
fprintf(stderr, "*** urlGetFile sfd %p %s tfd %p %s\n", sfd, url, (tfd ? tfd : NULL), dest);
|
||||
if (tfd == NULL || Ferror(tfd)) {
|
||||
/* XXX Fstrerror */
|
||||
rpmMessage(RPMMESS_DEBUG, _("failed to create %s: %s\n"), dest, Fstrerror(tfd));
|
||||
|
|
72
rpmqv.c
72
rpmqv.c
|
@ -29,7 +29,7 @@ static int initdb = 0;
|
|||
#define GETOPT_RELOCATE 1016
|
||||
#define GETOPT_EXCLUDEPATH 1019
|
||||
static int incldocs = 0;
|
||||
static char * prefix = NULL;
|
||||
/*@null@*/ static const char * prefix = NULL;
|
||||
#endif /* IAM_RPMEIU */
|
||||
|
||||
#ifdef IAM_RPMK
|
||||
|
@ -94,16 +94,16 @@ extern const char * rpmNAME;
|
|||
extern const char * rpmEVR;
|
||||
extern int rpmFLAGS;
|
||||
|
||||
extern MacroContext rpmCLIMacroContext;
|
||||
extern struct MacroContext_s rpmCLIMacroContext;
|
||||
|
||||
/* options for all executables */
|
||||
|
||||
static int help = 0;
|
||||
static int noUsageMsg = 0;
|
||||
static char * pipeOutput = NULL;
|
||||
/*@null@*/ static const char * pipeOutput = NULL;
|
||||
static int quiet = 0;
|
||||
static char * rcfile = NULL;
|
||||
static char * rootdir = "/";
|
||||
/*@null@*/ static const char * rcfile = NULL;
|
||||
/*@null@*/ static char * rootdir = "/";
|
||||
static int showrc = 0;
|
||||
static int showVersion = 0;
|
||||
|
||||
|
@ -398,15 +398,15 @@ static void printVersion(void) {
|
|||
}
|
||||
|
||||
static void printBanner(void) {
|
||||
puts(_("Copyright (C) 1998-2000 - Red Hat, Inc."));
|
||||
puts(_("This program may be freely redistributed under the terms of the GNU GPL"));
|
||||
(void) puts(_("Copyright (C) 1998-2000 - Red Hat, Inc."));
|
||||
(void) puts(_("This program may be freely redistributed under the terms of the GNU GPL"));
|
||||
}
|
||||
|
||||
static void printUsage(void) {
|
||||
FILE * fp;
|
||||
printVersion();
|
||||
printBanner();
|
||||
puts("");
|
||||
(void) puts("");
|
||||
|
||||
fp = stdout;
|
||||
|
||||
|
@ -690,11 +690,11 @@ int main(int argc, const char ** argv)
|
|||
enum modes bigMode = MODE_UNKNOWN;
|
||||
|
||||
#ifdef IAM_RPMQV
|
||||
QVA_t *qva = &rpmQVArgs;
|
||||
QVA_t qva = &rpmQVArgs;
|
||||
#endif
|
||||
|
||||
#ifdef IAM_RPMBT
|
||||
struct rpmBuildArguments *ba = &rpmBTArgs;
|
||||
BTA_t ba = &rpmBTArgs;
|
||||
#endif
|
||||
|
||||
#ifdef IAM_RPMEIU
|
||||
|
@ -733,6 +733,7 @@ int main(int argc, const char ** argv)
|
|||
}
|
||||
|
||||
/* Set the major mode based on argv[0] */
|
||||
/*@-nullpass@*/
|
||||
#ifdef IAM_RPMBT
|
||||
if (!strcmp(__progname, "rpmb")) bigMode = MODE_BUILD;
|
||||
if (!strcmp(__progname, "rpmt")) bigMode = MODE_TARBUILD;
|
||||
|
@ -749,6 +750,7 @@ int main(int argc, const char ** argv)
|
|||
if (!strcmp(__progname, "rpmi")) bigMode = MODE_INSTALL;
|
||||
if (!strcmp(__progname, "rpmu")) bigMode = MODE_INSTALL;
|
||||
#endif
|
||||
/*@=nullpass@*/
|
||||
|
||||
/* set the defaults for the various command line options */
|
||||
_ftp_debug = 0;
|
||||
|
@ -779,9 +781,11 @@ int main(int argc, const char ** argv)
|
|||
|
||||
/* Make a first pass through the arguments, looking for --rcfile */
|
||||
/* We need to handle that before dealing with the rest of the arguments. */
|
||||
/*@-nullpass -temptrans@*/
|
||||
optCon = poptGetContext(__progname, argc, argv, optionsTable, 0);
|
||||
poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
|
||||
poptReadDefaultConfig(optCon, 1);
|
||||
/*@=nullpass =temptrans@*/
|
||||
(void) poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
|
||||
(void) poptReadDefaultConfig(optCon, 1);
|
||||
poptSetExecPath(optCon, RPMCONFIGDIR, 1);
|
||||
|
||||
/* reading rcfile early makes it easy to override */
|
||||
|
@ -801,7 +805,7 @@ int main(int argc, const char ** argv)
|
|||
exit(EXIT_FAILURE);
|
||||
|
||||
if (showrc) {
|
||||
rpmShowRC(stdout);
|
||||
(void) rpmShowRC(stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -845,16 +849,20 @@ int main(int argc, const char ** argv)
|
|||
case 'i':
|
||||
#ifdef IAM_RPMQV
|
||||
if (bigMode == MODE_QUERY) {
|
||||
/*@-nullassign@*/
|
||||
const char * infoCommand[] = { "--info", NULL };
|
||||
poptStuffArgs(optCon, infoCommand);
|
||||
/*@=nullassign@*/
|
||||
(void) poptStuffArgs(optCon, infoCommand);
|
||||
}
|
||||
#endif
|
||||
#ifdef IAM_RPMEIU
|
||||
if (bigMode == MODE_INSTALL)
|
||||
/*@-ifempty@*/ ;
|
||||
if (bigMode == MODE_UNKNOWN) {
|
||||
/*@-nullassign@*/
|
||||
const char * installCommand[] = { "--install", NULL };
|
||||
poptStuffArgs(optCon, installCommand);
|
||||
/*@=nullassign@*/
|
||||
(void) poptStuffArgs(optCon, installCommand);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
@ -947,8 +955,8 @@ int main(int argc, const char ** argv)
|
|||
#endif /* IAM_RPMK */
|
||||
|
||||
case GETOPT_DEFINEMACRO:
|
||||
rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
|
||||
rpmDefineMacro(&rpmCLIMacroContext, optArg, RMIL_CMDLINE);
|
||||
(void) rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
|
||||
(void) rpmDefineMacro(&rpmCLIMacroContext, optArg, RMIL_CMDLINE);
|
||||
noUsageMsg = 1;
|
||||
break;
|
||||
|
||||
|
@ -1137,7 +1145,7 @@ int main(int argc, const char ** argv)
|
|||
"erasure, and building"));
|
||||
#endif /* IAM_RPMEIU */
|
||||
|
||||
if (rootdir[1] && (bigMode & ~MODES_FOR_ROOT))
|
||||
if (rootdir && rootdir[1] && (bigMode & ~MODES_FOR_ROOT))
|
||||
argerror(_("--root (-r) may only be specified during "
|
||||
"installation, erasure, querying, and "
|
||||
"database rebuilds"));
|
||||
|
@ -1232,30 +1240,30 @@ int main(int argc, const char ** argv)
|
|||
}
|
||||
} else {
|
||||
/* Make rpmLookupSignatureType() return 0 ("none") from now on */
|
||||
rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
|
||||
(void) rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
|
||||
}
|
||||
#endif /* IAM_RPMBT || IAM_RPMK */
|
||||
|
||||
if (pipeOutput) {
|
||||
pipe(p);
|
||||
(void) pipe(p);
|
||||
|
||||
if (!(pipeChild = fork())) {
|
||||
close(p[1]);
|
||||
dup2(p[0], STDIN_FILENO);
|
||||
close(p[0]);
|
||||
execl("/bin/sh", "/bin/sh", "-c", pipeOutput, NULL);
|
||||
(void) close(p[1]);
|
||||
(void) dup2(p[0], STDIN_FILENO);
|
||||
(void) close(p[0]);
|
||||
(void) execl("/bin/sh", "/bin/sh", "-c", pipeOutput, NULL);
|
||||
fprintf(stderr, _("exec failed\n"));
|
||||
}
|
||||
|
||||
close(p[0]);
|
||||
dup2(p[1], STDOUT_FILENO);
|
||||
close(p[1]);
|
||||
(void) close(p[0]);
|
||||
(void) dup2(p[1], STDOUT_FILENO);
|
||||
(void) close(p[1]);
|
||||
}
|
||||
|
||||
switch (bigMode) {
|
||||
#ifdef IAM_RPMDB
|
||||
case MODE_INITDB:
|
||||
rpmdbInit(rootdir, 0644);
|
||||
(void) rpmdbInit(rootdir, 0644);
|
||||
break;
|
||||
|
||||
case MODE_REBUILDDB:
|
||||
|
@ -1366,7 +1374,7 @@ int main(int argc, const char ** argv)
|
|||
if (ec)
|
||||
break;
|
||||
rpmFreeMacros(NULL);
|
||||
rpmReadConfigFiles(rcfile, NULL);
|
||||
(void) rpmReadConfigFiles(rcfile, NULL);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -1566,8 +1574,8 @@ exit:
|
|||
rpmFreeRpmrc();
|
||||
|
||||
if (pipeChild) {
|
||||
fclose(stdout);
|
||||
(void)waitpid(pipeChild, &status, 0);
|
||||
(void) fclose(stdout);
|
||||
(void) waitpid(pipeChild, &status, 0);
|
||||
}
|
||||
|
||||
/* keeps memory leak checkers quiet */
|
||||
|
@ -1587,5 +1595,7 @@ exit:
|
|||
#if HAVE_MCHECK_H && HAVE_MTRACE
|
||||
muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
|
||||
#endif
|
||||
/*@-globstate@*/
|
||||
return ec;
|
||||
/*@=globstate@*/
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue