summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2004-02-26 01:20:52 +0000
committerjbj <devnull@localhost>2004-02-26 01:20:52 +0000
commit99825287bd2f7c1bd663194cf67d639de6ca31ec (patch)
treebb4deb7cde1352e289a70f7c0e529f8370951758
parent55eec2cbdcbff3248cb8c6de9e2860820ab430a7 (diff)
downloadlibrpm-tizen-99825287bd2f7c1bd663194cf67d639de6ca31ec.tar.gz
librpm-tizen-99825287bd2f7c1bd663194cf67d639de6ca31ec.tar.bz2
librpm-tizen-99825287bd2f7c1bd663194cf67d639de6ca31ec.zip
splint fiddles.
CVS patchset: 7134 CVS date: 2004/02/26 01:20:52
-rw-r--r--CHANGES1
-rw-r--r--build/files.c4
-rw-r--r--lib/fsm.c2
-rw-r--r--lib/rpmlock.c44
-rw-r--r--lib/rpmlock.h9
-rw-r--r--lib/rpmsx.c2
-rw-r--r--lib/transaction.c7
-rw-r--r--popt/popthelp.c15
-rw-r--r--rpm.spec.in3
9 files changed, 62 insertions, 25 deletions
diff --git a/CHANGES b/CHANGES
index 418544329..68c86d92d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,7 @@
- stable sort for policy specifications, patterns before paths.
- set "rpm_script_t" exec type for scriptlets iff /bin/sh, else default.
- force FD_CLOEXEC on 1st 100 inherited fdno's.
+ - serialize rpmtsRun() using fcntl on /var/lock/rpm/transaction.
4.2.1 -> 4.2.2:
- unify signal handling in librpmio, use condvar to deliver signal.
diff --git a/build/files.c b/build/files.c
index 168b5ae4a..70bd75232 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1767,12 +1767,13 @@ static int processMetadataFile(Package pkg, FileList fl, const char * fileURL,
} else
fn = rpmGenPath(buildURL, NULL, fn);
+/*@-branchstate@*/
switch (tag) {
default:
rpmError(RPMERR_BADSPEC, _("%s: can't load unknown tag (%d).\n"),
fn, tag);
goto exit;
- /*@notreached@*/
+ /*@notreached@*/ break;
case RPMTAG_PUBKEYS:
if ((rc = pgpReadPkts(fn, &pkt, &pktlen)) <= 0) {
rpmError(RPMERR_BADSPEC, _("%s: public key read failed.\n"), fn);
@@ -1793,6 +1794,7 @@ static int processMetadataFile(Package pkg, FileList fl, const char * fileURL,
pkt = NULL;
break;
}
+/*@=branchstate@*/
xx = headerAddOrAppendEntry(pkg->header, tag,
RPM_STRING_ARRAY_TYPE, &apkt, 1);
diff --git a/lib/fsm.c b/lib/fsm.c
index f720e2252..48bce305c 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1274,7 +1274,9 @@ static int fsmMkdirs(/*@special@*/ /*@partial@*/ FSM_t fsm)
int dc = dnlCount(dnli);
int rc = 0;
int i;
+/*@-compdef@*/
rpmts ts = fsmGetTs(fsm);
+/*@=compdef@*/
rpmsx sx = rpmtsREContext(ts);
fsm->path = NULL;
diff --git a/lib/rpmlock.c b/lib/rpmlock.c
index 031a531fe..0ac8703f4 100644
--- a/lib/rpmlock.c
+++ b/lib/rpmlock.c
@@ -26,22 +26,27 @@ enum {
typedef struct {
int fd;
int openmode;
-} rpmlock;
+} * rpmlock;
-static rpmlock *rpmlock_new(const char *rootdir)
+/*@null@*/
+static rpmlock rpmlock_new(const char *rootdir)
+ /*@globals fileSystem @*/
+ /*@modifies fileSystem @*/
{
- rpmlock *lock = (rpmlock *)malloc(sizeof(rpmlock));
+ rpmlock lock = (rpmlock) malloc(sizeof(*lock));
if (lock) {
mode_t oldmask = umask(022);
char *path = (char *)malloc(strlen(rootdir)+
- strlen(RPMLOCK_FILE)+2);
+ sizeof(RPMLOCK_FILE)+1);
if (!path) {
free(lock);
return NULL;
}
sprintf(path, "%s/%s", rootdir, RPMLOCK_FILE);
lock->fd = open(RPMLOCK_FILE, O_RDWR|O_CREAT, 0644);
- umask(oldmask);
+ (void) umask(oldmask);
+
+/*@-branchstate@*/
if (lock->fd == -1) {
lock->fd = open(RPMLOCK_FILE, O_RDONLY);
if (lock->fd == -1) {
@@ -53,19 +58,25 @@ static rpmlock *rpmlock_new(const char *rootdir)
} else {
lock->openmode = RPMLOCK_WRITE | RPMLOCK_READ;
}
+/*@=branchstate@*/
}
+/*@-compdef@*/
return lock;
+/*@=compdef@*/
}
-static void rpmlock_free(rpmlock *lock)
+static void rpmlock_free(/*@only@*/ /*@null@*/ rpmlock lock)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies lock, fileSystem, internalState @*/
{
if (lock) {
- close(lock->fd);
+ (void) close(lock->fd);
free(lock);
}
}
-static int rpmlock_acquire(rpmlock *lock, int mode)
+static int rpmlock_acquire(/*@null@*/ rpmlock lock, int mode)
+ /*@*/
{
int res = 0;
if (lock && (mode & lock->openmode)) {
@@ -82,13 +93,16 @@ static int rpmlock_acquire(rpmlock *lock, int mode)
info.l_whence = SEEK_SET;
info.l_start = 0;
info.l_len = 0;
+ info.l_pid = 0;
if (fcntl(lock->fd, cmd, &info) != -1)
res = 1;
}
return res;
}
-static void rpmlock_release(rpmlock *lock)
+static void rpmlock_release(/*@null@*/ rpmlock lock)
+ /*@globals internalState @*/
+ /*@modifies internalState @*/
{
if (lock) {
struct flock info;
@@ -96,7 +110,8 @@ static void rpmlock_release(rpmlock *lock)
info.l_whence = SEEK_SET;
info.l_start = 0;
info.l_len = 0;
- fcntl(lock->fd, F_SETLK, &info);
+ info.l_pid = 0;
+ (void) fcntl(lock->fd, F_SETLK, &info);
}
}
@@ -106,10 +121,12 @@ static void rpmlock_release(rpmlock *lock)
void *rpmtsAcquireLock(rpmts ts)
{
const char *rootDir = rpmtsRootDir(ts);
- rpmlock *lock;
+ rpmlock lock;
+
if (!rootDir)
rootDir = "/";
lock = rpmlock_new(rootDir);
+/*@-branchstate@*/
if (!lock) {
rpmMessage(RPMMESS_ERROR, _("can't create transaction lock\n"));
} else if (!rpmlock_acquire(lock, RPMLOCK_WRITE)) {
@@ -123,13 +140,14 @@ void *rpmtsAcquireLock(rpmts ts)
lock = NULL;
}
}
+/*@=branchstate@*/
return lock;
}
void rpmtsFreeLock(void *lock)
{
- rpmlock_release((rpmlock *)lock); /* Not really needed here. */
- rpmlock_free((rpmlock *)lock);
+ rpmlock_release((rpmlock)lock); /* Not really needed here. */
+ rpmlock_free((rpmlock)lock);
}
diff --git a/lib/rpmlock.h b/lib/rpmlock.h
index cfd84f764..c36566fb3 100644
--- a/lib/rpmlock.h
+++ b/lib/rpmlock.h
@@ -1,7 +1,12 @@
#ifndef RPMLOCK_H
#define RPMLOCK_H
-void *rpmtsAcquireLock(rpmts ts);
-void rpmtsFreeLock(void *lock);
+/*@only@*/ /*@null@*/
+void * rpmtsAcquireLock(rpmts ts)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/;
+void rpmtsFreeLock(/*@only@*/ /*@null@*/ void *lock)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies lock, fileSystem, internalState @*/;
#endif
diff --git a/lib/rpmsx.c b/lib/rpmsx.c
index f45b7f80a..3da2411a5 100644
--- a/lib/rpmsx.c
+++ b/lib/rpmsx.c
@@ -26,7 +26,7 @@ static void rpmsxSort(rpmsx sx)
int i, j;
/* Stable sort for policy regex's and paths. */
- sxp = xmalloc(sizeof(*sxp) * sx->Count);
+ sxp = xcalloc(sx->Count, sizeof(*sxp));
/* Regex patterns first ... */
j = 0;
diff --git a/lib/transaction.c b/lib/transaction.c
index 4bf848637..0b2f06c38 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -953,15 +953,16 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
rpmtsi qi; rpmte q;
int numAdded;
int numRemoved;
+ void * lock;
int xx;
/* XXX programmer error segfault avoidance. */
if (rpmtsNElements(ts) <= 0)
return -1;
- void *lock = rpmtsAcquireLock(ts);
- if (!lock)
- return -1;
+ lock = rpmtsAcquireLock(ts);
+ if (lock == NULL)
+ return -1; /* XXX W2DO? */
if (rpmtsFlags(ts) & RPMTRANS_FLAG_NOSCRIPTS)
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransScripts | _noTransTriggers));
diff --git a/popt/popthelp.c b/popt/popthelp.c
index 872ea7979..5f10a5f05 100644
--- a/popt/popthelp.c
+++ b/popt/popthelp.c
@@ -13,6 +13,7 @@
#define POPT_WCHAR_HACK
#ifdef POPT_WCHAR_HACK
#include <wchar.h> /* for mbsrtowcs */
+/*@access mbstate_t @*/
#endif
#include "poptint.h"
@@ -340,11 +341,11 @@ static void singleOptionHelp(FILE * fp, size_t maxLeftCol,
mbstate_t t;
size_t n;
- memset (&t, '\0', sizeof (t)); /* In initial state. */
+ memset ((void *)&t, '\0', sizeof (t)); /* In initial state. */
/* Determine number of characters. */
n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
- displaypad = (lelen-n);
+ displaypad = (int) (lelen-n);
}
#endif
}
@@ -381,7 +382,7 @@ static void singleOptionHelp(FILE * fp, size_t maxLeftCol,
while (ch > (help + 1) && isspace(*ch)) ch--;
ch++;
- sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
+ sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), (int) indentLength);
/*@-formatconst@*/
fprintf(fp, format, help, " ");
/*@=formatconst@*/
@@ -439,7 +440,9 @@ static size_t maxArgWidth(const struct poptOption * opt,
mbstate_t t;
size_t n;
- memset (&t, '\0', sizeof (t)); /* In initial state. */
+/*@-boundswrite@*/
+ memset ((void *)&t, '\0', sizeof (t)); /* In initial state. */
+/*@=boundswrite@*/
/* Determine number of characters. */
n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
len += sizeof("=")-1 + n;
@@ -613,7 +616,9 @@ static size_t singleOptionUsage(FILE * fp, size_t cursor,
mbstate_t t;
size_t n;
- memset (&t, '\0', sizeof (t)); /* In initial state. */
+/*@-boundswrite@*/
+ memset ((void *)&t, '\0', sizeof (t)); /* In initial state. */
+/*@=boundswrite@*/
/* Determine number of characters. */
n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
len += sizeof("=")-1 + n;
diff --git a/rpm.spec.in b/rpm.spec.in
index 8505a02b9..6e3162fca 100644
--- a/rpm.spec.in
+++ b/rpm.spec.in
@@ -482,6 +482,9 @@ exit 0
%{__includedir}/popt.h
%changelog
+* Wed Feb 25 2004 Jeff Johnson <jbj@jbj.org> 4.3-0.15
+- serialize rpmtsRun() using fcntl on /var/lock/rpm/transaction.
+
* Sun Feb 22 2004 Jeff Johnson <jbj@jbj.org> 4.3-0.14
- add ia32e arch.
- stable sort for policy specifications, patterns before paths.