summaryrefslogtreecommitdiff
path: root/lib
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 /lib
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
Diffstat (limited to 'lib')
-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
5 files changed, 45 insertions, 19 deletions
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));