summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1998-11-16 21:40:28 +0000
committerjbj <devnull@localhost>1998-11-16 21:40:28 +0000
commit28c4ae83a312a54cbe0faa2827ca6a3f9106b4a9 (patch)
treeb73dd13f60ab5e3904f93cd76622c4f5f61ad6f1
parentbed2bf89c9cc52f655900413d32eb8a5bdcb810c (diff)
downloadlibrpm-tizen-28c4ae83a312a54cbe0faa2827ca6a3f9106b4a9.tar.gz
librpm-tizen-28c4ae83a312a54cbe0faa2827ca6a3f9106b4a9.tar.bz2
librpm-tizen-28c4ae83a312a54cbe0faa2827ca6a3f9106b4a9.zip
LCLINT pass 0.
CVS patchset: 2540 CVS date: 1998/11/16 21:40:28
-rw-r--r--.files7
-rw-r--r--.lclintrc36
-rw-r--r--build.c4
-rw-r--r--build/.files18
-rw-r--r--build/.lclintrc36
-rw-r--r--build/build.c4
-rw-r--r--build/files.c20
-rw-r--r--build/myftw.c1
-rw-r--r--build/pack.c15
-rw-r--r--build/parseBuildInstallClean.c2
-rw-r--r--build/parseFiles.c2
-rw-r--r--build/parsePreamble.c2
-rw-r--r--build/parsePrep.c18
-rw-r--r--build/parseSpec.c6
-rw-r--r--build/spec.c2
-rw-r--r--checksig.c10
-rw-r--r--ftp.c2
-rw-r--r--install.c6
-rw-r--r--lib/.files28
-rw-r--r--lib/.lclintrc36
-rw-r--r--lib/cpio.c10
-rw-r--r--lib/dbindex.h2
-rw-r--r--lib/depends.c12
-rw-r--r--lib/falloc.c58
-rw-r--r--lib/falloc.h8
-rw-r--r--lib/header.c26
-rw-r--r--lib/header.h4
-rw-r--r--lib/install.c20
-rw-r--r--lib/lookup.c2
-rw-r--r--lib/macro.c2
-rw-r--r--lib/md5.h2
-rw-r--r--lib/misc.c3
-rw-r--r--lib/oldheader.c4
-rw-r--r--lib/package.c10
-rw-r--r--lib/query.c25
-rw-r--r--lib/rebuilddb.c2
-rw-r--r--lib/rpmdb.c24
-rw-r--r--lib/rpmlib.h2
-rw-r--r--lib/rpmmacro.h4
-rw-r--r--lib/rpmrc.c5
-rw-r--r--lib/signature.c12
-rw-r--r--lib/stringbuf.h2
-rw-r--r--lib/uninstall.c26
-rwxr-xr-xrpm.c12
-rw-r--r--rpmio/macro.c2
-rw-r--r--rpmio/rpmmacro.h4
-rw-r--r--verify.c4
47 files changed, 378 insertions, 164 deletions
diff --git a/.files b/.files
new file mode 100644
index 000000000..4965116ac
--- /dev/null
+++ b/.files
@@ -0,0 +1,7 @@
+build.c
+checksig.c
+rpm.c
+ftp.c
+install.c
+verify.c
+url.c
diff --git a/.lclintrc b/.lclintrc
new file mode 100644
index 000000000..11fa21998
--- /dev/null
+++ b/.lclintrc
@@ -0,0 +1,36 @@
+-I. -I./build -I./lib -I./popt
+
+-Du_long=unsigned
+-Du_int=unsigned
+-Du_short=short
+-Du_char=char
+
+-Du_int32_t=unsigned
+-Du_int16_t=short
+
+-Dfd_set=void
+
++partial
+
++unixlib #-> +posixlib
+-warnunixlib
+
++boolint
+-boolops
+-fixedformalarray
+-formattype
+-fullinitblock
++ignorequals
++ignoresigns
++longintegral
++matchanyintegral
+-mustfree
+-nullpass
+-observertrans
+-predboolint
+-predboolothers
+-redef
+-retvalint
+-retvalother
+-shiftsigned
+-type
diff --git a/build.c b/build.c
index 929c976d8..b9977170c 100644
--- a/build.c
+++ b/build.c
@@ -90,7 +90,7 @@ int buildplatform(char *arg, int buildAmount, char *passPhrase,
directory for this run */
if (*arg != '/') {
- getcwd(buf, BUFSIZ);
+ (void)getcwd(buf, BUFSIZ);
strcat(buf, "/");
strcat(buf, arg);
} else
@@ -105,7 +105,7 @@ int buildplatform(char *arg, int buildAmount, char *passPhrase,
specfile = arg;
} else {
specfile = alloca(BUFSIZ);
- getcwd(specfile, BUFSIZ);
+ (void)getcwd(specfile, BUFSIZ);
strcat(specfile, "/");
strcat(specfile, arg);
}
diff --git a/build/.files b/build/.files
new file mode 100644
index 000000000..e888cd303
--- /dev/null
+++ b/build/.files
@@ -0,0 +1,18 @@
+build.c
+expression.c
+files.c
+misc.c
+myftw.c
+names.c
+pack.c
+parseBuildInstallClean.c
+parseChangelog.c
+parseDescription.c
+parseFiles.c
+parsePreamble.c
+parsePrep.c
+parseReqs.c
+parseScript.c
+parseSpec.c
+reqprov.c
+spec.c
diff --git a/build/.lclintrc b/build/.lclintrc
new file mode 100644
index 000000000..7e763e22f
--- /dev/null
+++ b/build/.lclintrc
@@ -0,0 +1,36 @@
+-I. -I.. -I../lib
+
+-Du_long=unsigned
+-Du_int=unsigned
+-Du_short=short
+-Du_char=char
+
+-Du_int32_t=unsigned
+-Du_int16_t=short
+
+-Dfd_set=void
+
++partial
+
++unixlib #-> +posixlib
+-warnunixlib
+
++boolint
+-boolops
+-fixedformalarray
+-formattype
+-fullinitblock
++ignorequals
++ignoresigns
++longintegral
++matchanyintegral
+-mustfree
+-nullpass
+-observertrans
+-predboolint
+-predboolothers
+-redef
+-retvalint
+-retvalother
+-shiftsigned
+-type
diff --git a/build/build.c b/build/build.c
index 6dc6fbc7b..d6d3d3a62 100644
--- a/build/build.c
+++ b/build/build.c
@@ -79,7 +79,7 @@ int doScript(Spec spec, int what, char *name, StringBuf sb, int test)
case RPMBUILD_STRINGBUF:
break;
}
- if ((what != RPMBUILD_RMBUILD) && !sb) {
+ if ((what != RPMBUILD_RMBUILD) && sb == NULL) {
return 0;
}
@@ -133,7 +133,7 @@ int doScript(Spec spec, int what, char *name, StringBuf sb, int test)
FREE(scriptName);
return RPMERR_SCRIPT;
}
- wait(&status);
+ (void)wait(&status);
if (! WIFEXITED(status) || WEXITSTATUS(status)) {
rpmError(RPMERR_SCRIPT, _("Bad exit status from %s (%s)"),
scriptName, name);
diff --git a/build/files.c b/build/files.c
index fcd86bcc2..736464b02 100644
--- a/build/files.c
+++ b/build/files.c
@@ -10,6 +10,12 @@
#include "md5.h"
#include "rpmmacro.h"
+#ifdef __LCLINT__
+#define FINDPROVIDES "/usr/lib/rpm/find-provides"
+#define FINDREQUIRES "/usr/lib/rpm/find-requires"
+#define MKDIR_P "mkdir -p"
+#endif
+
#define MAXDOCDIR 1024
struct FileListRec {
@@ -362,7 +368,7 @@ static int parseForAttr(char *buf, struct FileList *fl)
if (!strcmp(resultAttr->PmodeString, "-")) {
resultAttr->PmodeString = NULL;
} else {
- x = sscanf(resultAttr->PmodeString, "%o", &(resultAttr->Pmode));
+ x = sscanf(resultAttr->PmodeString, "%o", (unsigned *)&(resultAttr->Pmode));
if ((x == 0) || (resultAttr->Pmode >> 12)) {
rpmError(RPMERR_BADSPEC, _("Bad %s() mode spec: %s"), name, buf);
resultAttr->PmodeString = resultAttr->Uname =
@@ -379,7 +385,7 @@ static int parseForAttr(char *buf, struct FileList *fl)
resultAttr->PdirmodeString = strdup(resultAttr->PdirmodeString);
} else {
x = sscanf(resultAttr->PdirmodeString, "%o",
- &(resultAttr->Pdirmode));
+ (unsigned *)&(resultAttr->Pdirmode));
if ((x == 0) || (resultAttr->Pdirmode >> 12)) {
rpmError(RPMERR_BADSPEC,
_("Bad %s() dirmode spec: %s"), name, buf);
@@ -1511,10 +1517,10 @@ static StringBuf getOutputFrom(char *dir, char *argv[],
if (toProg[1] >= 0)
close(toProg[1]);
close(fromProg[0]);
- signal(SIGPIPE, oldhandler);
+ (void)signal(SIGPIPE, oldhandler);
/* Collect status from prog */
- waitpid(progPID, &status, 0);
+ (void)waitpid(progPID, &status, 0);
if (failNonZero && (!WIFEXITED(status) || WEXITSTATUS(status))) {
rpmError(RPMERR_EXEC, _("%s failed"), argv[0]);
return NULL;
@@ -1560,7 +1566,7 @@ static int generateAutoReqProv(Spec spec, Package pkg,
argv[1] = NULL;
readBuf = getOutputFrom(NULL, argv,
getStringBuf(writeBuf), writeBytes, 1);
- if (!readBuf) {
+ if (readBuf == NULL) {
rpmError(RPMERR_EXEC, _("Failed to find provides"));
freeStringBuf(writeBuf);
return RPMERR_EXEC;
@@ -1587,7 +1593,7 @@ static int generateAutoReqProv(Spec spec, Package pkg,
argv[1] = NULL;
readBuf = getOutputFrom(NULL, argv,
getStringBuf(writeBuf), writeBytes, 0);
- if (!readBuf) {
+ if (readBuf == NULL) {
rpmError(RPMERR_EXEC, _("Failed to find requires"));
freeStringBuf(writeBuf);
return RPMERR_EXEC;
@@ -1675,7 +1681,7 @@ int processBinaryFiles(Spec spec, int installSpecialDoc, int test)
res = 0;
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
- if (!pkg->fileList) {
+ if (pkg->fileList == NULL) {
continue;
}
diff --git a/build/myftw.c b/build/myftw.c
index 16656554f..21cba4663 100644
--- a/build/myftw.c
+++ b/build/myftw.c
@@ -176,6 +176,7 @@ int myftw (const char *dir,
if (descriptors <= 0)
descriptors = 1;
+ /*@access DIR@*/
dirs = (DIR **) alloca (descriptors * sizeof (DIR *));
i = descriptors;
while (i-- > 0)
diff --git a/build/pack.c b/build/pack.c
index ebdfe363c..b7f5a5f01 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -48,6 +48,9 @@ int packageSources(Spec spec)
int_32 tag, count;
char **ptr;
+#ifdef __LCLINT__
+#define VERSION "3.0"
+#endif
/* Add some cruft */
headerAddEntry(spec->sourceHeader, RPMTAG_RPMVERSION,
RPM_STRING_TYPE, VERSION, 1);
@@ -106,7 +109,7 @@ int packageBinaries(Spec spec)
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
- if (!pkg->fileList)
+ if (pkg->fileList == NULL)
continue;
if ((rc = processScriptFiles(spec, pkg)))
@@ -181,14 +184,14 @@ int readRPM(char *fileName, Spec *specp, struct rpmlead *lead, Header *sigs,
strerror(errno));
return RPMERR_BADMAGIC;
}
- lseek(fdi, 0, SEEK_SET); /* XXX FIXME: EPIPE */
+ (void)lseek(fdi, 0, SEEK_SET); /* XXX FIXME: EPIPE */
/* Reallocate build data structures */
spec = newSpec();
spec->packages = newPackage(spec);
/* XXX the header just allocated will be allocated again */
- if (spec->packages->header) {
+ if (spec->packages->header != NULL) {
headerFree(spec->packages->header);
spec->packages->header = NULL;
}
@@ -272,7 +275,7 @@ int writeRPM(Header header, char *fileName, int type,
headerModifyEntry(header, RPMTAG_ARCHIVESIZE,
RPM_INT32_TYPE, &csa->cpioArchiveSize, 1);
}
- lseek(fd, 0, SEEK_SET);
+ (void)lseek(fd, 0, SEEK_SET);
headerWrite(fd, header, HEADER_MAGIC_YES);
close(fd);
@@ -456,7 +459,7 @@ static int addFileToTag(Spec spec, char *file, Header h, int tag)
headerRemoveEntry(h, tag);
}
- if (! (sb = addFileToTagAux(spec, file, sb))) {
+ if ((sb = addFileToTagAux(spec, file, sb)) == NULL) {
return 1;
}
@@ -472,7 +475,7 @@ static int addFileToArrayTag(Spec spec, char *file, Header h, int tag)
char *s;
sb = newStringBuf();
- if (! (sb = addFileToTagAux(spec, file, sb))) {
+ if ((sb = addFileToTagAux(spec, file, sb)) == NULL) {
return 1;
}
diff --git a/build/parseBuildInstallClean.c b/build/parseBuildInstallClean.c
index 8ba908e14..2b181bede 100644
--- a/build/parseBuildInstallClean.c
+++ b/build/parseBuildInstallClean.c
@@ -23,7 +23,7 @@ int parseBuildInstallClean(Spec spec, int parsePart)
break;
}
- if (*sbp) {
+ if (*sbp != NULL) {
rpmError(RPMERR_BADSPEC, _("line %d: second %s"), spec->lineNum, name);
return RPMERR_BADSPEC;
}
diff --git a/build/parseFiles.c b/build/parseFiles.c
index ecfbb9d85..fcbe6eb9e 100644
--- a/build/parseFiles.c
+++ b/build/parseFiles.c
@@ -70,7 +70,7 @@ int parseFiles(Spec spec)
return RPMERR_BADSPEC;
}
- if (pkg->fileList) {
+ if (pkg->fileList != NULL) {
rpmError(RPMERR_BADSPEC, _("line %d: Second %%files list"),
spec->lineNum);
FREE(argv);
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 4df1c363c..e1077c4fc 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -72,7 +72,7 @@ static int parseSimplePart(char *line, char **name, int *flag)
strcpy(linebuf, line);
/* Throw away the first token (the %xxxx) */
- strtok(linebuf, " \t\n");
+ (void)strtok(linebuf, " \t\n");
if (!(tok = strtok(NULL, " \t\n"))) {
*name = NULL;
diff --git a/build/parsePrep.c b/build/parsePrep.c
index 620ae9d97..b252971ca 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -19,6 +19,10 @@
{ 0, 0, 0, 0, 0 }
};
+#ifdef __LCLINT__
+#define MKDIR_P "mkdir -p"
+#endif
+
#ifdef DYING
static int doSetupMacro(Spec spec, char *line);
static int doPatchMacro(Spec spec, char *line);
@@ -286,6 +290,9 @@ static int doSetupMacro(Spec spec, char *line)
/* clean up permissions etc */
if (!geteuid()) {
appendLineStringBuf(spec->prep, "chown -R root .");
+#ifdef __LCLINT__
+#define ROOT_GROUP "root"
+#endif
appendLineStringBuf(spec->prep, "chgrp -R " ROOT_GROUP " .");
}
@@ -303,7 +310,7 @@ static int doPatchMacro(Spec spec, char *line)
char *opt_b;
int opt_P, opt_p, opt_R, opt_E;
char *s;
- char buf[BUFSIZ];
+ char buf[BUFSIZ], *bp;
int patch_nums[1024]; /* XXX - we can only handle 1024 patches! */
int patch_index, x;
@@ -318,8 +325,11 @@ static int doPatchMacro(Spec spec, char *line)
strcpy(buf, line);
}
- strtok(buf, " \t\n"); /* remove %patch */
- while ((s = strtok(NULL, " \t\n"))) {
+ for (bp = buf; (s = strtok(bp, " \t\n")) != NULL;) {
+ if (bp) { /* remove 1st token (%patch) */
+ bp = NULL;
+ continue;
+ }
if (!strcmp(s, "-P")) {
opt_P = 1;
} else if (!strcmp(s, "-R")) {
@@ -402,7 +412,7 @@ int parsePrep(Spec spec, int force)
StringBuf buf;
char **lines, **saveLines;
- if (spec->prep) {
+ if (spec->prep != NULL) {
rpmError(RPMERR_BADSPEC, _("line %d: second %%prep"), spec->lineNum);
return RPMERR_BADSPEC;
}
diff --git a/build/parseSpec.c b/build/parseSpec.c
index e82604079..5aeb5a955 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -69,7 +69,7 @@ static int matchTok(char *token, char *line);
static int matchTok(char *token, char *line)
{
- char buf[BUFSIZ], *tok;
+ char buf[BUFSIZ], *bp, *tok;
/*
* XXX The strcasecmp below is necessary so the old (rpm < 2.90) style
@@ -77,8 +77,8 @@ static int matchTok(char *token, char *line)
* XXX os-from-platform (e.g "linux" from "sparc-*-linux").
*/
strcpy(buf, line);
- strtok(buf, " \n\t");
- while ((tok = strtok(NULL, " \n\t"))) {
+ for (bp = buf; (tok = strtok(bp, " \n\t")) != NULL;) {
+ bp = NULL;
if (! strcasecmp(tok, token)) {
return 1;
}
diff --git a/build/spec.c b/build/spec.c
index 57e86e107..41aa69b59 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -419,7 +419,7 @@ void freeSpec(Spec spec)
free(rl);
}
- if (spec->sourceHeader) {
+ if (spec->sourceHeader != NULL) {
headerFree(spec->sourceHeader);
}
diff --git a/checksig.c b/checksig.c
index 25b290b18..f953ae06d 100644
--- a/checksig.c
+++ b/checksig.c
@@ -172,7 +172,7 @@ int doCheckSig(int flags, char **argv)
res++;
continue;
}
- if (! sig) {
+ if (sig == NULL) {
fprintf(stderr, _("%s: No signature available\n"), rpm);
res++;
continue;
@@ -278,16 +278,16 @@ int doCheckSig(int flags, char **argv)
if (res2) {
if (rpmIsVerbose()) {
- fprintf(stderr, "%s", buffer);
+ fprintf(stderr, "%s", (char *)buffer);
} else {
- fprintf(stderr, "%s%s%s\n", buffer, _("NOT OK"),
+ fprintf(stderr, "%s%s%s\n", (char *)buffer, _("NOT OK"),
missingKeys ? _(" (MISSING KEYS)") : "");
}
} else {
if (rpmIsVerbose()) {
- fprintf(stdout, "%s", buffer);
+ fprintf(stdout, "%s", (char *)buffer);
} else {
- fprintf(stdout, "%s%s%s\n", buffer, _("OK"),
+ fprintf(stdout, "%s%s%s\n", (char *)buffer, _("OK"),
missingKeys ? _(" (MISSING KEYS)") : "");
}
}
diff --git a/ftp.c b/ftp.c
index 7b5805c4d..e9f52ff6a 100644
--- a/ftp.c
+++ b/ftp.c
@@ -7,9 +7,11 @@
#define HAVE_SYS_SOCKET_H 1
#endif
+#ifndef __LCLINT__
#if HAVE_MACHINE_TYPES_H
# include <machine/types.h>
#endif
+#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <sys/types.h>
diff --git a/install.c b/install.c
index 72e17badf..ca03ce203 100644
--- a/install.c
+++ b/install.c
@@ -82,7 +82,7 @@ static int installPackages(char * rootdir, char ** packages,
} else if (rpmIsVerbose())
fprintf(stdout, _("Installing %s\n"), *filename);
- if (db) {
+ if (db != NULL) {
rc = rpmInstallPackage(rootdir, db, fd, relocations, installFlags,
fn, printFormat);
} else {
@@ -202,7 +202,7 @@ int doInstall(char * rootdir, char ** argv, int installFlags,
*filename = NULL;
} else if (isSource) {
/* the header will be NULL if this is a v1 source package */
- if (binaryHeaders[numBinaryPackages])
+ if (binaryHeaders[numBinaryPackages] != NULL)
headerFree(binaryHeaders[numBinaryPackages]);
numSourcePackages++;
@@ -271,7 +271,7 @@ int doInstall(char * rootdir, char ** argv, int installFlags,
for (i = 0; i < numBinaryPackages; i++)
headerFree(binaryHeaders[i]);
- if (db) rpmdbClose(db);
+ if (db != NULL) rpmdbClose(db);
return numFailed;
}
diff --git a/lib/.files b/lib/.files
new file mode 100644
index 000000000..5af822fad
--- /dev/null
+++ b/lib/.files
@@ -0,0 +1,28 @@
+cpio.c
+dbindex.c
+depends.c
+falloc.c
+formats.c
+fs.c
+header.c
+install.c
+lookup.c
+macro.c
+md5.c
+md5sum.c
+messages.c
+misc.c
+oldheader.c
+package.c
+query.c
+rebuilddb.c
+rpmdb.c
+rpmerr.c
+rpmlead.c
+rpmrc.c
+signature.c
+stringbuf.c
+tagtable.c
+tread.c
+uninstall.c
+verify.c
diff --git a/lib/.lclintrc b/lib/.lclintrc
new file mode 100644
index 000000000..cf2576de8
--- /dev/null
+++ b/lib/.lclintrc
@@ -0,0 +1,36 @@
+-I. -I..
+
+-Du_long=unsigned
+-Du_int=unsigned
+-Du_short=short
+-Du_char=char
+
+-Du_int32_t=unsigned
+-Du_int16_t=short
+
+-Dfd_set=void
+
++partial
+
++unixlib #-> +posixlib
+-warnunixlib
+
++boolint
+-boolops
+-fixedformalarray
+-formattype
+-fullinitblock
++ignorequals
++ignoresigns
++longintegral
++matchanyintegral
+-mustfree
+-nullpass
+-observertrans
+-predboolint
+-predboolothers
+-redef
+-retvalint
+-retvalother
+-shiftsigned
+-type
diff --git a/lib/cpio.c b/lib/cpio.c
index a33772c37..9ef288fa4 100644
--- a/lib/cpio.c
+++ b/lib/cpio.c
@@ -60,13 +60,13 @@ static inline off_t saferead(CFD_t *cfd, void * vbuf, size_t amount) {
switch (cfd->cpioIoType) {
default:
#ifdef PARANOID
- fprintf(stderr, "\tsaferead(%p,%p,%x)\n", cfd, vbuf, amount);
+ fprintf(stderr, "\tsaferead(%p,%p,%x)\n", cfd, vbuf, (unsigned)amount);
exit(1);
break;
#endif
case cpioIoTypeDebug:
nb = amount;
- fprintf(stderr, "\tsaferead(%p,%p,%x)\n", cfd, vbuf, amount);
+ fprintf(stderr, "\tsaferead(%p,%p,%x)\n", cfd, vbuf, (unsigned)amount);
break;
case cpioIoTypeFd:
nb = read(cfd->cpioFd, buf, amount);
@@ -103,7 +103,7 @@ static inline void padinfd(CFD_t * cfd, int modulo) {
int amount;
amount = (modulo - cfd->cpioPos % modulo) % modulo;
- ourread(cfd, buf, amount);
+ (void)ourread(cfd, buf, amount);
}
static inline off_t safewrite(CFD_t *cfd, void * vbuf, size_t amount) {
@@ -115,13 +115,13 @@ static inline off_t safewrite(CFD_t *cfd, void * vbuf, size_t amount) {
switch (cfd->cpioIoType) {
default:
#ifdef PARANOID
- fprintf(stderr, "\tsafewrite(%p,%p,%x)\n", cfd, vbuf, amount);
+ fprintf(stderr, "\tsafewrite(%p,%p,%x)\n", cfd, vbuf, (unsigned)amount);
exit(1);
break;
#endif
case cpioIoTypeDebug:
nb = amount;
- fprintf(stderr, "\tsafewrite(%p,%p,%x)\n", cfd, vbuf, amount);
+ fprintf(stderr, "\tsafewrite(%p,%p,%x)\n", cfd, vbuf, (unsigned)amount);
break;
case cpioIoTypeFd:
nb = write(cfd->cpioFd, buf, amount);
diff --git a/lib/dbindex.h b/lib/dbindex.h
index d1e6eb8c8..30004a184 100644
--- a/lib/dbindex.h
+++ b/lib/dbindex.h
@@ -19,7 +19,7 @@ typedef struct {
int count;
} dbiIndexSet;
-typedef struct {
+typedef /*@abstract@*/ struct {
DB * db;
char * indexname;
} dbiIndex;
diff --git a/lib/depends.c b/lib/depends.c
index bab5b1b71..f95edc362 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -247,7 +247,7 @@ void rpmdepUpgradePackage(rpmDependencies rpmdep, Header h, void * key) {
alAddPackage(&rpmdep->addedPackages, h, key);
- if (!rpmdep->db) return;
+ if (rpmdep->db == NULL) return;
headerGetEntry(h, RPMTAG_NAME, NULL, (void *) &name, &count);
@@ -368,7 +368,7 @@ int rpmdepCheck(rpmDependencies rpmdep,
/* now look at the removed packages and make sure they aren't critical */
for (i = 0; i < rpmdep->numRemovedPackages; i++) {
h = rpmdbGetRecord(rpmdep->db, rpmdep->removedPackages[i]);
- if (!h) {
+ if (h == NULL) {
rpmError(RPMERR_DBCORRUPT,
_("cannot read header at %d for dependency check"),
rpmdep->removedPackages[i]);
@@ -453,7 +453,7 @@ static int unsatisfiedDepend(rpmDependencies rpmdep, char * reqName,
reqFlags))
return 0;
- if (rpmdep->db) {
+ if (rpmdep->db != NULL) {
if (*reqName == '/') {
/* reqFlags better be 0! */
if (!rpmdbFindByFile(rpmdep->db, reqName, &matches)) {
@@ -523,7 +523,7 @@ static int checkPackageSet(rpmDependencies rpmdep, struct problemsSet * psp,
continue;
h = rpmdbGetRecord(rpmdep->db, matches->recs[i].recOffset);
- if (!h) {
+ if (h == NULL) {
rpmError(RPMERR_DBCORRUPT,
_("cannot read header at %d for dependency check"),
rpmdep->removedPackages[i]);
@@ -561,7 +561,7 @@ static int checkDependentConflicts(rpmDependencies rpmdep,
dbiIndexSet matches;
int rc;
- if (!rpmdep->db) return 0;
+ if (rpmdep->db == NULL) return 0;
if (rpmdbFindByConflicts(rpmdep->db, package, &matches)) {
return 0;
@@ -759,7 +759,7 @@ static int dbrecMatchesDepFlags(rpmDependencies rpmdep, int recOffset,
int rc;
h = rpmdbGetRecord(rpmdep->db, recOffset);
- if (!h) {
+ if (h == NULL) {
rpmMessage(RPMMESS_DEBUG, _("dbrecMatchesDepFlags() failed to read header"));
return 0;
}
diff --git a/lib/falloc.c b/lib/falloc.c
index 47628d49a..a73bed475 100644
--- a/lib/falloc.c
+++ b/lib/falloc.c
@@ -65,7 +65,7 @@ faFile faOpen(char * path, int flags, int perms) {
fas.fileSize = sizeof(newHdr);
}
else {
- lseek(fas.fd, 0, SEEK_SET);
+ (void)lseek(fas.fd, 0, SEEK_SET);
if (read(fas.fd, &newHdr, sizeof(newHdr)) != sizeof(newHdr)) {
close(fas.fd);
return NULL;
@@ -124,7 +124,7 @@ unsigned int faAlloc(faFile fa, unsigned int size) { /* returns 0 on failure */
if (read(fa->fd, &header, sizeof(header)) != sizeof(header)) return 0;
if (!header.isFree) {
- fprintf(stderr, _("free list corrupt (%d)- contact "
+ fprintf(stderr, _("free list corrupt (%u)- contact "
"support@redhat.com\n"), nextFreeBlock);
exit(1);
}
@@ -229,28 +229,28 @@ unsigned int faAlloc(faFile fa, unsigned int size) { /* returns 0 on failure */
if (updateHeader) {
faHeader.firstFree = newBlockOffset;
fa->firstFree = newBlockOffset;
- lseek(fa->fd, 0, SEEK_SET);
- write(fa->fd, &faHeader, sizeof(faHeader));
+ (void)lseek(fa->fd, 0, SEEK_SET);
+ (void)write(fa->fd, &faHeader, sizeof(faHeader));
}
if (restorePrevHeader) {
- lseek(fa->fd, header.freePrev, SEEK_SET);
- write(fa->fd, restorePrevHeader, sizeof(*restorePrevHeader));
+ (void)lseek(fa->fd, header.freePrev, SEEK_SET);
+ (void)write(fa->fd, restorePrevHeader, sizeof(*restorePrevHeader));
}
if (restoreNextHeader) {
- lseek(fa->fd, header.freeNext, SEEK_SET);
- write(fa->fd, restoreNextHeader, sizeof(*restoreNextHeader));
+ (void)lseek(fa->fd, header.freeNext, SEEK_SET);
+ (void)write(fa->fd, restoreNextHeader, sizeof(*restoreNextHeader));
}
if (restoreHeader) {
- lseek(fa->fd, newBlockOffset, SEEK_SET);
- write(fa->fd, restoreHeader, sizeof(header));
+ (void)lseek(fa->fd, newBlockOffset, SEEK_SET);
+ (void)write(fa->fd, restoreHeader, sizeof(header));
}
if (restoreFooter) {
- lseek(fa->fd, footerOffset, SEEK_SET);
- write(fa->fd, restoreFooter, sizeof(footer));
+ (void)lseek(fa->fd, footerOffset, SEEK_SET);
+ (void)write(fa->fd, restoreFooter, sizeof(footer));
}
return 0;
@@ -270,17 +270,17 @@ unsigned int faAlloc(faFile fa, unsigned int size) { /* returns 0 on failure */
header.freePrev = header.freeNext = 0;
/* reserve all space up front */
- lseek(fa->fd, newBlockOffset, SEEK_SET);
+ (void)lseek(fa->fd, newBlockOffset, SEEK_SET);
if (write(fa->fd, space, size) != size) {
return 0;
}
- lseek(fa->fd, newBlockOffset, SEEK_SET);
+ (void)lseek(fa->fd, newBlockOffset, SEEK_SET);
if (write(fa->fd, &header, sizeof(header)) != sizeof(header)) {
return 0;
}
- lseek(fa->fd, footerOffset, SEEK_SET);
+ (void)lseek(fa->fd, footerOffset, SEEK_SET);
if (write(fa->fd, &footer, sizeof(footer)) != sizeof(footer)) {
return 0;
}
@@ -348,11 +348,11 @@ void faFree(faFile fa, unsigned int offset) {
header.freePrev = prevFreeOffset;
footer.isFree = 1;
- lseek(fa->fd, offset, SEEK_SET);
- write(fa->fd, &header, sizeof(header));
+ (void)lseek(fa->fd, offset, SEEK_SET);
+ (void)write(fa->fd, &header, sizeof(header));
- lseek(fa->fd, footerOffset, SEEK_SET);
- write(fa->fd, &footer, sizeof(footer));
+ (void)lseek(fa->fd, footerOffset, SEEK_SET);
+ (void)write(fa->fd, &footer, sizeof(footer));
if (nextFreeOffset) {
nextFreeHeader.freePrev = offset;
@@ -364,7 +364,7 @@ void faFree(faFile fa, unsigned int offset) {
if (prevFreeOffset) {
prevFreeHeader.freeNext = offset;
if (lseek(fa->fd, prevFreeOffset, SEEK_SET) < 0) return;
- write(fa->fd, &prevFreeHeader, sizeof(prevFreeHeader));
+ (void)write(fa->fd, &prevFreeHeader, sizeof(prevFreeHeader));
} else {
fa->firstFree = offset;
@@ -372,7 +372,7 @@ void faFree(faFile fa, unsigned int offset) {
faHeader.firstFree = fa->firstFree;
if (lseek(fa->fd, 0, SEEK_SET) < 0) return;
- write(fa->fd, &faHeader, sizeof(faHeader));
+ (void)write(fa->fd, &faHeader, sizeof(faHeader));
}
}
@@ -381,6 +381,18 @@ void faClose(faFile fa) {
free(fa);
}
+int faFcntl(faFile fa, int op, void *lip) {
+ return fcntl(fa->fd, op, lip);
+}
+
+int faLseek(faFile fa, off_t off, int op) {
+ return lseek(fa->fd, off, op);
+}
+
+int faFileno(faFile fa) {
+ return fa->fd;
+}
+
int faFirstOffset(faFile fa) {
return faNextOffset(fa, 0);
}
@@ -397,7 +409,7 @@ int faNextOffset(faFile fa, unsigned int lastOffset) {
if (offset >= fa->fileSize) return 0;
- lseek(fa->fd, offset, SEEK_SET);
+ (void)lseek(fa->fd, offset, SEEK_SET);
if (read(fa->fd, &header, sizeof(header)) != sizeof(header)) {
return 0;
}
@@ -406,7 +418,7 @@ int faNextOffset(faFile fa, unsigned int lastOffset) {
do {
offset += header.size;
- lseek(fa->fd, offset, SEEK_SET);
+ (void)lseek(fa->fd, offset, SEEK_SET);
if (read(fa->fd, &header, sizeof(header)) != sizeof(header)) {
return 0;
}
diff --git a/lib/falloc.h b/lib/falloc.h
index 96b06d13f..3a9a9a990 100644
--- a/lib/falloc.h
+++ b/lib/falloc.h
@@ -5,15 +5,17 @@
are compacted. Minimal fragmentation is more important then speed. This
uses 32 bit offsets on all platforms and should be byte order independent */
-typedef struct faFile_s {
+typedef /*@abstract@*/ struct faFile_s {
int fd;
int readOnly;
unsigned int firstFree;
unsigned long fileSize;
} * faFile;
+#ifdef UNUSED
struct FaPlace_s;
typedef struct FaPlace * faPlace;
+#endif
/* flags here is the same as for open(2) - NULL returned on error */
faFile faOpen(char * path, int flags, int perms);
@@ -21,6 +23,10 @@ unsigned int faAlloc(faFile fa, unsigned int size); /* returns 0 on failure */
void faFree(faFile fa, unsigned int offset);
void faClose(faFile fa);
+int faFcntl(faFile fa, int op, void *lip);
+int faLseek(faFile fa, off_t off, int op);
+int faFileno(faFile);
+
int faFirstOffset(faFile fa);
int faNextOffset(faFile fa, unsigned int lastOffset); /* 0 at end */
diff --git a/lib/header.c b/lib/header.c
index 4050f5f42..0cb4507d2 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -260,12 +260,12 @@ void headerWrite(int fd, Header h, int magicp)
p = doHeaderUnload(h, &length);
if (magicp) {
- write(fd, header_magic, sizeof(header_magic));
+ (void)write(fd, header_magic, sizeof(header_magic));
l = htonl(0);
- write(fd, &l, sizeof(l));
+ (void)write(fd, &l, sizeof(l));
}
- write(fd, p, length);
+ (void)write(fd, p, length);
free(p);
}
@@ -594,7 +594,7 @@ void headerDump(Header h, FILE *f, int flags,
tag = tage->name;
fprintf(f, "Entry : %.3d (%d)%-14s %-18s 0x%.8x %.8d\n", i,
- p->info.tag, tag, type, (uint_32) p->info.offset, (uint_32)
+ p->info.tag, tag, type, (unsigned) p->info.offset, (int)
p->info.count);
if (flags & HEADER_DUMP_INLINE) {
@@ -606,8 +606,8 @@ void headerDump(Header h, FILE *f, int flags,
case RPM_INT32_TYPE:
while (c--) {
fprintf(f, " Data: %.3d 0x%08x (%d)\n", ct++,
- (uint_32) *((int_32 *) dp),
- (uint_32) *((int_32 *) dp));
+ (unsigned) *((int_32 *) dp),
+ (int) *((int_32 *) dp));
dp += sizeof(int_32);
}
break;
@@ -615,16 +615,16 @@ void headerDump(Header h, FILE *f, int flags,
case RPM_INT16_TYPE:
while (c--) {
fprintf(f, " Data: %.3d 0x%04x (%d)\n", ct++,
- (short int) *((int_16 *) dp),
- (short int) *((int_16 *) dp));
+ (unsigned) *((int_16 *) dp),
+ (int) *((int_16 *) dp));
dp += sizeof(int_16);
}
break;
case RPM_INT8_TYPE:
while (c--) {
fprintf(f, " Data: %.3d 0x%02x (%d)\n", ct++,
- (char) *((int_8 *) dp),
- (char) *((int_8 *) dp));
+ (unsigned) *((int_8 *) dp),
+ (int) *((int_8 *) dp));
dp += sizeof(int_8);
}
break;
@@ -632,7 +632,7 @@ void headerDump(Header h, FILE *f, int flags,
while (c > 0) {
fprintf(f, " Data: %.3d ", ct);
while (c--) {
- fprintf(f, "%02x ", (unsigned char) *(int_8 *)dp);
+ fprintf(f, "%02x ", (unsigned) *(int_8 *)dp);
ct++;
dp += sizeof(int_8);
if (! (ct % 8)) {
@@ -646,7 +646,7 @@ void headerDump(Header h, FILE *f, int flags,
while (c--) {
ch = (char) *((char *) dp);
fprintf(f, " Data: %.3d 0x%2x %c (%d)\n", ct++,
- ch,
+ (unsigned)ch,
(isprint(ch) ? ch : ' '),
(char) *((char *) dp));
dp += sizeof(char);
@@ -1985,7 +1985,7 @@ static char * realDateFormat(int_32 type, const void * data,
/* this is important if sizeof(int_32) ! sizeof(time_t) */
dateint = *((int_32 *) data);
tstruct = localtime(&dateint);
- strftime(buf, sizeof(buf) - 1, strftimeFormat, tstruct);
+ (void)strftime(buf, sizeof(buf) - 1, strftimeFormat, tstruct);
sprintf(val, formatPrefix, buf);
}
diff --git a/lib/header.h b/lib/header.h
index 788db6399..a1333236d 100644
--- a/lib/header.h
+++ b/lib/header.h
@@ -34,8 +34,8 @@ typedef unsigned int uint_32;
typedef unsigned short uint_16;
#endif
-typedef struct headerToken *Header;
-typedef struct headerIteratorS *HeaderIterator;
+typedef /*@abstract@*/ struct headerToken *Header;
+typedef /*@abstract@*/ struct headerIteratorS *HeaderIterator;
struct headerTagTableEntry {
char * name;
diff --git a/lib/install.c b/lib/install.c
index df2b0a62c..cfe08da26 100644
--- a/lib/install.c
+++ b/lib/install.c
@@ -111,7 +111,7 @@ int rpmInstallSourcePackage(char * rootdir, int fd, char ** specFile,
}
rc = installSources(h, rootdir, fd, specFile, notify, labelFormat);
- if (h) headerFree(h);
+ if (h != NULL) headerFree(h);
return rc;
}
@@ -464,7 +464,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd,
if (flags & RPMINSTALL_JUSTDB) return 0;
rc = installSources(h, rootdir, fd, NULL, notify, labelFormat);
- if (h) headerFree(h);
+ if (h != NULL) headerFree(h);
return rc;
}
@@ -610,7 +610,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd,
/* this loads all of the name services libraries, in case we
don't have access to them in the chroot() */
- getpwnam("root");
+ (void)getpwnam("root");
endpwent();
chdir("/");
@@ -1044,7 +1044,7 @@ static int packageAlreadyInstalled(rpmdb db, char * name, char * version,
if (!rpmdbFindPackage(db, name, &matches)) {
for (i = 0; i < matches.count; i++) {
sech = rpmdbGetRecord(db, matches.recs[i].recOffset);
- if (!sech) {
+ if (sech == NULL) {
return 1;
}
@@ -1245,7 +1245,7 @@ static int instHandleSharedFiles(rpmdb db, int ignoreOffset,
secOffset = sharedList[i].secRecOffset;
sech = rpmdbGetRecord(db, secOffset);
- if (!sech) {
+ if (sech == NULL) {
rpmError(RPMERR_DBCORRUPT, _("cannot read header at %d for "
"uninstall"), secOffset);
rc = 1;
@@ -1461,7 +1461,7 @@ static int installSources(Header h, char * rootdir, int fd,
}
}
- if (labelFormat && h) {
+ if (labelFormat && h != NULL) {
headerGetEntry(h, RPMTAG_NAME, &type, (void *) &name, &count);
headerGetEntry(h, RPMTAG_VERSION, &type, (void *) &version, &count);
headerGetEntry(h, RPMTAG_RELEASE, &type, (void *) &release, &count);
@@ -1543,7 +1543,7 @@ static int markReplacedFiles(rpmdb db, struct replacedFile * replList) {
for (fileInfo = replList; fileInfo->recOffset; fileInfo++) {
if (secOffset != fileInfo->recOffset) {
- if (secHeader) {
+ if (secHeader != NULL) {
/* ignore errors here - just do the best we can */
rpmdbUpdateRecord(db, secOffset, secHeader);
@@ -1552,7 +1552,7 @@ static int markReplacedFiles(rpmdb db, struct replacedFile * replList) {
secOffset = fileInfo->recOffset;
sh = rpmdbGetRecord(db, secOffset);
- if (!sh) {
+ if (sh == NULL) {
secOffset = 0;
} else {
secHeader = headerCopy(sh); /* so we can modify it */
@@ -1569,7 +1569,7 @@ static int markReplacedFiles(rpmdb db, struct replacedFile * replList) {
secStates[fileInfo->fileNumber] = RPMFILE_STATE_REPLACED;
}
- if (secHeader) {
+ if (secHeader != NULL) {
/* ignore errors here - just do the best we can */
rpmdbUpdateRecord(db, secOffset, secHeader);
@@ -1620,7 +1620,7 @@ static int ensureOlder(rpmdb db, Header new, int dbOffset) {
int result, rc = 0;
old = rpmdbGetRecord(db, dbOffset);
- if (!old) return 1;
+ if (old == NULL) return 1;
result = rpmVersionCompare(old, new);
if (result < 0)
diff --git a/lib/lookup.c b/lib/lookup.c
index a53cb946f..77fa3900e 100644
--- a/lib/lookup.c
+++ b/lib/lookup.c
@@ -79,7 +79,7 @@ static int findMatches(rpmdb db, char * name, char * version, char * release,
for (i = 0; i < matches->count; i++) {
if (matches->recs[i].recOffset) {
h = rpmdbGetRecord(db, matches->recs[i].recOffset);
- if (!h) {
+ if (h == NULL) {
rpmError(RPMERR_DBCORRUPT,
_("cannot read header at %d for lookup"),
matches->recs[i].recOffset);
diff --git a/lib/macro.c b/lib/macro.c
index c8441eb61..2f1eb805a 100644
--- a/lib/macro.c
+++ b/lib/macro.c
@@ -1166,7 +1166,7 @@ initMacros(MacroContext *mc, const char *macrofile)
continue;
n++;
mb->mc = mc; /* XXX just enough to get by */
- doDefine(mb, n, RMIL_MACROFILES, 0);
+ (void)doDefine(mb, n, RMIL_MACROFILES, 0);
}
fclose(fp);
}
diff --git a/lib/md5.h b/lib/md5.h
index bee55716e..4e6f5e0d3 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -31,6 +31,6 @@ int mdbinfileBroken(char *fn, unsigned char *bindigest);
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
*/
-typedef struct MD5Context MD5_CTX;
+typedef /*@abstract@*/ struct MD5Context MD5_CTX;
#endif /* MD5_H */
diff --git a/lib/misc.c b/lib/misc.c
index cdeb01793..1789a9ea6 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -4,6 +4,9 @@
#include "misc.h"
+#ifdef __LCLINT__
+#define VERSION "3.0"
+#endif
char * RPMVERSION = VERSION; /* just to put a marker in librpm.a */
char ** splitString(char * str, int length, char sep) {
diff --git a/lib/oldheader.c b/lib/oldheader.c
index 3682bb169..f6c6fa472 100644
--- a/lib/oldheader.c
+++ b/lib/oldheader.c
@@ -341,8 +341,8 @@ char * oldrpmfileToInfoStr(struct oldrpmFileInfo * fi) {
else
buf = malloc(100);
- sprintf(buf, "%ld %ld %s %o %d %d %s %s %x ", fi->size, fi->mtime,
- fi->md5, fi->mode, fi->uid, fi->gid,
+ sprintf(buf, "%ld %ld %s %o %d %d %s %s %x ", (long)fi->size, (long)fi->mtime,
+ fi->md5, fi->mode, (int)fi->uid, (int)fi->gid,
fi->isconf ? "1" : "0", fi->isdoc ? "1" : "0",
fi->rdev);
diff --git a/lib/package.c b/lib/package.c
index b3589afa8..df356d720 100644
--- a/lib/package.c
+++ b/lib/package.c
@@ -55,7 +55,7 @@ static int readPackageHeaders(int fd, struct rpmlead * leadPtr,
oldLead->archiveOffset = ntohl(oldLead->archiveOffset);
rpmMessage(RPMMESS_DEBUG, _("archive offset is %d\n"),
oldLead->archiveOffset);
- lseek(fd, oldLead->archiveOffset, SEEK_SET);
+ (void)lseek(fd, oldLead->archiveOffset, SEEK_SET);
/* we can't put togeher a header for old format source packages,
there just isn't enough information there. We'll return
@@ -76,8 +76,8 @@ static int readPackageHeaders(int fd, struct rpmlead * leadPtr,
}
*hdr = headerRead(fd, (lead->major >= 3) ?
HEADER_MAGIC_YES : HEADER_MAGIC_NO);
- if (! *hdr) {
- if (sigs) headerFree(*sigs);
+ if (*hdr == NULL) {
+ if (sigs != NULL) headerFree(*sigs);
return 2;
}
@@ -99,7 +99,7 @@ static int readPackageHeaders(int fd, struct rpmlead * leadPtr,
return 2;
}
- if (!hdrPtr) headerFree(*hdr);
+ if (hdrPtr == NULL) headerFree(*hdr);
return 0;
}
@@ -148,7 +148,7 @@ static int readOldHeader(int fd, Header * hdr, int * isSource) {
int i, j;
char ** unames, ** gnames;
- lseek(fd, 0, SEEK_SET);
+ (void)lseek(fd, 0, SEEK_SET);
if (oldhdrReadFromStream(fd, &oldheader)) {
return 1;
}
diff --git a/lib/query.c b/lib/query.c
index 739e01dc8..fddf6237c 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -227,10 +227,10 @@ static void printHeader(Header h, int queryFlags, char * queryFormat) {
"neither file owner or id lists"));
}
- fprintf(stdout, " %s %s %d ",
+ fprintf(stdout, " %s %s %u ",
fileFlagsList[i] & RPMFILE_CONFIG ? "1" : "0",
fileFlagsList[i] & RPMFILE_DOC ? "1" : "0",
- fileRdevList[i]);
+ (unsigned)fileRdevList[i]);
if (strlen(fileLinktoList[i]))
fprintf(stdout, "%s\n", fileLinktoList[i]);
@@ -359,7 +359,7 @@ static void printFileInfo(char * name, unsigned int size, unsigned short mode,
sprintf(groupfield, "%-8d", gid);
/* this is normally right */
- sprintf(sizefield, "%10d", size);
+ sprintf(sizefield, "%10u", size);
/* this knows too much about dev_t */
@@ -368,10 +368,10 @@ static void printFileInfo(char * name, unsigned int size, unsigned short mode,
sprintf(namefield, "%s -> %s", name, linkto);
} else if (S_ISCHR(mode)) {
perms[0] = 'c';
- sprintf(sizefield, "%3d, %3d", rdev >> 8, rdev & 0xFF);
+ sprintf(sizefield, "%3u, %3u", (rdev >> 8) & 0xff, rdev & 0xFF);
} else if (S_ISBLK(mode)) {
perms[0] = 'b';
- sprintf(sizefield, "%3d, %3d", rdev >> 8, rdev & 0xFF);
+ sprintf(sizefield, "%3u, %3u", (rdev >> 8) & 0xff, rdev & 0xFF);
}
/* this is important if sizeof(int_32) ! sizeof(time_t) */
@@ -379,10 +379,10 @@ static void printFileInfo(char * name, unsigned int size, unsigned short mode,
tstruct = localtime(&themtime);
if (tstruct->tm_year == thisYear ||
- ((tstruct->tm_year + 1) == thisYear && tstruct->tm_mon > thisMonth))
- strftime(timefield, sizeof(timefield) - 1, "%b %d %H:%M", tstruct);
+ ((tstruct->tm_year + 1) == thisYear && tstruct->tm_mon > thisMonth))
+ (void)strftime(timefield, sizeof(timefield) - 1, "%b %d %H:%M",tstruct);
else
- strftime(timefield, sizeof(timefield) - 1, "%b %d %Y", tstruct);
+ (void)strftime(timefield, sizeof(timefield) - 1, "%b %d %Y", tstruct);
fprintf(stdout, "%s %8s %8s %10s %s %s\n", perms, ownerfield, groupfield,
sizefield, timefield, namefield);
@@ -399,7 +399,7 @@ static void showMatches(rpmdb db, dbiIndexSet matches, int queryFlags,
matches.recs[i].recOffset);
h = rpmdbGetRecord(db, matches.recs[i].recOffset);
- if (!h) {
+ if (h == NULL) {
fprintf(stderr, _("error: could not read database record\n"));
} else {
printHeader(h, queryFlags, queryFormat);
@@ -458,7 +458,7 @@ int rpmQuery(char * prefix, enum rpmQuerySources source, int queryFlags,
switch (rc) {
case 0:
- if (!h) {
+ if (h == NULL) {
fprintf(stderr, _("old format source packages cannot "
"be queried\n"));
} else {
@@ -484,7 +484,7 @@ int rpmQuery(char * prefix, enum rpmQuerySources source, int queryFlags,
offset = rpmdbFirstRecNum(db);
while (offset) {
h = rpmdbGetRecord(db, offset);
- if (!h) {
+ if (h == NULL) {
fprintf(stderr, _("could not read database record!\n"));
return 1;
}
@@ -583,8 +583,7 @@ int rpmQuery(char * prefix, enum rpmQuerySources source, int queryFlags,
}
rpmMessage(RPMMESS_DEBUG, _("showing package: %d\n"), recNumber);
h = rpmdbGetRecord(db, recNumber);
-
- if (!h) {
+ if (h == NULL) {
fprintf(stderr, _("record %d could not be read\n"), recNumber);
retcode = 1;
} else {
diff --git a/lib/rebuilddb.c b/lib/rebuilddb.c
index 3a066ab4f..ef3c4ec32 100644
--- a/lib/rebuilddb.c
+++ b/lib/rebuilddb.c
@@ -47,7 +47,7 @@ int rpmdbRebuild(char * rootdir) {
recnum = rpmdbFirstRecNum(olddb);
while (recnum > 0) {
- if (!(h = rpmdbGetRecord(olddb, recnum))) {
+ if ((h = rpmdbGetRecord(olddb, recnum)) == NULL) {
rpmError(RPMERR_INTERNAL,
_("record number %d in database is bad -- skipping it"),
recnum);
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index aa7b1296a..331844eb1 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -117,7 +117,7 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode,
if (!justcheck || !exists(filename)) {
db.pkgs = faOpen(filename, mode, 0644);
- if (!db.pkgs) {
+ if (db.pkgs == NULL) {
rpmError(RPMERR_DBOPEN, _("failed to open %s\n"), filename);
return 1;
}
@@ -130,14 +130,14 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode,
if (mode & O_RDWR) {
lockinfo.l_type = F_WRLCK;
- if (fcntl(db.pkgs->fd, F_SETLK, (void *) &lockinfo)) {
+ if (faFcntl(db.pkgs, F_SETLK, (void *) &lockinfo)) {
rpmError(RPMERR_FLOCK, _("cannot get %s lock on database"),
_("exclusive"));
return 1;
}
} else {
lockinfo.l_type = F_RDLCK;
- if (fcntl(db.pkgs->fd, F_SETLK, (void *) &lockinfo)) {
+ if (faFcntl(db.pkgs, F_SETLK, (void *) &lockinfo)) {
rpmError(RPMERR_FLOCK, _("cannot get %s lock on database"),
_("shared"));
return 1;
@@ -189,7 +189,7 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode,
}
void rpmdbClose (rpmdb db) {
- if (db->pkgs) faClose(db->pkgs);
+ if (db->pkgs != NULL) faClose(db->pkgs);
if (db->fileIndex) dbiCloseIndex(db->fileIndex);
if (db->groupIndex) dbiCloseIndex(db->groupIndex);
if (db->nameIndex) dbiCloseIndex(db->nameIndex);
@@ -210,9 +210,9 @@ int rpmdbNextRecNum(rpmdb db, unsigned int lastOffset) {
}
Header rpmdbGetRecord(rpmdb db, unsigned int offset) {
- lseek(db->pkgs->fd, offset, SEEK_SET);
+ (void)faLseek(db->pkgs, offset, SEEK_SET);
- return headerRead(db->pkgs->fd, HEADER_MAGIC_NO);
+ return headerRead(faFileno(db->pkgs), HEADER_MAGIC_NO);
}
int rpmdbFindByFile(rpmdb db, char * filespec, dbiIndexSet * matches) {
@@ -305,7 +305,7 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) {
rec.fileNumber = 0;
h = rpmdbGetRecord(db, offset);
- if (!h) {
+ if (h == NULL) {
rpmError(RPMERR_DBCORRUPT, _("cannot read header at %d for uninstall"),
offset);
return 1;
@@ -468,9 +468,9 @@ int rpmdbAdd(rpmdb db, Header dbentry) {
if (count) free(fileList);
return 1;
}
- lseek(db->pkgs->fd, dboffset, SEEK_SET);
+ (void)faLseek(db->pkgs, dboffset, SEEK_SET);
- headerWrite(db->pkgs->fd, dbentry, HEADER_MAGIC_NO);
+ headerWrite(faFileno(db->pkgs), dbentry, HEADER_MAGIC_NO);
/* Now update the appropriate indexes */
if (addIndexEntry(db->nameIndex, name, dboffset, 0))
@@ -522,7 +522,7 @@ int rpmdbUpdateRecord(rpmdb db, int offset, Header newHeader) {
int oldSize;
oldHeader = rpmdbGetRecord(db, offset);
- if (!oldHeader) {
+ if (oldHeader == NULL) {
rpmError(RPMERR_DBCORRUPT, _("cannot read header at %d for update"),
offset);
return 1;
@@ -541,9 +541,9 @@ int rpmdbUpdateRecord(rpmdb db, int offset, Header newHeader) {
} else {
blockSignals();
- lseek(db->pkgs->fd, offset, SEEK_SET);
+ (void)faLseek(db->pkgs, offset, SEEK_SET);
- headerWrite(db->pkgs->fd, newHeader, HEADER_MAGIC_NO);
+ headerWrite(faFileno(db->pkgs), newHeader, HEADER_MAGIC_NO);
unblockSignals();
}
diff --git a/lib/rpmlib.h b/lib/rpmlib.h
index ba9ad20dd..6fc7b41ba 100644
--- a/lib/rpmlib.h
+++ b/lib/rpmlib.h
@@ -279,7 +279,7 @@ void rpmGetMachine(char **arch, char **os);
/** **/
-typedef struct rpmdb_s * rpmdb;
+typedef /*@abstract@*/ struct rpmdb_s * rpmdb;
typedef void (*rpmNotifyFunction)(const unsigned long amount,
const unsigned long total);
diff --git a/lib/rpmmacro.h b/lib/rpmmacro.h
index 02ea6f2e0..9642e556f 100644
--- a/lib/rpmmacro.h
+++ b/lib/rpmmacro.h
@@ -1,7 +1,7 @@
#ifndef _H_MACRO_
#define _H_MACRO_
-typedef struct MacroEntry {
+typedef /*@abstract@*/ struct MacroEntry {
struct MacroEntry *prev;
const char *name; /* Macro name */
const char *opts; /* Macro parameters (ala getopt) */
@@ -10,7 +10,7 @@ typedef struct MacroEntry {
int level;
} MacroEntry;
-typedef struct MacroContext {
+typedef /*@abstract@*/ struct MacroContext {
MacroEntry ** macroTable;
int macrosAllocated;
int firstFree;
diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index e21b9e0ec..ccf5c9ae1 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -11,6 +11,11 @@
#include "misc.h"
+#ifdef __LCLINT__
+#define LIBRPMRC_FILENAME "/usr/lib/rpm/rpmrc"
+#define MACROFILES "/usr/lib/rpm/macros"
+#endif
+
static char *usrlibrpmrc = LIBRPMRC_FILENAME;
static char *etcrpmrc = "/etc/rpmrc";
static char *macrofiles = MACROFILES;
diff --git a/lib/signature.c b/lib/signature.c
index b8f4a2931..18a7e749e 100644
--- a/lib/signature.c
+++ b/lib/signature.c
@@ -91,7 +91,7 @@ int rpmReadSignature(int fd, Header *header, short sig_type)
rpmMessage(RPMMESS_DEBUG, _("New Header signature\n"));
/* This is a new style signature */
h = headerRead(fd, HEADER_MAGIC_YES);
- if (! h) {
+ if (h == NULL) {
return 1;
}
sigSize = headerSizeof(h, HEADER_MAGIC_YES);
@@ -137,7 +137,7 @@ int rpmWriteSignature(int fd, Header header)
rpmMessage(RPMMESS_DEBUG, _("Signature size: %d\n"), sigSize);
rpmMessage(RPMMESS_DEBUG, _("Signature pad : %d\n"), pad);
memset(buf, 0, pad);
- write(fd, buf, pad);
+ (void)write(fd, buf, pad);
}
return 0;
}
@@ -216,7 +216,7 @@ static int makePGPSignature(char *file, void **sig, int_32 *size,
fprintf(fpipe, "%s\n", passPhrase);
fclose(fpipe);
- waitpid(pid, &status, 0);
+ (void)waitpid(pid, &status, 0);
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
rpmError(RPMERR_SIGGEN, _("pgp failed"));
return 1;
@@ -362,7 +362,7 @@ static int verifyPGPSignature(char *datafile, void *sig,
/* Write out the signature */
sigfile = tempnam(rpmGetVar(RPMVAR_TMPPATH), "rpmsig");
sfd = open(sigfile, O_WRONLY|O_CREAT|O_TRUNC, 0644);
- write(sfd, sig, count);
+ (void)write(sfd, sig, count);
close(sfd);
/* Now run PGP */
@@ -400,7 +400,7 @@ static int verifyPGPSignature(char *datafile, void *sig,
}
fclose(file);
- waitpid(pid, &status, 0);
+ (void)waitpid(pid, &status, 0);
unlink(sigfile);
if (!res && (!WIFEXITED(status) || WEXITSTATUS(status))) {
res = RPMSIG_BAD;
@@ -473,7 +473,7 @@ static int checkPassPhrase(char *passPhrase)
fprintf(fpipe, "%s\n", passPhrase);
fclose(fpipe);
- waitpid(pid, &status, 0);
+ (void)waitpid(pid, &status, 0);
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
return 1;
}
diff --git a/lib/stringbuf.h b/lib/stringbuf.h
index ea6136f26..2a1c7ae57 100644
--- a/lib/stringbuf.h
+++ b/lib/stringbuf.h
@@ -1,7 +1,7 @@
#ifndef _STRINGBUF_H_
#define _STRINGBUF_H_
-typedef struct StringBufRec *StringBuf;
+typedef /*@abstract@*/ struct StringBufRec *StringBuf;
StringBuf newStringBuf(void);
void freeStringBuf(StringBuf sb);
diff --git a/lib/uninstall.c b/lib/uninstall.c
index 605231559..4e85af0b0 100644
--- a/lib/uninstall.c
+++ b/lib/uninstall.c
@@ -11,14 +11,14 @@
static char * SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:"
"/usr/X11R6/bin";
-enum fileActions { REMOVE, BACKUP, KEEP };
+typedef enum fileActions { REMOVE, BACKUP, KEEP } fileActions_t;
static int sharedFileCmp(const void * one, const void * two);
static int handleSharedFiles(rpmdb db, int offset, char ** fileList,
char ** fileMd5List, int fileCount,
- enum fileActions * fileActions);
+ fileActions_t * fileActions);
static int removeFile(char * file, char state, unsigned int flags, char * md5,
- short mode, enum fileActions action,
+ short mode, fileActions_t action,
int brokenMd5, int test);
static int runScript(Header h, char * root, int progArgc, char ** progArgv,
char * script, int arg1, int arg2, int errfd);
@@ -80,7 +80,7 @@ int findSharedFiles(rpmdb db, int offset, char ** fileList, int fileCount,
static int handleSharedFiles(rpmdb db, int offset, char ** fileList,
char ** fileMd5List, int fileCount,
- enum fileActions * fileActions) {
+ fileActions_t * fileActions) {
Header sech = NULL;
int secOffset = 0;
struct sharedFile * sharedList;
@@ -112,7 +112,7 @@ static int handleSharedFiles(rpmdb db, int offset, char ** fileList,
secOffset = sharedList[i].secRecOffset;
sech = rpmdbGetRecord(db, secOffset);
- if (!sech) {
+ if (sech == NULL) {
rpmError(RPMERR_DBCORRUPT,
_("cannot read header at %d for uninstall"), offset);
rc = 1;
@@ -206,14 +206,14 @@ int rpmRemovePackage(char * prefix, rpmdb db, unsigned int offset, int flags) {
uint_32 * fileFlagsList;
int_16 * fileModesList;
char * fileStatesList;
- enum { REMOVE, BACKUP, KEEP } * fileActions;
+ fileActions_t * fileActions;
int scriptArg;
if (flags & RPMUNINSTALL_JUSTDB)
flags |= RPMUNINSTALL_NOSCRIPTS;
h = rpmdbGetRecord(db, offset);
- if (!h) {
+ if (h == NULL) {
rpmError(RPMERR_DBCORRUPT, _("cannot read header at %d for uninstall"),
offset);
return 1;
@@ -420,9 +420,9 @@ static int runScript(Header h, char * root, int progArgc, char ** progArgv,
if (rpmIsDebug() &&
(!strcmp(argv[0], "/bin/sh") || !strcmp(argv[0], "/bin/bash")))
- write(fd, "set -x\n", 7);
+ (void)write(fd, "set -x\n", 7);
- write(fd, script, strlen(script));
+ (void)write(fd, script, strlen(script));
close(fd);
argv[argc++] = fn + strlen(root);
@@ -487,7 +487,7 @@ static int runScript(Header h, char * root, int progArgc, char ** progArgv,
_exit(-1);
}
- waitpid(child, &status, 0);
+ (void)waitpid(child, &status, 0);
if (freePrefixes) free(prefixes);
@@ -539,7 +539,7 @@ int runInstScript(char * root, Header h, int scriptTag, int progTag,
}
static int removeFile(char * file, char state, unsigned int flags, char * md5,
- short mode, enum fileActions action,
+ short mode, fileActions_t action,
int brokenMd5, int test) {
char currentMd5[40];
int rc = 0;
@@ -729,7 +729,7 @@ int runTriggers(char * root, rpmdb db, int sense, Header h,
rc = 0;
for (i = 0; i < matches.count; i++) {
- if (!(triggeredH = rpmdbGetRecord(db, matches.recs[i].recOffset)))
+ if ((triggeredH = rpmdbGetRecord(db, matches.recs[i].recOffset)) == NULL)
return 1;
rc |= handleOneTrigger(root, db, sense, h, triggeredH, 0, numPackage,
@@ -772,7 +772,7 @@ int runImmedTriggers(char * root, rpmdb db, int sense, Header h,
}
for (j = 0; j < matches.count; j++) {
- if (!(sourceH = rpmdbGetRecord(db, matches.recs[j].recOffset)))
+ if ((sourceH = rpmdbGetRecord(db, matches.recs[j].recOffset)) == NULL)
return 1;
rc |= handleOneTrigger(root, db, sense, sourceH, h,
countCorrection, matches.count, triggersRun);
diff --git a/rpm.c b/rpm.c
index e9ed95fd2..ccc03a7e1 100755
--- a/rpm.c
+++ b/rpm.c
@@ -9,6 +9,12 @@
#include "popt/popt.h"
#include "verify.h"
+#ifdef __LCLINT__
+#define VERSION "3.0"
+#define LIBRPMALIAS_FILENAME "/usr/lib/rpm/rpmpopt"
+#define RPMCONFIGDIR "/usr/lib/rpm"
+#endif
+
#define GETOPT_REBUILD 1003
#define GETOPT_RECOMPILE 1004
#define GETOPT_ADDSIGN 1005
@@ -556,7 +562,7 @@ int main(int argc, char ** argv) {
rpm_version = 0;
/* set up the correct locale */
- setlocale(LC_ALL, "" );
+ (void)setlocale(LC_ALL, "" );
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@@ -696,7 +702,7 @@ int main(int argc, char ** argv) {
if (bigMode == MODE_QUERY)
poptStuffArgs(optCon, infoCommand);
else if (bigMode == MODE_INSTALL)
- /* ignore it */ ;
+ /*@-ifempty@*/ ;
else if (bigMode == MODE_UNKNOWN)
poptStuffArgs(optCon, installCommand);
break;
@@ -1317,7 +1323,7 @@ int main(int argc, char ** argv) {
if (pipeChild) {
fclose(stdout);
- waitpid(pipeChild, &status, 0);
+ (void)waitpid(pipeChild, &status, 0);
}
/* keeps memory leak checkers quiet */
diff --git a/rpmio/macro.c b/rpmio/macro.c
index c8441eb61..2f1eb805a 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -1166,7 +1166,7 @@ initMacros(MacroContext *mc, const char *macrofile)
continue;
n++;
mb->mc = mc; /* XXX just enough to get by */
- doDefine(mb, n, RMIL_MACROFILES, 0);
+ (void)doDefine(mb, n, RMIL_MACROFILES, 0);
}
fclose(fp);
}
diff --git a/rpmio/rpmmacro.h b/rpmio/rpmmacro.h
index 02ea6f2e0..9642e556f 100644
--- a/rpmio/rpmmacro.h
+++ b/rpmio/rpmmacro.h
@@ -1,7 +1,7 @@
#ifndef _H_MACRO_
#define _H_MACRO_
-typedef struct MacroEntry {
+typedef /*@abstract@*/ struct MacroEntry {
struct MacroEntry *prev;
const char *name; /* Macro name */
const char *opts; /* Macro parameters (ala getopt) */
@@ -10,7 +10,7 @@ typedef struct MacroEntry {
int level;
} MacroEntry;
-typedef struct MacroContext {
+typedef /*@abstract@*/ struct MacroContext {
MacroEntry ** macroTable;
int macrosAllocated;
int firstFree;
diff --git a/verify.c b/verify.c
index 1f798d2f0..a2405c0fe 100644
--- a/verify.c
+++ b/verify.c
@@ -132,7 +132,7 @@ static int verifyMatches(char * prefix, rpmdb db, dbiIndexSet matches,
matches.recs[i].recOffset);
h = rpmdbGetRecord(db, matches.recs[i].recOffset);
- if (!h) {
+ if (h == NULL) {
fprintf(stderr, _("error: could not read database record\n"));
ec = 1;
} else {
@@ -172,7 +172,7 @@ int doVerify(char * prefix, enum verifysources source, char ** argv,
offset != 0;
offset = rpmdbNextRecNum(db, offset)) {
h = rpmdbGetRecord(db, offset);
- if (!h) {
+ if (h == NULL) {
fprintf(stderr, _("could not read database record!\n"));
return 1; /* XXX was exit(1) */
}