lclint annotations.
CVS patchset: 4821 CVS date: 2001/05/31 19:02:55
This commit is contained in:
parent
cc54f00167
commit
f8b347a38a
|
@ -0,0 +1,36 @@
|
|||
-I. -I.. -I../lib -I../rpmdb -I../rpmio -I../popt -DHAVE_CONFIG_H -D_GNU_SOURCE
|
||||
|
||||
+partial
|
||||
|
||||
-warnunixlib
|
||||
-warnposix
|
||||
|
||||
+unixlib
|
||||
|
||||
# XXX ignore doxygen markings
|
||||
-unrecogcomments
|
||||
|
||||
# don't-bother-me-yet parameters
|
||||
-branchstate # ~39
|
||||
-mustfree # ~325
|
||||
|
||||
# not-yet normal parameters
|
||||
-boolops # ~351 w->n
|
||||
-predboolint # ~200 w->n
|
||||
-type # ~271
|
||||
|
||||
# -weak paramaters
|
||||
#+boolint
|
||||
#-boolops
|
||||
#+ignorequals
|
||||
#+ignoresigns
|
||||
#-mustfree
|
||||
#+longintegral
|
||||
#+matchanyintegral
|
||||
#-nullpass
|
||||
#-observertrans
|
||||
#-predboolint
|
||||
#-predboolothers
|
||||
#-retvalint
|
||||
#-retvalother
|
||||
#-shiftsigned
|
|
@ -30,3 +30,7 @@ librpmmodule_la_SOURCES = rpmmodule.c hash.c upgrade.c
|
|||
|
||||
rpmmodule.so: $(librpmmodule_la_OBJECTS)
|
||||
$(LINK) -o $@ $^ $(rpmmodule_so_LDFLAGS)
|
||||
|
||||
.PHONY: lclint
|
||||
lclint:
|
||||
lclint $(DEFS) $(INCLUDES) $(librpmmodule_la_SOURCES)
|
||||
|
|
|
@ -474,6 +474,10 @@ mostlyclean distclean maintainer-clean
|
|||
rpmmodule.so: $(librpmmodule_la_OBJECTS)
|
||||
$(LINK) -o $@ $^ $(rpmmodule_so_LDFLAGS)
|
||||
|
||||
.PHONY: lclint
|
||||
lclint:
|
||||
lclint $(DEFS) $(INCLUDES) $(librpmmodule_la_SOURCES)
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
|
|
@ -68,7 +68,7 @@ void htFreeHashTable(struct hash_table *ht)
|
|||
free(ht);
|
||||
}
|
||||
|
||||
void htHashStats(struct hash_table *t)
|
||||
void htHashStats(const struct hash_table *t)
|
||||
{
|
||||
int i = 0;
|
||||
int empty = 0;
|
||||
|
@ -89,13 +89,13 @@ void htHashStats(struct hash_table *t)
|
|||
printf("Avergage Depth: %f\n", (double)t->entries / (double)t->size);
|
||||
}
|
||||
|
||||
static unsigned int htHashStrings(const char *s, const char *t)
|
||||
static unsigned int htHashStrings(const char * s, const char * t)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
|
||||
while (*s)
|
||||
while (*s != '\0')
|
||||
res = ((res<<1) + (int)(*(s++)));
|
||||
while (*t)
|
||||
while (*t != '\0')
|
||||
res = ((res<<1) + (int)(*(t++)));
|
||||
|
||||
return res;
|
||||
|
|
|
@ -15,9 +15,9 @@ struct ht_iterator {
|
|||
|
||||
typedef struct ht_iterator htIterator;
|
||||
|
||||
struct hash_table *htNewTable(int size);
|
||||
void htFreeHashTable(struct hash_table *ht);
|
||||
void htHashStats(struct hash_table *t);
|
||||
/*@only@*/ /*@null@*/ struct hash_table * htNewTable(int size);
|
||||
void htFreeHashTable(/*@only@*/ struct hash_table *ht);
|
||||
void htHashStats(const struct hash_table *t);
|
||||
int htInTable(struct hash_table *t, const char * dir, const char * base);
|
||||
void htAddToTable(struct hash_table *t, const char * dir, const char * base);
|
||||
void htPrintHashStats(struct hash_table *t);
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
|
||||
extern int _rpmio_debug;
|
||||
|
||||
#ifdef __LCLINT__
|
||||
#undef PyObject_HEAD
|
||||
#defin PyObject_HEAD int _PyObjectHead
|
||||
#endif
|
||||
|
||||
extern int mdfile(const char *fn, unsigned char *digest);
|
||||
|
||||
void initrpm(void);
|
||||
|
@ -1267,7 +1272,7 @@ static PyObject * rpmtransRemove(rpmtransObject * s, PyObject * args) {
|
|||
/** \ingroup python
|
||||
*/
|
||||
static PyObject * rpmtransDepCheck(rpmtransObject * s, PyObject * args) {
|
||||
struct rpmDependencyConflict * conflicts;
|
||||
struct rpmDependencyConflict_s * conflicts;
|
||||
int numConflicts;
|
||||
PyObject * list, * cf;
|
||||
int i;
|
||||
|
@ -1278,6 +1283,7 @@ static PyObject * rpmtransDepCheck(rpmtransObject * s, PyObject * args) {
|
|||
if (numConflicts) {
|
||||
list = PyList_New(0);
|
||||
|
||||
/* XXX TODO: rpmlib-4.0.3 can return multiple suggested packages. */
|
||||
for (i = 0; i < numConflicts; i++) {
|
||||
cf = Py_BuildValue("((sss)(ss)iOi)", conflicts[i].byName,
|
||||
conflicts[i].byVersion, conflicts[i].byRelease,
|
||||
|
@ -1286,14 +1292,14 @@ static PyObject * rpmtransDepCheck(rpmtransObject * s, PyObject * args) {
|
|||
conflicts[i].needsVersion,
|
||||
|
||||
conflicts[i].needsFlags,
|
||||
conflicts[i].suggestedPackage ?
|
||||
conflicts[i].suggestedPackage : Py_None,
|
||||
conflicts[i].suggestedPackages ?
|
||||
conflicts[i].suggestedPackages[0] : Py_None,
|
||||
conflicts[i].sense);
|
||||
PyList_Append(list, (PyObject *) cf);
|
||||
Py_DECREF(cf);
|
||||
}
|
||||
|
||||
rpmdepFreeConflicts(conflicts, numConflicts);
|
||||
conflicts = rpmdepFreeConflicts(conflicts, numConflicts);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
129
python/upgrade.c
129
python/upgrade.c
|
@ -35,6 +35,9 @@ static void printMemStats(char *mess)
|
|||
}
|
||||
#endif
|
||||
|
||||
/*@access Header@*/ /* compared with NULL. */
|
||||
/*@access rpmdbMatchIterator@*/ /* compared with NULL. */
|
||||
|
||||
int pkgCompare(void * first, void * second); /* XXX make gcc shut up. */
|
||||
int pkgCompare(void * first, void * second) {
|
||||
struct packageInfo ** a = first;
|
||||
|
@ -50,9 +53,9 @@ int pkgCompare(void * first, void * second) {
|
|||
|
||||
/* Adds all files in the second file list which are not in the first
|
||||
file list to the hash table. */
|
||||
static void compareFileList(int availFileCount, char **availBaseNames,
|
||||
static void compareFileList(int availFileCount, char ** availBaseNames,
|
||||
char ** availDirNames, int * availDirIndexes,
|
||||
int instFileCount, char **instBaseNames,
|
||||
int instFileCount, char ** instBaseNames,
|
||||
char ** instDirNames, int * instDirIndexes,
|
||||
struct hash_table *ht)
|
||||
{
|
||||
|
@ -115,7 +118,7 @@ static void addLostFiles(rpmdb db, struct pkgSet *psp, struct hash_table *ht)
|
|||
mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
|
||||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
|
||||
headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
(void) headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
if (name && !strcmp(name, "metroess")) {
|
||||
/* metro was removed from 5.1, but leave it if it's already
|
||||
installed */
|
||||
|
@ -127,11 +130,12 @@ static void addLostFiles(rpmdb db, struct pkgSet *psp, struct hash_table *ht)
|
|||
sizeof(*psp->packages), (void *)pkgCompare);
|
||||
if (!pack) {
|
||||
if (headerGetEntryMinMemory(h, RPMTAG_BASENAMES, NULL,
|
||||
(const void **) &installedFiles, &installedFileCount)) {
|
||||
headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
|
||||
(const void **) &installedDirIndexes, NULL);
|
||||
headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
|
||||
(const void **) &installedDirs, NULL);
|
||||
(const void **) &installedFiles, &installedFileCount)
|
||||
&& headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
|
||||
(const void **) &installedDirIndexes, NULL)
|
||||
&& headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
|
||||
(const void **) &installedDirs, NULL))
|
||||
{
|
||||
|
||||
compareFileList(0, NULL, NULL, NULL, installedFileCount,
|
||||
installedFiles, installedDirs,
|
||||
|
@ -143,7 +147,7 @@ static void addLostFiles(rpmdb db, struct pkgSet *psp, struct hash_table *ht)
|
|||
}
|
||||
}
|
||||
|
||||
rpmdbFreeIterator(mi);
|
||||
mi = rpmdbFreeIterator(mi);
|
||||
}
|
||||
|
||||
static int findPackagesWithObsoletes(rpmdb db, struct pkgSet *psp)
|
||||
|
@ -155,7 +159,7 @@ static int findPackagesWithObsoletes(rpmdb db, struct pkgSet *psp)
|
|||
count = psp->numPackages;
|
||||
pip = psp->packages;
|
||||
while (count--) {
|
||||
if ((*pip)->selected) {
|
||||
if ((*pip)->selected != 0) {
|
||||
pip++;
|
||||
continue;
|
||||
}
|
||||
|
@ -189,9 +193,12 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
|
|||
Header h, installedHeader;
|
||||
char *name;
|
||||
int count;
|
||||
char **installedFiles, **availFiles;
|
||||
char **installedDirs, ** availDirs;
|
||||
int_32 * installedDirIndexes, * availDirIndexes;
|
||||
char **installedFiles;
|
||||
char ** availFiles = NULL;
|
||||
char ** installedDirs;
|
||||
char ** availDirs = NULL;
|
||||
int_32 * installedDirIndexes;
|
||||
int_32 * availDirIndexes = NULL;
|
||||
int installedFileCount, availFileCount;
|
||||
struct packageInfo **pip;
|
||||
|
||||
|
@ -200,8 +207,9 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
|
|||
while (count--) {
|
||||
h = (*pip)->h;
|
||||
name = NULL;
|
||||
headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
if (!name) {
|
||||
if (!headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL) ||
|
||||
name == NULL)
|
||||
{
|
||||
/* bum header */
|
||||
/*logMessage("Failed with bad header");*/
|
||||
return(-1);
|
||||
|
@ -212,9 +220,9 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
|
|||
{ rpmdbMatchIterator mi;
|
||||
|
||||
mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
|
||||
skipThis = (mi ? 0 : 1);
|
||||
rpmErrorSetCallback(errorFunction);
|
||||
while((installedHeader = rpmdbNextIterator(mi)) != NULL) {
|
||||
skipThis = (mi != NULL ? 0 : 1);
|
||||
(void) rpmErrorSetCallback(errorFunction);
|
||||
while ((installedHeader = rpmdbNextIterator(mi)) != NULL) {
|
||||
if (rpmVersionCompare(installedHeader, h) >= 0) {
|
||||
/* already have a newer version installed */
|
||||
DEBUG (("Already have newer version\n"))
|
||||
|
@ -222,8 +230,8 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
|
|||
break;
|
||||
}
|
||||
}
|
||||
rpmdbFreeIterator(mi);
|
||||
rpmErrorSetCallback(NULL);
|
||||
mi = rpmdbFreeIterator(mi);
|
||||
(void) rpmErrorSetCallback(NULL);
|
||||
if (! skipThis) {
|
||||
DEBUG (("No newer version installed\n"))
|
||||
}
|
||||
|
@ -240,9 +248,9 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
|
|||
availFiles = NULL;
|
||||
availFileCount = 0;
|
||||
} else {
|
||||
headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
|
||||
(void) headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
|
||||
(const void **) &availDirs, NULL);
|
||||
headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
|
||||
(void) headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
|
||||
(const void **) &availDirIndexes, NULL);
|
||||
}
|
||||
|
||||
|
@ -250,12 +258,13 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
|
|||
mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
|
||||
while((installedHeader = rpmdbNextIterator(mi)) != NULL) {
|
||||
if (headerGetEntryMinMemory(installedHeader, RPMTAG_BASENAMES,
|
||||
NULL, (const void **) &installedFiles,
|
||||
&installedFileCount)) {
|
||||
headerGetEntryMinMemory(installedHeader, RPMTAG_DIRNAMES,
|
||||
NULL, (const void **) &installedDirs, NULL);
|
||||
headerGetEntryMinMemory(installedHeader, RPMTAG_DIRINDEXES,
|
||||
NULL, (const void **) &installedDirIndexes, NULL);
|
||||
NULL, (const void **) &installedFiles,
|
||||
&installedFileCount)
|
||||
&& headerGetEntryMinMemory(installedHeader, RPMTAG_DIRNAMES,
|
||||
NULL, (const void **) &installedDirs, NULL)
|
||||
&& headerGetEntryMinMemory(installedHeader, RPMTAG_DIRINDEXES,
|
||||
NULL, (const void **) &installedDirIndexes, NULL))
|
||||
{
|
||||
|
||||
compareFileList(availFileCount, availFiles,
|
||||
availDirs, availDirIndexes,
|
||||
|
@ -267,7 +276,7 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
|
|||
free(installedDirs);
|
||||
}
|
||||
}
|
||||
rpmdbFreeIterator(mi);
|
||||
mi = rpmdbFreeIterator(mi);
|
||||
}
|
||||
|
||||
if (availFiles) {
|
||||
|
@ -290,7 +299,7 @@ static int removeMovedFilesAlreadyHandled(struct pkgSet *psp,
|
|||
char *name;
|
||||
int i, count;
|
||||
Header h;
|
||||
char **availFiles, ** availDirs;
|
||||
char ** availFiles, ** availDirs;
|
||||
int_32 * availDirIndexes;
|
||||
int availFileCount;
|
||||
struct packageInfo **pip;
|
||||
|
@ -299,17 +308,18 @@ static int removeMovedFilesAlreadyHandled(struct pkgSet *psp,
|
|||
pip = psp->packages;
|
||||
while (count--) {
|
||||
h = (*pip)->h;
|
||||
if ((*pip)->selected) {
|
||||
if ((*pip)->selected != 0) {
|
||||
name = NULL;
|
||||
headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
(void) headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
|
||||
if (headerGetEntryMinMemory(h, RPMTAG_BASENAMES, NULL,
|
||||
(const void **) &availFiles, &availFileCount)) {
|
||||
(const void **) &availFiles, &availFileCount)
|
||||
|
||||
headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
|
||||
(const void **) &availDirs, NULL);
|
||||
headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
|
||||
(const void **) &availDirIndexes, NULL);
|
||||
&& headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
|
||||
(const void **) &availDirs, NULL)
|
||||
&& headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
|
||||
(const void **) &availDirIndexes, NULL))
|
||||
{
|
||||
|
||||
for (i = 0; i < availFileCount; i++) {
|
||||
if (htInTable(ht, availDirs[availDirIndexes[i]],
|
||||
|
@ -351,16 +361,17 @@ static int findPackagesWithRelocatedFiles(struct pkgSet *psp,
|
|||
h = (*pip)->h;
|
||||
if (! (*pip)->selected) {
|
||||
name = NULL;
|
||||
headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
(void) headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
|
||||
if (headerGetEntry(h, RPMTAG_BASENAMES, NULL,
|
||||
(void **) &availFiles, &availFileCount)) {
|
||||
headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
|
||||
(const void **) &availDirs, NULL);
|
||||
headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
|
||||
(const void **) &availDirIndexes, NULL);
|
||||
headerGetEntryMinMemory(h, RPMTAG_FILEMODES, NULL,
|
||||
(const void **) &availFileModes, NULL);
|
||||
(void **) &availFiles, &availFileCount)
|
||||
&& headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL,
|
||||
(const void **) &availDirs, NULL)
|
||||
&& headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL,
|
||||
(const void **) &availDirIndexes, NULL)
|
||||
&& headerGetEntryMinMemory(h, RPMTAG_FILEMODES, NULL,
|
||||
(const void **) &availFileModes, NULL))
|
||||
{
|
||||
|
||||
for (i = 0; i < availFileCount; i++) {
|
||||
if (S_ISDIR(availFileModes[i])) continue;
|
||||
|
@ -414,12 +425,13 @@ static int unmarkPackagesAlreadyInstalled(rpmdb db, struct pkgSet *psp)
|
|||
count = psp->numPackages;
|
||||
pip = psp->packages;
|
||||
while (count--) {
|
||||
if ((*pip)->selected) {
|
||||
if ((*pip)->selected != 0) {
|
||||
h = (*pip)->h;
|
||||
/* If this package is already installed, don't bother */
|
||||
name = NULL;
|
||||
headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
if (!name) {
|
||||
if (!headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL) ||
|
||||
name == NULL)
|
||||
{
|
||||
/* bum header */
|
||||
/*logMessage("Failed with bad header");*/
|
||||
return(-1);
|
||||
|
@ -427,7 +439,7 @@ static int unmarkPackagesAlreadyInstalled(rpmdb db, struct pkgSet *psp)
|
|||
{ rpmdbMatchIterator mi;
|
||||
|
||||
mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
|
||||
rpmErrorSetCallback(errorFunction);
|
||||
(void) rpmErrorSetCallback(errorFunction);
|
||||
while((installedHeader = rpmdbNextIterator(mi)) != NULL) {
|
||||
if (rpmVersionCompare(installedHeader, h) >= 0) {
|
||||
/* already have a newer version installed */
|
||||
|
@ -436,8 +448,8 @@ static int unmarkPackagesAlreadyInstalled(rpmdb db, struct pkgSet *psp)
|
|||
break;
|
||||
}
|
||||
}
|
||||
rpmdbFreeIterator(mi);
|
||||
rpmErrorSetCallback(NULL);
|
||||
mi = rpmdbFreeIterator(mi);
|
||||
(void) rpmErrorSetCallback(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -469,10 +481,11 @@ int ugFindUpgradePackages(struct pkgSet *psp, char *installRoot)
|
|||
return(-1);
|
||||
}
|
||||
|
||||
rpmErrorSetCallback(old);
|
||||
(void) rpmErrorSetCallback(old);
|
||||
rpmSetVerbosity(RPMMESS_NORMAL);
|
||||
|
||||
hashTable = htNewTable(1103);
|
||||
if (hashTable == NULL) return (-1);
|
||||
|
||||
/* For all packages that are installed, if there is no package */
|
||||
/* available by that name, add the package's files to the hash table */
|
||||
|
@ -484,7 +497,7 @@ int ugFindUpgradePackages(struct pkgSet *psp, char *installRoot)
|
|||
/* updating availPkgs with the count. Also add files to the hash */
|
||||
/* table that do not exist in the new package - they may have moved */
|
||||
if (findUpgradePackages(db, psp, hashTable)) {
|
||||
rpmdbClose(db);
|
||||
(void) rpmdbClose(db);
|
||||
return(-1);
|
||||
}
|
||||
/*logDebugMessage(("found basic packages to upgrade"));
|
||||
|
@ -493,19 +506,19 @@ int ugFindUpgradePackages(struct pkgSet *psp, char *installRoot)
|
|||
|
||||
/* Remove any files that were added to the hash table that are in */
|
||||
/* some other package marked for upgrade. */
|
||||
removeMovedFilesAlreadyHandled(psp, hashTable);
|
||||
(void) removeMovedFilesAlreadyHandled(psp, hashTable);
|
||||
/*logDebugMessage(("removed extra files which have moved"));
|
||||
printCount(psp);*/
|
||||
|
||||
findPackagesWithRelocatedFiles(psp, hashTable);
|
||||
(void) findPackagesWithRelocatedFiles(psp, hashTable);
|
||||
/*logDebugMessage(("found packages with relocated files"));
|
||||
printCount(psp);*/
|
||||
|
||||
findPackagesWithObsoletes(db, psp);
|
||||
(void) findPackagesWithObsoletes(db, psp);
|
||||
/*logDebugMessage(("found packages that obsolete installed packages"));
|
||||
printCount(psp);*/
|
||||
|
||||
unmarkPackagesAlreadyInstalled(db, psp);
|
||||
(void) unmarkPackagesAlreadyInstalled(db, psp);
|
||||
/*logDebugMessage(("unmarked packages already installed"));
|
||||
printCount(psp);*/
|
||||
|
||||
|
@ -513,7 +526,7 @@ int ugFindUpgradePackages(struct pkgSet *psp, char *installRoot)
|
|||
|
||||
/*printMemStats("Done");*/
|
||||
|
||||
rpmdbClose(db);
|
||||
(void) rpmdbClose(db);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue