lclint annotations.

CVS patchset: 3290
CVS date: 1999/09/17 20:52:46
This commit is contained in:
jbj 1999-09-17 20:52:46 +00:00
parent a8e5caca58
commit 00dcfeff38
8 changed files with 67 additions and 52 deletions

View File

@ -39,7 +39,7 @@ dbiIndex * dbiOpenIndex(const char * filename, int flags, int perms, DBTYPE type
void dbiCloseIndex(dbiIndex * dbi) {
dbi->db->close(dbi->db);
free(dbi->indexname);
xfree(dbi->indexname);
free(dbi);
}
@ -54,6 +54,8 @@ int dbiGetFirstKey(dbiIndex * dbi, const char ** keyp) {
if (dbi == NULL || dbi->db == NULL)
return 1;
key.data = NULL;
key.size = 0;
rc = dbi->db->seq(dbi->db, &key, &data, R_FIRST);
if (rc) {
return 1;
@ -74,6 +76,8 @@ int dbiSearchIndex(dbiIndex * dbi, const char * str, dbiIndexSet * set) {
key.data = (void *)str;
key.size = strlen(str);
data.data = NULL;
data.size = 0;
rc = dbi->db->get(dbi->db, &key, &data, 0);
if (rc == -1) {

View File

@ -25,27 +25,27 @@ typedef /*@abstract@*/ struct {
typedef /*@abstract@*/ struct {
DB * db;
char * indexname;
const char * indexname;
} dbiIndex;
#ifdef __cplusplus
extern "C" {
#endif
dbiIndex * dbiOpenIndex(const char * filename, int flags, int perms, DBTYPE type);
void dbiCloseIndex(dbiIndex * dbi);
/*@only@*/dbiIndex * dbiOpenIndex(const char * filename, int flags, int perms, DBTYPE type);
void dbiCloseIndex(/*@only@*/dbiIndex * dbi);
void dbiSyncIndex(dbiIndex * dbi);
int dbiSearchIndex(dbiIndex * dbi, const char * str, dbiIndexSet * set);
int dbiSearchIndex(dbiIndex * dbi, const char * str, /*@out@*/dbiIndexSet * set);
/* -1 error, 0 success, 1 not found */
int dbiUpdateIndex(dbiIndex * dbi, const char * str, dbiIndexSet * set);
/* 0 on success */
int dbiAppendIndexRecord(dbiIndexSet * set, dbiIndexRecord rec);
int dbiAppendIndexRecord(/*@out@*/dbiIndexSet * set, dbiIndexRecord rec);
/* 0 on success - should never fail */
int dbiRemoveIndexRecord(dbiIndexSet * set, dbiIndexRecord rec);
/* 0 on success - fails if rec is not found */
dbiIndexSet dbiCreateIndexRecord(void);
void dbiFreeIndexRecord(dbiIndexSet set);
int dbiGetFirstKey(dbiIndex * dbi, const char ** key);
int dbiGetFirstKey(dbiIndex * dbi, /*@out@*/const char ** key);
extern unsigned int dbiIndexSetCount(dbiIndexSet set);

View File

@ -71,7 +71,8 @@ static fingerPrint doLookup(const char * fullName, int scareMemory,
/* if the current directory doesn't exist, we might fail.
oh well. likewise if it's too long. */
if (realpath(".", dir) != NULL) {
dir[0] = '\0';
if ( /*@-unrecog@*/ realpath(".", dir) /*@=unrecog@*/ != NULL) {
char *s = alloca(strlen(dir) + strlen(fullName) + 2);
sprintf(s, "%s/%s", dir, fullName);
fullName = chptr1 = s;
@ -136,8 +137,8 @@ unsigned int fpHashFunction(const void * key)
chptr = fp->basename;
while (*chptr) ch ^= *chptr++;
hash |= ch << 24;
hash |= (((fp->dev >> 8) ^ fp->dev) & 0xFF) << 16;
hash |= ((unsigned)ch) << 24;
hash |= (((((unsigned)fp->dev) >> 8) ^ fp->dev) & 0xFF) << 16;
hash |= fp->ino & 0xFFFF;
return hash;
@ -174,6 +175,8 @@ void fpLookupList(const char ** fullNames, fingerPrint * fpList, int numItems,
cache.matchLength = 0;
cache.pathsStripped = 0;
cache.stripLength = 0;
cache.dev = 0;
cache.ino = 0;
for (i = 0; i < numItems; i++) {
fpList[i] = doLookup(fullNames[i], 1, &cache);

View File

@ -4,10 +4,10 @@
#include "hash.h"
struct hashBucket {
const void * key;
const void ** data;
/*@owned@*/const void * key;
/*@owned@*/const void ** data;
int dataCount;
struct hashBucket * next;
/*@dependent@*/struct hashBucket * next;
};
struct hashTable_s {
@ -18,7 +18,7 @@ struct hashTable_s {
hashEqualityType eq;
};
static struct hashBucket * findEntry(hashTable ht, const void * key)
static /*@shared@*/ struct hashBucket * findEntry(hashTable ht, const void * key)
{
unsigned int hash;
struct hashBucket * b;
@ -53,7 +53,7 @@ unsigned int hashFunctionString(const void * string)
sum += *chp;
}
return ((len << 16) + (sum << 8) + xorValue);
return ((((unsigned)len) << 16) + (((unsigned)sum) << 8) + xorValue);
}
hashTable htCreate(int numBuckets, int keySize, hashFunctionType fn,
@ -89,7 +89,7 @@ void htAddEntry(hashTable ht, const void * key, const void * data)
memcpy(k, key, ht->keySize);
b->key = k;
} else {
b->key = (void *) key;
b->key = key;
}
b->dataCount = 0;
b->next = ht->buckets[hash];

View File

@ -63,15 +63,15 @@ void rpmMessage(int level, const char * format, ...) {
fprintf(stderr, _("fatal error: "));
vfprintf(stderr, format, args);
fflush(stderr);
exit(1);
break;
exit(EXIT_FAILURE);
/*@unreached@*/ break;
default:
fprintf(stderr, _("internal error (rpm bug?): "));
vfprintf(stderr, format, args);
fflush(stderr);
exit(1);
break;
exit(EXIT_FAILURE);
/*@unreached@*/ break;
}
}

View File

@ -19,7 +19,7 @@
#if defined(ENABLE_V1_PACKAGES)
/* 0 = success */
/* !0 = error */
static int readOldHeader(FD_t fd, Header * hdr, int * isSource)
static int readOldHeader(FD_t fd, /*@out@*/Header * hdr, /*@unused@*/ /*@out@*/int * isSource)
{
struct oldrpmHeader oldheader;
struct oldrpmHeaderSpec spec;
@ -143,31 +143,31 @@ static int readOldHeader(FD_t fd, Header * hdr, int * isSource)
}
}
headerAddEntry(dbentry, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE,
headerAddEntry(*hdr, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE,
fileList, spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILELINKTOS, RPM_STRING_ARRAY_TYPE,
headerAddEntry(*hdr, RPMTAG_FILELINKTOS, RPM_STRING_ARRAY_TYPE,
fileLinktoList, spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILEMD5S, RPM_STRING_ARRAY_TYPE,
headerAddEntry(*hdr, RPMTAG_FILEMD5S, RPM_STRING_ARRAY_TYPE,
fileMD5List, spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILESIZES, RPM_INT32_TYPE, fileSizeList,
headerAddEntry(*hdr, RPMTAG_FILESIZES, RPM_INT32_TYPE, fileSizeList,
spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILEUIDS, RPM_INT32_TYPE, fileUIDList,
headerAddEntry(*hdr, RPMTAG_FILEUIDS, RPM_INT32_TYPE, fileUIDList,
spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILEGIDS, RPM_INT32_TYPE, fileGIDList,
headerAddEntry(*hdr, RPMTAG_FILEGIDS, RPM_INT32_TYPE, fileGIDList,
spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILEMTIMES, RPM_INT32_TYPE,
headerAddEntry(*hdr, RPMTAG_FILEMTIMES, RPM_INT32_TYPE,
fileMtimesList, spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILEFLAGS, RPM_INT32_TYPE,
headerAddEntry(*hdr, RPMTAG_FILEFLAGS, RPM_INT32_TYPE,
fileFlagsList, spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILEMODES, RPM_INT16_TYPE,
headerAddEntry(*hdr, RPMTAG_FILEMODES, RPM_INT16_TYPE,
fileModesList, spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILERDEVS, RPM_INT16_TYPE,
headerAddEntry(*hdr, RPMTAG_FILERDEVS, RPM_INT16_TYPE,
fileRDevsList, spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILESTATES, RPM_INT8_TYPE,
headerAddEntry(*hdr, RPMTAG_FILESTATES, RPM_INT8_TYPE,
fileStatesList, spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILEUSERNAME, RPM_STRING_ARRAY_TYPE,
headerAddEntry(*hdr, RPMTAG_FILEUSERNAME, RPM_STRING_ARRAY_TYPE,
unames, spec.fileCount);
headerAddEntry(dbentry, RPMTAG_FILEGROUPNAME, RPM_STRING_ARRAY_TYPE,
headerAddEntry(*hdr, RPMTAG_FILEGROUPNAME, RPM_STRING_ARRAY_TYPE,
gnames, spec.fileCount);
free(fileList);
@ -200,12 +200,12 @@ static int readOldHeader(FD_t fd, Header * hdr, int * isSource)
/* 0 = success */
/* 1 = bad magic */
/* 2 = error */
static int readPackageHeaders(FD_t fd, struct rpmlead * leadPtr,
Header * sigs, Header * hdrPtr)
static int readPackageHeaders(FD_t fd, /*@out@*/struct rpmlead * leadPtr,
/*@out@*/Header * sigs, /*@out@*/Header * hdrPtr)
{
Header hdrBlock;
struct rpmlead leadBlock;
Header * hdr;
Header * hdr = NULL;
struct rpmlead * lead;
int_8 arch;
int isSource;
@ -297,7 +297,7 @@ static int readPackageHeaders(FD_t fd, struct rpmlead * leadPtr,
rpmError(RPMERR_NEWPACKAGE, _("only packages with major numbers <= 3 "
"are supported by this version of RPM"));
return 2;
break;
/*@notreached@*/ break;
}
if (hdrPtr == NULL) headerFree(*hdr);

View File

@ -5,6 +5,9 @@
#include "depends.h"
#include "misc.h"
/*@access rpmProblemSet@*/
/*@access rpmProblem@*/
/* XXX FIXME: merge into problems */
/* XXX used in verify.c */
void printDepFlags(FILE * fp, const char * version, int flags)
@ -45,10 +48,10 @@ void printDepProblems(FILE * fp, struct rpmDependencyConflict * conflicts,
}
}
char * rpmProblemString(rpmProblem prob)
const char * rpmProblemString(rpmProblem prob)
{
const char * name, * version, * release;
const char * altName, * altVersion, * altRelease;
const char * altName = NULL, * altVersion = NULL, * altRelease = NULL;
char * buf;
headerNVR(prob.h, &name, &version, &release);

View File

@ -30,7 +30,12 @@
# endif
#endif
struct fileInfo {
/*@access rpmdb@*/
/*@access rpmTransactionSet@*/
/*@access rpmProblemSet@*/
/*@access rpmProblem@*/
typedef struct transactionFileInfo {
/* for all packages */
enum rpmTransactionType type;
enum fileActions * actions;
@ -49,7 +54,7 @@ struct fileInfo {
uint_32 * replacedSizes;
/* for TR_REMOVED packages */
unsigned int record;
};
} TFI_t;
struct diskspaceInfo {
dev_t dev;
@ -70,7 +75,7 @@ struct diskspaceInfo {
#define XFA_SKIPPING(_a) \
((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED)
static void freeFi(struct fileInfo *fi)
static void freeFi(TFI_t *fi)
{
if (fi->h) {
headerFree(fi->h); fi->h = NULL;
@ -114,9 +119,9 @@ static void freeFi(struct fileInfo *fi)
}
}
static void freeFl(rpmTransactionSet ts, struct fileInfo *flList)
static void freeFl(rpmTransactionSet ts, TFI_t *flList)
{
struct fileInfo *fi;
TFI_t *fi;
int oc;
for (oc = 0, fi = flList; oc < ts->orderCount; oc++, fi++) {
@ -564,7 +569,7 @@ static int filecmp(short mode1, const char * md51, const char * link1,
return 0;
}
static int handleInstInstalledFiles(struct fileInfo * fi, rpmdb db,
static int handleInstInstalledFiles(TFI_t * fi, rpmdb db,
struct sharedFileInfo * shared,
int sharedCount, int reportConflicts,
rpmProblemSet probs)
@ -647,7 +652,7 @@ static int handleInstInstalledFiles(struct fileInfo * fi, rpmdb db,
return 0;
}
static int handleRmvdInstalledFiles(struct fileInfo * fi, rpmdb db,
static int handleRmvdInstalledFiles(TFI_t * fi, rpmdb db,
struct sharedFileInfo * shared,
int sharedCount)
{
@ -677,7 +682,7 @@ static int handleRmvdInstalledFiles(struct fileInfo * fi, rpmdb db,
return 0;
}
static void handleOverlappedFiles(struct fileInfo * fi, hashTable ht,
static void handleOverlappedFiles(TFI_t * fi, hashTable ht,
rpmProblemSet probs, struct diskspaceInfo * dsl)
{
int i, j;
@ -686,7 +691,7 @@ static void handleOverlappedFiles(struct fileInfo * fi, hashTable ht,
for (i = 0; i < fi->fc; i++) {
int otherPkgNum, otherFileNum;
const struct fileInfo ** recs;
const TFI_t ** recs;
int numRecs;
if (XFA_SKIPPING(fi->actions[i]))
@ -877,7 +882,7 @@ static int ensureOlder(rpmdb db, Header new, int dbOffset, rpmProblemSet probs,
return rc;
}
static void skipFiles(struct fileInfo * fi, int noDocs)
static void skipFiles(TFI_t * fi, int noDocs)
{
int i;
char ** netsharedPaths = NULL;
@ -993,7 +998,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
int fileCount;
int totalFileCount = 0;
hashTable ht;
struct fileInfo * flList, * fi;
TFI_t * flList, * fi;
struct sharedFileInfo * shared, * sharedList;
int numShared;
int flEntries;
@ -1443,7 +1448,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
headerFree(hdrs[i]);
if (!alp->fd && fd)
if (alp->fd == NULL && fd)
notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0, alp->key,
notifyData);
break;