RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 15-Nov-2007 15:30:26
Branch: HEAD Handle: 2007111514302501
Modified files:
rpm CHANGES
rpm/rpmdb .splintrc header.c header_internal.c
header_internal.h merge.c pkgio.c rpmdb.c sqlite.c
rpm/rpmio rpmpgp.h
Log:
- jbj: first pass through header.c converting to uint32_t everywhere.
Summary:
Revision Changes Path
1.1826 +1 -0 rpm/CHANGES
1.12 +1 -1 rpm/rpmdb/.splintrc
1.120 +132 -127 rpm/rpmdb/header.c
1.15 +10 -10 rpm/rpmdb/header_internal.c
1.30 +9 -9 rpm/rpmdb/header_internal.h
1.11 +8 -8 rpm/rpmdb/merge.c
1.35 +83 -83 rpm/rpmdb/pkgio.c
1.209 +1 -1 rpm/rpmdb/rpmdb.c
1.23 +8 -8 rpm/rpmdb/sqlite.c
2.53 +8 -8 rpm/rpmio/rpmpgp.h
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.1825 -r1.1826 CHANGES
--- rpm/CHANGES 14 Nov 2007 23:56:33 -0000 1.1825
+++ rpm/CHANGES 15 Nov 2007 14:30:25 -0000 1.1826
@@ -1,4 +1,5 @@
5.0a1 -> 5.0a2:
+ - jbj: first pass through header.c converting to uint32_t everywhere.
- jbj: get rid of splint spew before chasing header.c integers.
- jbj: use splint to check integral types, eliminate the easy stuff.
- jbj: splint fiddles for rpmdb.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/.splintrc
============================================================================
$ cvs diff -u -r1.11 -r1.12 .splintrc
--- rpm/rpmdb/.splintrc 14 Nov 2007 23:56:33 -0000 1.11
+++ rpm/rpmdb/.splintrc 15 Nov 2007 14:30:25 -0000 1.12
@@ -62,4 +62,4 @@
-boolops # 136
+boolint # 407
+ignorequals # 165
-+matchanyintegral # 130
++matchanyintegral # 23
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header.c
============================================================================
$ cvs diff -u -r1.119 -r1.120 header.c
--- rpm/rpmdb/header.c 14 Nov 2007 23:56:33 -0000 1.119
+++ rpm/rpmdb/header.c 15 Nov 2007 14:30:25 -0000 1.120
@@ -127,7 +127,7 @@
*/
/*@-redecl@*/
/*@unused@*/ static inline /*@observer@*/
-const char * tagName(int tag)
+const char * tagName(uint32_t tag)
/*@*/
{
/*@-type@*/
@@ -142,7 +142,7 @@
* @return tag data type, 0 on not found.
*/
/*@unused@*/ static inline
-int tagType(int tag)
+uint32_t tagType(uint32_t tag)
/*@*/
{
/*@-type@*/
@@ -331,7 +331,7 @@
/*@-castexpose@*/
indexEntry ap = (indexEntry) avp, bp = (indexEntry) bvp;
/*@=castexpose@*/
- return (ap->info.tag - bp->info.tag);
+ return ((int)ap->info.tag - (int)bp->info.tag);
}
/** \ingroup header
@@ -355,14 +355,14 @@
/*@-castexpose@*/
indexEntry ap = (indexEntry) avp, bp = (indexEntry) bvp;
/*@=castexpose@*/
- int rc = (ap->info.offset - bp->info.offset);
+ int rc = ((int)ap->info.offset - (int)bp->info.offset);
if (rc == 0) {
/* Within a region, entries sort by address. Added drips sort by tag. */
if (ap->info.offset < 0)
rc = (((char *)ap->data) - ((char *)bp->data));
else
- rc = (ap->info.tag - bp->info.tag);
+ rc = ((int)ap->info.tag - (int)bp->info.tag);
}
return rc;
}
@@ -447,15 +447,15 @@
* @param count entry item count
* @param onDisk data is concatenated strings (with NUL's))?
* @param *pend pointer to end of tag container data (or NULL)
- * @return no. bytes in data, -1 on failure
+ * @return no. bytes in data, 0 on failure
*/
-static int dataLength(rpmTagType type, rpmTagData * p, rpmTagCount count,
+static size_t dataLength(rpmTagType type, rpmTagData * p, rpmTagCount count,
int onDisk, /*@null@*/ rpmTagData * pend)
/*@*/
{
const unsigned char * s = (unsigned char *) (*p).ui8p;
const unsigned char * se = (unsigned char *) (pend ? (*pend).ui8p : NULL);
- int length = 0;
+ size_t length = 0;
switch (type) {
case RPM_STRING_TYPE:
@@ -463,7 +463,7 @@
return -1;
while (*s++ != '\0') {
if (se && s > se)
- return -1;
+ return 0;
length++;
}
length++; /* count nul terminator too. */
@@ -477,7 +477,7 @@
length++; /* count nul terminator too */
while (*s++ != '\0') {
if (se && s > se)
- return -1; /* XXX change errret, use size_t */
+ return 0;
length++;
}
}
@@ -491,10 +491,10 @@
break;
default:
if (typeSizes[type] == -1)
- return -1; /* XXX change errret, use size_t */
+ return 0;
length = typeSizes[(type & 0xf)] * count;
- if (length < 0 || (se && (s + length) > se))
- return -1; /* XXX change errret, use size_t */
+ if ((se && (s + length) > se))
+ return 0;
break;
}
@@ -539,7 +539,7 @@
rpmTagData pend;
unsigned char * tprev = NULL;
unsigned char * t = NULL;
- int tdel = 0;
+ size_t tdel = 0;
int tl = dl;
struct indexEntry_s ieprev;
@@ -548,9 +548,9 @@
struct indexEntry_s ie;
rpmTagType type;
- ie.info.tag = ntohl(pe->tag);
- ie.info.type = ntohl(pe->type);
- ie.info.count = ntohl(pe->count);
+ ie.info.tag = (uint32_t) ntohl(pe->tag);
+ ie.info.type = (uint32_t) ntohl(pe->type);
+ ie.info.count = (uint32_t) ntohl(pe->count);
ie.info.offset = ntohl(pe->offset);
if (hdrchkType(ie.info.type))
@@ -571,7 +571,7 @@
/*@-nullstate@*/ /* pend.ui8p derived from dataLength may be null */
ie.length = dataLength(ie.info.type, &p, ie.info.count, 1, &pend);
/*@=nullstate@*/
- if (ie.length < 0 || hdrchkData(ie.length))
+ if (ie.length == 0 || hdrchkData(ie.length))
return -1;
ie.rdlen = 0;
@@ -613,33 +613,33 @@
/* Perform endian conversions */
switch (ntohl(pe->type)) {
case RPM_UINT64_TYPE:
- { int_64 * it = (int_64 *)t;
- int_32 b[2];
+ { uint64_t * it = (uint64_t *)t;
+ uint32_t b[2];
for (; ie.info.count > 0; ie.info.count--, it += 1) {
if (dataEnd && ((unsigned char *)it) >= dataEnd)
return -1;
- b[1] = htonl(((int_32 *)it)[0]);
- b[0] = htonl(((int_32 *)it)[1]);
- if (b[1] != ((int_32 *)it)[0])
+ b[1] = (uint32_t) htonl(((uint32_t *)it)[0]);
+ b[0] = (uint32_t) htonl(((uint32_t *)it)[1]);
+ if (b[1] != ((uint32_t *)it)[0])
memcpy(it, b, sizeof(b));
}
t = (unsigned char *) it;
} /*@switchbreak@*/ break;
case RPM_UINT32_TYPE:
- { int_32 * it = (int_32 *)t;
+ { uint32_t * it = (uint32_t *)t;
for (; ie.info.count > 0; ie.info.count--, it += 1) {
if (dataEnd && ((unsigned char *)it) >= dataEnd)
return -1;
- *it = htonl(*it);
+ *it = (uint32_t) htonl(*it);
}
t = (unsigned char *) it;
} /*@switchbreak@*/ break;
case RPM_UINT16_TYPE:
- { int_16 * it = (int_16 *) t;
+ { uint16_t * it = (uint16_t *) t;
for (; ie.info.count > 0; ie.info.count--, it += 1) {
if (dataEnd && ((unsigned char *)it) >= dataEnd)
return -1;
- *it = htons(*it);
+ *it = (uint16_t) htons(*it);
}
t = (unsigned char *) it;
} /*@switchbreak@*/ break;
@@ -683,14 +683,14 @@
/*@ensures maxRead(result) == (*lenp) @*/
{
void * sw;
- int_32 * ei = NULL;
+ uint32_t * ei = NULL;
entryInfo pe;
unsigned char * dataStart;
unsigned char * te;
unsigned pad;
- unsigned len = 0;
- int_32 il = 0;
- int_32 dl = 0;
+ size_t len = 0;
+ uint32_t il = 0;
+ uint32_t dl = 0;
indexEntry entry;
rpmTagType type;
int i;
@@ -747,7 +747,7 @@
}
/* Ignore deleted drips. */
- if (entry->data == NULL || entry->length <= 0)
+ if (entry->data == NULL || entry->length == 0)
continue;
/* Alignment */
@@ -776,8 +776,8 @@
len = sizeof(il) + sizeof(dl) + (il * sizeof(*pe)) + dl;
ei = xmalloc(len);
- ei[0] = htonl(il);
- ei[1] = htonl(dl);
+ ei[0] = (uint32_t) htonl(il);
+ ei[1] = (uint32_t) htonl(dl);
pe = (entryInfo) &ei[2];
dataStart = te = (unsigned char *) (pe + il);
@@ -786,16 +786,16 @@
for (i = 0, entry = h->index; i < h->indexUsed; i++, entry++) {
const char * src;
unsigned char *t;
- int count;
- int rdlen;
+ uint32_t count;
+ uint32_t rdlen;
- if (entry->data == NULL || entry->length <= 0)
+ if (entry->data == NULL || entry->length == 0)
continue;
t = te;
- pe->tag = htonl(entry->info.tag);
- pe->type = htonl(entry->info.type);
- pe->count = htonl(entry->info.count);
+ pe->tag = (uint32_t) htonl(entry->info.tag);
+ pe->type = (uint32_t) htonl(entry->info.type);
+ pe->count = (uint32_t) htonl(entry->info.count);
if (ENTRY_IS_REGION(entry)) {
int_32 rdl = -entry->info.offset; /* negative offset */
@@ -807,7 +807,7 @@
/* XXX Legacy regions do not include the region tag and data. */
if (i == 0 && (h->flags & HEADERFLAG_LEGACY)) {
- int_32 stei[4];
+ int32_t stei[4]; /* FIXME uint32_t */
legacy = 1;
memcpy(pe+1, src, rdl);
@@ -815,10 +815,10 @@
te += rdlen;
pe->offset = htonl(te - dataStart);
- stei[0] = pe->tag;
- stei[1] = pe->type;
- stei[2] = htonl(-rdl-entry->info.count);
- stei[3] = pe->count;
+ stei[0] = (int32_t) pe->tag;
+ stei[1] = (int32_t) pe->type;
+ stei[2] = (int32_t) htonl(-rdl-entry->info.count);
+ stei[3] = (int32_t) pe->count;
memcpy(te, stei, entry->info.count);
te += entry->info.count;
ril++;
@@ -858,7 +858,7 @@
}
/* Ignore deleted drips. */
- if (entry->data == NULL || entry->length <= 0)
+ if (entry->data == NULL || entry->length == 0)
continue;
/* Alignment */
@@ -878,13 +878,13 @@
/* copy data w/ endian conversions */
switch (entry->info.type) {
case RPM_UINT64_TYPE:
- { int_32 b[2];
+ { uint32_t b[2];
count = entry->info.count;
src = entry->data;
while (count--) {
- b[1] = htonl(((int_32 *)src)[0]);
- b[0] = htonl(((int_32 *)src)[1]);
- if (b[1] == ((int_32 *)src)[0])
+ b[1] = (uint32_t) htonl(((uint32_t *)src)[0]);
+ b[0] = (uint32_t) htonl(((uint32_t *)src)[1]);
+ if (b[1] == ((uint32_t *)src)[0])
memcpy(te, src, sizeof(b));
else
memcpy(te, b, sizeof(b));
@@ -897,10 +897,10 @@
count = entry->info.count;
src = entry->data;
while (count--) {
- *((int_32 *)te) = htonl(*((int_32 *)src));
+ *((uint32_t *)te) = (uint32_t) htonl(*((uint32_t *)src));
/*@-sizeoftype@*/
- te += sizeof(int_32);
- src += sizeof(int_32);
+ te += sizeof(uint32_t);
+ src += sizeof(uint32_t);
/*@=sizeoftype@*/
}
/*@switchbreak@*/ break;
@@ -909,10 +909,10 @@
count = entry->info.count;
src = entry->data;
while (count--) {
- *((int_16 *)te) = htons(*((int_16 *)src));
+ *((uint16_t *)te) = (uint16_t) htons(*((uint16_t *)src));
/*@-sizeoftype@*/
- te += sizeof(int_16);
- src += sizeof(int_16);
+ te += sizeof(uint16_t);
+ src += sizeof(uint16_t);
/*@=sizeoftype@*/
}
/*@switchbreak@*/ break;
@@ -1053,9 +1053,9 @@
/*@modifies uh @*/
{
void * sw = NULL;
- int_32 * ei = (int_32 *) uh;
- int_32 il = ntohl(ei[0]); /* index length */
- int_32 dl = ntohl(ei[1]); /* data length */
+ uint32_t * ei = (uint32_t *) uh;
+ uint32_t il = (uint32_t) ntohl(ei[0]); /* index length */
+ uint32_t dl = (uint32_t) ntohl(ei[1]); /* data length */
/*@-sizeoftype@*/
size_t pvlen = sizeof(il) + sizeof(dl) +
(il * sizeof(struct entryInfo_s)) + dl;
@@ -1073,7 +1073,7 @@
if (hdrchkTags(il) || hdrchkData(dl))
goto errxit;
- ei = (int_32 *) pv;
+ ei = (uint32_t *) pv;
/*@-castexpose@*/
pe = (entryInfo) &ei[2];
/*@=castexpose@*/
@@ -1128,8 +1128,8 @@
h->flags &= ~HEADERFLAG_LEGACY;
- entry->info.type = htonl(pe->type);
- entry->info.count = htonl(pe->count);
+ entry->info.type = (uint32_t) htonl(pe->type);
+ entry->info.count = (uint32_t) htonl(pe->count);
if (hdrchkType(entry->info.type))
goto errxit;
@@ -1144,7 +1144,7 @@
/*@-sizeoftype@*/
size_t nb = REGION_TAG_COUNT;
/*@=sizeoftype@*/
- int_32 * stei = memcpy(alloca(nb), dataStart + off, nb);
+ int32_t * stei = memcpy(alloca(nb), dataStart + off, nb);
rdl = -ntohl(stei[2]); /* negative offset */
ril = rdl/sizeof(*pe);
if (hdrchkTags(ril) || hdrchkData(rdl))
@@ -1337,7 +1337,7 @@
Header nh;
void * uh;
const char * origin = (h->origin != NULL ? xstrdup(h->origin) : NULL);
- int_32 instance = h->instance;
+ uint32_t instance = h->instance;
int xx;
/*@-onlytrans@*/
@@ -1375,9 +1375,9 @@
Header headerCopyLoad(const void * uh)
/*@*/
{
- int_32 * ei = (int_32 *) uh;
- int_32 il = ntohl(ei[0]); /* index length */
- int_32 dl = ntohl(ei[1]); /* data length */
+ uint32_t * ei = (uint32_t *) uh;
+ uint32_t il = (uint32_t) ntohl(ei[0]); /* index length */
+ uint32_t dl = (uint32_t) ntohl(ei[1]); /* data length */
/*@-sizeoftype@*/
size_t pvlen = sizeof(il) + sizeof(dl) +
(il * sizeof(struct entryInfo_s)) + dl;
@@ -1406,12 +1406,12 @@
/*@modifies _fd @*/
{
FD_t fd = _fd;
- int_32 block[4];
- int_32 reserved;
- int_32 * ei = NULL;
- int_32 il;
- int_32 dl;
- int_32 magic;
+ uint32_t block[4];
+ uint32_t reserved;
+ uint32_t * ei = NULL;
+ uint32_t il;
+ uint32_t dl;
+ uint32_t magic;
Header h = NULL;
size_t len;
int i;
@@ -1437,8 +1437,8 @@
reserved = block[i++];
}
- il = ntohl(block[i]); i++;
- dl = ntohl(block[i]); i++;
+ il = (uint32_t) ntohl(block[i]); i++;
+ dl = (uint32_t) ntohl(block[i]); i++;
/*@-sizeoftype@*/
len = sizeof(il) + sizeof(dl) + (il * sizeof(struct entryInfo_s)) + dl;
@@ -1449,8 +1449,8 @@
goto exit;
ei = xmalloc(len);
- ei[0] = htonl(il);
- ei[1] = htonl(dl);
+ ei[0] = (uint32_t) htonl(il);
+ ei[1] = (uint32_t) htonl(dl);
len -= sizeof(il) + sizeof(dl);
/*@-type@*/ /* FIX: cast? */
@@ -1618,7 +1618,7 @@
{ const char ** argv;
size_t nb = count * sizeof(*argv);
char * t;
- int i;
+ unsigned i;
/*@-mods@*/
if (minMem) {
@@ -1630,7 +1630,7 @@
memcpy(t, entry->data, entry->length);
}
/*@=mods@*/
- for (i = 0; i < count; i++) {
+ for (i = 0; i < (unsigned) count; i++) {
argv[i] = t;
t = strchr(t, 0);
t++;
@@ -1758,7 +1758,7 @@
for (l = lang; *l != '\0'; l = le) {
const char *td;
char *ed;
- int langNum;
+ uint32_t langNum;
while (*l && *l == ':') /* skip leading colons */
l++;
@@ -2022,12 +2022,12 @@
*/
/*@null@*/
static void *
-grabData(rpmTagType type, rpmTagData * p, rpmTagCount c, /*@out@*/ int * lenp)
+grabData(rpmTagType type, rpmTagData * p, rpmTagCount c, /*@out@*/size_t * lenp)
/*@modifies *lenp @*/
/*@requires maxSet(lenp) >= 0 @*/
{
rpmTagData data = { .ptr = NULL };
- int length;
+ size_t length;
length = dataLength(type, p, c, 0, NULL);
if (length > 0) {
@@ -2061,7 +2061,7 @@
indexEntry entry;
rpmTagData q = { .ptr = (void *) p };
rpmTagData data;
- int length;
+ size_t length;
/* Count must always be >= 1 for headerAddEntry. */
if (c == 0)
@@ -2074,7 +2074,7 @@
length = 0;
data.ptr = grabData(type, &q, c, &length);
- if (data.ptr == NULL || length <= 0)
+ if (data.ptr == NULL || length == 0)
return 0;
/* Allocate more index space if necessary */
@@ -2119,7 +2119,7 @@
rpmTagData src = { .ptr = (void *) p };
rpmTagData dest = { .ptr = NULL };
indexEntry entry;
- int length;
+ size_t length;
if (type == RPM_STRING_TYPE || type == RPM_I18NSTRING_TYPE) {
/* we can't do this */
@@ -2132,7 +2132,7 @@
return 0;
length = dataLength(type, &src, c, 0, NULL);
- if (length < 0)
+ if (length == 0)
return 0;
if (ENTRY_IN_REGION(entry)) {
@@ -2199,9 +2199,10 @@
{
indexEntry table, entry;
rpmTagData p;
- int length;
- int ghosts;
- int i, langNum;
+ size_t length;
+ size_t ghosts;
+ uint32_t i;
+ uint32_t langNum;
char * buf;
table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE);
@@ -2346,7 +2347,7 @@
rpmTagData q = { .ptr = (void *) p };
rpmTagData oldData;
rpmTagData newData;
- int length;
+ size_t length;
/* First find the tag */
entry = findEntry(h, tag, type);
@@ -2355,7 +2356,7 @@
length = 0;
newData.ptr = grabData(type, &q, c, &length);
- if (newData.ptr == NULL || length <= 0)
+ if (newData.ptr == NULL || length == 0)
return 0;
/* make sure entry points to the first occurence of this tag */
@@ -2441,14 +2442,14 @@
* @return NULL always
*/
static /*@null@*/ sprintfToken
-freeFormat( /*@only@*/ /*@null@*/ sprintfToken format, int num)
+freeFormat( /*@only@*/ /*@null@*/ sprintfToken format, size_t num)
/*@modifies *format @*/
{
- int i;
+ unsigned i;
if (format == NULL) return NULL;
- for (i = 0; i < num; i++) {
+ for (i = 0; i < (unsigned) num; i++) {
switch (format[i].type) {
case PTOK_TAG:
if (_tagcache)
@@ -2619,7 +2620,7 @@
char * val;
size_t vallen;
size_t alloced;
- int numTokens;
+ size_t numTokens;
int i;
} * headerSprintfArgs;
@@ -2732,8 +2733,8 @@
* @return tag name, NULL on not found
*/
/*@observer@*/ /*@null@*/
-static const char * myTagName(headerTagTableEntry tbl, int val,
- /*@null@*/ int *typep)
+static const char * myTagName(headerTagTableEntry tbl, uint32_t val,
+ /*@null@*/ uint32_t *typep)
/*@modifies *typep @*/
{
static char name[128];
@@ -2764,7 +2765,7 @@
* @param name tag name to find
* @return tag value, 0 on not found
*/
-static int myTagValue(headerTagTableEntry tbl, const char * name)
+static uint32_t myTagValue(headerTagTableEntry tbl, const char * name)
/*@*/
{
for (; tbl->name != NULL; tbl++) {
@@ -2851,8 +2852,8 @@
static char * intFormat(HE_t he, const char *fmt)
/*@*/
{
- int ix = (he->ix > 0 ? he->ix : 0);
- int_64 ival = 0;
+ uint32_t ix = (he->ix > 0 ? he->ix : 0);
+ uint64_t ival = 0;
const char * istr = NULL;
char * b;
size_t nb = 0;
@@ -2866,13 +2867,13 @@
return xstrdup(_("(not a number)"));
/*@notreached@*/ break;
case RPM_UINT8_TYPE:
- ival = he->p.ui8p[ix];
+ ival = (uint64_t) he->p.ui8p[ix];
break;
case RPM_UINT16_TYPE:
- ival = he->p.ui16p[ix]; /* XXX note unsigned. */
+ ival = (uint64_t) he->p.ui16p[ix];
break;
case RPM_UINT32_TYPE:
- ival = he->p.ui32p[ix];
+ ival = (uint64_t) he->p.ui32p[ix];
break;
case RPM_UINT64_TYPE:
ival = he->p.ui64p[ix];
@@ -2886,7 +2887,7 @@
case RPM_BIN_TYPE:
{ static char hex[] = "0123456789abcdef";
const char * s = he->p.str;
- int c = he->c;
+ rpmTagCount c = he->c;
char * t;
nb = 2 * c + 1;
@@ -2906,7 +2907,7 @@
} else
if (nb == 0) { /* number */
char myfmt[] = "%llX";
- myfmt[3] = *fmt;
+ myfmt[3] = ((fmt != NULL && *fmt != '\0') ? *fmt : 'd');
nb = 64;
b = alloca(nb);
/*@-formatconst@*/
@@ -3022,7 +3023,7 @@
if (he->t == RPM_UINT32_TYPE) {
nb = 20;
val = xmalloc(nb);
- xx = snprintf(val, nb, "%u", data.ui32p[0]);
+ xx = snprintf(val, nb, "%u", (unsigned) data.ui32p[0]);
val[nb-1] = '\0';
} else if (he->t == RPM_UINT64_TYPE) {
nb = 40;
@@ -3105,7 +3106,8 @@
* @return 0 on success
*/
static int parseFormat(headerSprintfArgs hsa, /*@null@*/ char * str,
- /*@out@*/sprintfToken * formatPtr, /*@out@*/int * numTokensPtr,
+ /*@out@*/ sprintfToken * formatPtr,
+ /*@out@*/ size_t * numTokensPtr,
/*@null@*/ /*@out@*/ char ** endPtr, int state)
/*@modifies hsa, str, *formatPtr, *numTokensPtr, *endPtr @*/
/*@requires maxSet(formatPtr) >= 0 /\ maxSet(numTokensPtr) >= 0
@@ -3114,8 +3116,8 @@
char * chptr, * start, * next, * dst;
sprintfToken format;
sprintfToken token;
- int numTokens;
- int i;
+ size_t numTokens;
+ unsigned i;
int done = 0;
/* upper limit on number of individual formats */
@@ -3128,7 +3130,7 @@
format = xcalloc(numTokens, sizeof(*format));
if (endPtr) *endPtr = NULL;
- /*@-infloops@*/ /* LCL: can't detect done termination */
+/*@-infloops@*/ /* LCL: can't detect done termination */
dst = start = str;
numTokens = 0;
token = NULL;
@@ -3315,12 +3317,12 @@
if (done)
break;
}
- /*@=infloops@*/
+/*@=infloops@*/
if (dst != NULL)
*dst = '\0';
- for (i = 0; i < numTokens; i++) {
+ for (i = 0; i < (unsigned) numTokens; i++) {
token = format + i;
switch(token->type) {
default:
@@ -3331,8 +3333,10 @@
}
}
- *numTokensPtr = numTokens;
- *formatPtr = format;
+ if (numTokensPtr != NULL)
+ *numTokensPtr = numTokens;
+ if (formatPtr != NULL)
+ *formatPtr = format;
return 0;
}
@@ -3468,7 +3472,8 @@
* @return end of formatted string (NULL on error)
*/
/*@observer@*/ /*@null@*/
-static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, int element)
+static char * formatValue(headerSprintfArgs hsa, sprintfTag tag,
+ uint32_t element)
/*@globals headerCompoundFormats @*/
/*@modifies hsa, tag, headerCompoundFormats @*/
{
@@ -3622,18 +3627,18 @@
*/
/*@observer@*/
static char * singleSprintf(headerSprintfArgs hsa, sprintfToken token,
- int element)
+ uint32_t element)
/*@globals headerCompoundFormats @*/
/*@modifies hsa, token, headerCompoundFormats @*/
{
char numbuf[64]; /* XXX big enuf for "Tag_0x01234567" */
char * t, * te;
- int i, j;
- int numElements;
+ uint32_t i, j;
+ uint32_t numElements;
sprintfToken spft;
sprintfTag tag = NULL;
HE_t he = NULL;
- int condNumFormats;
+ uint32_t condNumFormats;
size_t need;
int xx;
@@ -3686,7 +3691,7 @@
break;
case PTOK_ARRAY:
- numElements = -1;
+ numElements = 0;
spft = token->u.array.format;
for (i = 0; i < token->u.array.numTokens; i++, spft++)
{
@@ -3720,7 +3725,7 @@
/* Check iteration arrays are same dimension (or scalar). */
switch (he->t) {
default:
- if (numElements == -1) {
+ if (numElements == 0) {
numElements = he->c;
/*@switchbreak@*/ break;
}
@@ -3733,7 +3738,7 @@
/*@notreached@*/ /*@switchbreak@*/ break;
case RPM_BIN_TYPE:
case RPM_STRING_TYPE:
- if (numElements == -1)
+ if (numElements == 0)
numElements = 1;
/*@switchbreak@*/ break;
}
@@ -3742,7 +3747,7 @@
}
spft = token->u.array.format;
- if (numElements == -1) {
+ if (numElements == 0) {
#ifdef DYING /* XXX lots of pugly "(none)" lines with --conflicts. */
need = sizeof("(none)\n") - 1;
t = hsaReserve(hsa, need);
@@ -3768,7 +3773,7 @@
/* XXX display "Tag_0x01234567" for unknown tags. */
if (tagN == NULL) {
(void) snprintf(numbuf, sizeof(numbuf), "Tag_0x%08x",
- tag->tagno);
+ (unsigned) tag->tagno);
numbuf[sizeof(numbuf)-1] = '\0';
tagN = numbuf;
}
@@ -3778,12 +3783,12 @@
hsa->vallen += (te - t);
}
if (isyaml) {
- int tagT = -1;
+ uint32_t tagT = 0;
const char * tagN = myTagName(hsa->tags, tag->tagno, &tagT);
/* XXX display "Tag_0x01234567" for unknown tags. */
if (tagN == NULL) {
(void) snprintf(numbuf, sizeof(numbuf), "Tag_0x%08x",
- tag->tagno);
+ (unsigned) tag->tagno);
numbuf[sizeof(numbuf)-1] = '\0';
tagN = numbuf;
tagT = numElements > 1
@@ -4018,7 +4023,7 @@
void headerCopyTags(Header headerFrom, Header headerTo, hTAG_t tagstocopy)
/*@modifies headerTo @*/
{
- unsigned int * tagno;
+ uint32_t * tagno;
if (headerFrom == headerTo)
return;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header_internal.c
============================================================================
$ cvs diff -u -r1.14 -r1.15 header_internal.c
--- rpm/rpmdb/header_internal.c 11 Nov 2007 23:59:20 -0000 1.14
+++ rpm/rpmdb/header_internal.c 15 Nov 2007 14:30:25 -0000 1.15
@@ -32,35 +32,35 @@
0
};
-int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate)
+int headerVerifyInfo(uint32_t il, uint32_t dl, const void * pev, void * iv, int negate)
{
/*@-castexpose@*/
entryInfo pe = (entryInfo) pev;
/*@=castexpose@*/
entryInfo info = iv;
- int i;
+ uint32_t i;
for (i = 0; i < il; i++) {
- info->tag = ntohl(pe[i].tag);
- info->type = ntohl(pe[i].type);
+ info->tag = (uint32_t) ntohl(pe[i].tag);
+ info->type = (uint32_t) ntohl(pe[i].type);
/* XXX Convert RPMTAG_FILESTATE to RPM_UINT8_TYPE. */
if (info->tag == 1029 && info->type == 1) {
info->type = RPM_UINT8_TYPE;
- pe[i].type = htonl(info->type);
+ pe[i].type = (uint32_t) htonl(info->type);
}
info->offset = ntohl(pe[i].offset);
if (negate)
info->offset = -info->offset;
- info->count = ntohl(pe[i].count);
+ info->count = (uint32_t) ntohl(pe[i].count);
if (hdrchkType(info->type))
- return i;
+ return (int)i;
if (hdrchkAlign(info->type, info->offset))
- return i;
+ return (int)i;
if (!negate && hdrchkRange(dl, info->offset))
- return i;
+ return (int)i;
if (hdrchkData(info->count))
- return i;
+ return (int)i;
}
return -1;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header_internal.h
============================================================================
$ cvs diff -u -r1.29 -r1.30 header_internal.h
--- rpm/rpmdb/header_internal.h 11 Nov 2007 22:07:46 -0000 1.29
+++ rpm/rpmdb/header_internal.h 15 Nov 2007 14:30:25 -0000 1.30
@@ -53,10 +53,10 @@
*/
typedef /*@abstract@*/ struct entryInfo_s * entryInfo;
struct entryInfo_s {
- int_32 tag; /*!< Tag identifier. */
- int_32 type; /*!< Tag data type. */
+ uint32_t tag; /*!< Tag identifier. */
+ uint32_t type; /*!< Tag data type. */
int_32 offset; /*!< Offset into data segment (ondisk only). */
- int_32 count; /*!< Number of tag elements. */
+ uint32_t count; /*!< Number of tag elements. */
};
#define REGION_TAG_TYPE RPM_BIN_TYPE
@@ -74,7 +74,7 @@
struct entryInfo_s info; /*!< Description of tag data. */
/*@owned@*/
void * data; /*!< Location of tag data. */
- int length; /*!< No. bytes of data. */
+ size_t length; /*!< No. bytes of data. */
int rdlen; /*!< No. bytes of data in region. */
};
@@ -142,20 +142,20 @@
struct {
/*@only@*/
sprintfToken format;
- int numTokens;
+ size_t numTokens;
} array; /*!< PTOK_ARRAY */
struct {
/*@dependent@*/
char * string;
- int len;
+ size_t len;
} string; /*!< PTOK_STRING */
struct {
/*@only@*/ /*@null@*/
sprintfToken ifFormat;
- int numIfTokens;
+ size_t numIfTokens;
/*@only@*/ /*@null@*/
sprintfToken elseFormat;
- int numElseTokens;
+ size_t numElseTokens;
struct sprintfTag_s tag;
} cond; /*!< PTOK_COND */
} u;
@@ -175,7 +175,7 @@
* @param negate negative offset expected?
* @return -1 on success, otherwise failing tag element index
*/
-int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate)
+int headerVerifyInfo(uint32_t il, uint32_t dl, const void * pev, void * iv, int negate)
/*@modifies *iv @*/;
/** \ingroup header
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/merge.c
============================================================================
$ cvs diff -u -r1.10 -r1.11 merge.c
--- rpm/rpmdb/merge.c 14 Nov 2007 23:56:33 -0000 1.10
+++ rpm/rpmdb/merge.c 15 Nov 2007 14:30:25 -0000 1.11
@@ -91,7 +91,7 @@
#define swap(a, b) { \
s = b; \
- i = size; \
+ i = (int) size; \
do { \
tmp = *a; *a++ = *s; *s++ = tmp; \
} while (--i); \
@@ -100,7 +100,7 @@
#define reverse(bot, top) { \
s = top; \
do { \
- i = size; \
+ i = (int) size; \
do { \
tmp = *bot; *bot++ = *s; *s++ = tmp; \
} while (--i); \
@@ -153,7 +153,7 @@
* Avoid running pointers out of bounds; limit n to evens
* for simplicity.
*/
- i = 4 + (n & 1);
+ i = (int)(4 + (n & 1));
insertionsort(list1 + (n - i) * size, i, size, cmp);
last = list1 + size * (n - i);
*EVAL(list2 + (last - list1)) = list2 + n * size;
@@ -273,7 +273,7 @@
}
} else {
/*@-shiftimplementation@*/
-EXPONENTIAL: for (i = size; ; i <<= 1)
+EXPONENTIAL: for (i = (int) size; ; i <<= 1)
if ((p = (b + i)) >= t) {
if ((p = t - size) > b &&
(*cmp)(q, p) <= sense)
@@ -283,21 +283,21 @@
/*@innerbreak@*/ break;
} else if ((*cmp)(q, p) <= sense) {
t = p;
- if (i == size)
+ if (i == (int) size)
big = 0;
goto FASTCASE;
} else
b = p;
/*@-infloopsuncon@*/
while (t > b+size) {
- i = (((t - b) / size) >> 1) * size;
+ i = (int) ((((t - b) / size) >> 1) * size);
if ((*cmp)(q, p = b + i) <= sense)
t = p;
else
b = p;
}
goto COPY;
-FASTCASE: while (i > size)
+FASTCASE: while (i > (int) size)
if ((*cmp)(q,
p = b + (i >>= 1)) <= sense)
t = p;
@@ -307,7 +307,7 @@
/*@=shiftimplementation@*/
COPY: b = t;
}
- i = size;
+ i = (int) size;
if (q == f1) {
if (iflag) {
ICOPY_LIST(f2, tp2, b);
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/pkgio.c
============================================================================
$ cvs diff -u -r1.34 -r1.35 pkgio.c
--- rpm/rpmdb/pkgio.c 14 Nov 2007 23:56:33 -0000 1.34
+++ rpm/rpmdb/pkgio.c 15 Nov 2007 14:30:25 -0000 1.35
@@ -193,7 +193,7 @@
xx = 0;
if (fn && *fn != '%') {
- xx = (pgpReadPkts(fn, (byte **)&ts->pkpkt, &ts->pkpktlen) != PGPARMOR_PUBKEY);
+ xx = (pgpReadPkts(fn, (const byte **)&ts->pkpkt, &ts->pkpktlen) != PGPARMOR_PUBKEY);
}
fn = _free(fn);
if (xx) {
@@ -317,11 +317,11 @@
unsigned char magic[4];
unsigned char major;
unsigned char minor;
- short type;
- short archnum;
+ unsigned short type;
+ unsigned short archnum;
char name[66];
- short osnum;
- short signature_type; /*!< Signature header type (RPMSIG_HEADERSIG) */
+ unsigned short osnum;
+ unsigned short signature_type; /*!< Signature type (RPMSIG_HEADERSIG) */
/*@unused@*/
char reserved[16]; /*!< Pad to 96 bytes -- 8 byte aligned! */
} ;
@@ -362,10 +362,10 @@
(void) strncpy(l.name, *msg, sizeof(l.name));
memcpy(&l.magic, lead_magic, sizeof(l.magic));
- l.type = htons(l.type);
- l.archnum = htons(l.archnum);
- l.osnum = htons(l.osnum);
- l.signature_type = htons(l.signature_type);
+ l.type = (unsigned short) htons(l.type);
+ l.archnum = (unsigned short) htons(l.archnum);
+ l.osnum = (unsigned short) htons(l.osnum);
+ l.signature_type = (unsigned short) htons(l.signature_type);
if (Fwrite(&l, 1, sizeof(l), fd) != sizeof(l))
return RPMRC_FAIL;
@@ -417,10 +417,10 @@
}
}
- l->type = ntohs(l->type);
- l->archnum = ntohs(l->archnum);
- l->osnum = ntohs(l->osnum);
- l->signature_type = ntohs(l->signature_type);
+ l->type = (unsigned short) ntohs(l->type);
+ l->archnum = (unsigned short) ntohs(l->archnum);
+ l->osnum = (unsigned short) ntohs(l->osnum);
+ l->signature_type = (unsigned short) ntohs(l->signature_type);
if (memcmp(l->magic, lead_magic, sizeof(l->magic))) {
(void) snprintf(buf, sizeof(buf), _("lead magic: BAD"));
@@ -442,7 +442,7 @@
if (l->signature_type != 5) { /* RPMSIGTYPE_HEADERSIG */
(void) snprintf(buf, sizeof(buf),
- _("sigh type(%d): UNSUPPORTED"), l->signature_type);
+ _("sigh type(%u): UNSUPPORTED"), (unsigned) l->signature_type);
rc = RPMRC_NOTFOUND;
goto exit;
}
@@ -563,13 +563,13 @@
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
Header * sighp = ptr;
char buf[BUFSIZ];
- int_32 block[4];
- int_32 il;
- int_32 dl;
- int_32 * ei = NULL;
+ uint32_t block[4];
+ uint32_t il;
+ uint32_t dl;
+ uint32_t * ei = NULL;
entryInfo pe;
size_t nb;
- int_32 ril = 0;
+ uint32_t ril = 0;
indexEntry entry = memset(alloca(sizeof(*entry)), 0, sizeof(*entry));
entryInfo info = memset(alloca(sizeof(*info)), 0, sizeof(*info));
unsigned char * dataStart;
@@ -577,7 +577,7 @@
Header sigh = NULL;
rpmRC rc = RPMRC_FAIL; /* assume failure */
int xx;
- int i;
+ uint32_t i;
buf[0] = '\0';
if (sighp)
@@ -610,16 +610,16 @@
goto exit;
}
}
- il = ntohl(block[2]);
- if (il < 0 || il > 32) {
+ il = (uint32_t) ntohl(block[2]);
+ if (il > 32) {
(void) snprintf(buf, sizeof(buf),
- _("sigh tags: BAD, no. of tags(%d) out of range\n"), il);
+ _("sigh tags: BAD, no. of tags(%u) out of range\n"), (unsigned) il);
goto exit;
}
- dl = ntohl(block[3]);
- if (dl < 0 || dl > 8192) {
+ dl = (uint32_t) ntohl(block[3]);
+ if (dl > 8192) {
(void) snprintf(buf, sizeof(buf),
- _("sigh data: BAD, no. of bytes(%d) out of range\n"), dl);
+ _("sigh data: BAD, no. of bytes(%u) out of range\n"), (unsigned) dl);
goto exit;
}
@@ -637,7 +637,7 @@
} else {
if ((xx = (int) timedRead(fd, (void *)pe, nb)) != (int) nb) {
(void) snprintf(buf, sizeof(buf),
- _("sigh blob(%d): BAD, read returned %d\n"), (int)nb, xx);
+ _("sigh blob(%u): BAD, read returned %d\n"), (unsigned) nb, xx);
goto exit;
}
}
@@ -646,9 +646,9 @@
xx = headerVerifyInfo(1, dl, pe, &entry->info, 0);
if (xx != -1) {
(void) snprintf(buf, sizeof(buf),
- _("tag[%d]: BAD, tag %d type %d offset %d count %d\n"),
- 0, entry->info.tag, entry->info.type,
- entry->info.offset, entry->info.count);
+ _("tag[%d]: BAD, tag %u type %u offset %d count %u\n"),
+ 0, (unsigned) entry->info.tag, (unsigned) entry->info.type,
+ entry->info.offset, (unsigned) entry->info.count);
goto exit;
}
@@ -662,9 +662,9 @@
if (entry->info.offset >= dl) {
(void) snprintf(buf, sizeof(buf),
- _("region offset: BAD, tag %d type %d offset %d count %d\n"),
- entry->info.tag, entry->info.type,
- entry->info.offset, entry->info.count);
+ _("region offset: BAD, tag %u type %u offset %d count %u\n"),
+ (unsigned) entry->info.tag, (unsigned) entry->info.type,
+ entry->info.offset, (unsigned) entry->info.count);
goto exit;
}
@@ -673,8 +673,8 @@
/*@-sizeoftype@*/
(void) memcpy(info, dataEnd, REGION_TAG_COUNT);
/* XXX Really old packages have HEADER_IMAGE, not HEADER_SIGNATURES. */
- if (info->tag == htonl(RPMTAG_HEADERIMAGE)) {
- int_32 stag = htonl(RPMTAG_HEADERSIGNATURES);
+ if (info->tag == (uint32_t) htonl(RPMTAG_HEADERIMAGE)) {
+ uint32_t stag = (uint32_t) htonl(RPMTAG_HEADERSIGNATURES);
info->tag = stag;
memcpy(dataEnd, &stag, sizeof(stag));
}
@@ -687,32 +687,32 @@
&& entry->info.count == REGION_TAG_COUNT))
{
(void) snprintf(buf, sizeof(buf),
- _("region trailer: BAD, tag %d type %d offset %d count %d\n"),
- entry->info.tag, entry->info.type,
- entry->info.offset, entry->info.count);
+ _("region trailer: BAD, tag %u type %u offset %d count %u\n"),
+ (unsigned) entry->info.tag, (unsigned) entry->info.type,
+ entry->info.offset, (unsigned) entry->info.count);
goto exit;
}
/*@=sizeoftype@*/
memset(info, 0, sizeof(*info));
/* Is the no. of tags in the region less than the total no. of tags? */
- ril = entry->info.offset/sizeof(*pe);
+ ril = (uint32_t) entry->info.offset/sizeof(*pe);
if ((entry->info.offset % sizeof(*pe)) || ril > il) {
(void) snprintf(buf, sizeof(buf),
- _("region size: BAD, ril(%d) > il(%d)\n"), ril, il);
+ _("region size: BAD, ril(%u) > il(%u)\n"), (unsigned) ril, (unsigned) il);
goto exit;
}
}
/* Sanity check signature tags */
memset(info, 0, sizeof(*info));
- for (i = 1; i < il; i++) {
+ for (i = 1; i < (unsigned) il; i++) {
xx = headerVerifyInfo(1, dl, pe+i, &entry->info, 0);
if (xx != -1) {
(void) snprintf(buf, sizeof(buf),
- _("sigh tag[%d]: BAD, tag %d type %d offset %d count %d\n"),
- i, entry->info.tag, entry->info.type,
- entry->info.offset, entry->info.count);
+ _("sigh tag[%u]: BAD, tag %u type %u offset %d count %u\n"),
+ (unsigned) i, (unsigned) entry->info.tag, (unsigned) entry->info.type,
+ entry->info.offset, (unsigned) entry->info.count);
goto exit;
}
}
@@ -785,14 +785,14 @@
{
pgpDig dig = rpmtsDig(ts);
char buf[8*BUFSIZ];
- int_32 * ei = (int_32 *) uh;
- int_32 il = ntohl(ei[0]);
- int_32 dl = ntohl(ei[1]);
+ uint32_t * ei = (uint32_t *) uh;
+ uint32_t il = (uint32_t) ntohl(ei[0]);
+ uint32_t dl = (uint32_t) ntohl(ei[1]);
/*@-castexpose@*/
entryInfo pe = (entryInfo) &ei[2];
/*@=castexpose@*/
- int_32 ildl[2];
- int_32 pvlen = sizeof(ildl) + (il * sizeof(*pe)) + dl;
+ uint32_t ildl[2];
+ size_t pvlen = sizeof(ildl) + (il * sizeof(*pe)) + dl;
unsigned char * dataStart = (unsigned char *) (pe + il);
indexEntry entry = memset(alloca(sizeof(*entry)), 0, sizeof(*entry));
entryInfo info = memset(alloca(sizeof(*info)), 0, sizeof(*info));
@@ -800,14 +800,14 @@
unsigned char * b;
rpmVSFlags vsflags = pgpGetVSFlags(dig);
rpmop op;
- int siglen = 0;
+ size_t siglen = 0;
int blen;
size_t nb;
- int_32 ril = 0;
+ uint32_t ril = 0;
unsigned char * regionEnd = NULL;
rpmRC rc = RPMRC_FAIL; /* assume failure */
int xx;
- int i;
+ uint32_t i;
static int hclvl;
hclvl++;
@@ -816,8 +816,8 @@
/* Is the blob the right size? */
if (uc > 0 && pvlen != uc) {
(void) snprintf(buf, sizeof(buf),
- _("blob size(%d): BAD, 8 + 16 * il(%d) + dl(%d)\n"),
- (int)uc, (int)il, (int)dl);
+ _("blob size(%d): BAD, 8 + 16 * il(%u) + dl(%u)\n"),
+ (int)uc, (unsigned)il, (unsigned)dl);
goto exit;
}
@@ -825,9 +825,9 @@
xx = headerVerifyInfo(1, dl, pe, &entry->info, 0);
if (xx != -1) {
(void) snprintf(buf, sizeof(buf),
- _("tag[%d]: BAD, tag %d type %d offset %d count %d\n"),
- 0, entry->info.tag, entry->info.type,
- entry->info.offset, entry->info.count);
+ _("tag[%d]: BAD, tag %u type %u offset %d count %u\n"),
+ 0, (unsigned) entry->info.tag, (unsigned) entry->info.type,
+ entry->info.offset, (unsigned) entry->info.count);
goto exit;
}
@@ -843,11 +843,11 @@
/*@=sizeoftype@*/
/* Is the offset within the data area? */
- if (entry->info.offset >= dl) {
+ if (entry->info.offset >= (unsigned) dl) {
(void) snprintf(buf, sizeof(buf),
- _("region offset: BAD, tag %d type %d offset %d count %d\n"),
- entry->info.tag, entry->info.type,
- entry->info.offset, entry->info.count);
+ _("region offset: BAD, tag %u type %u offset %d count %u\n"),
+ (unsigned) entry->info.tag, (unsigned) entry->info.type,
+ entry->info.offset, (unsigned) entry->info.count);
goto exit;
}
@@ -864,30 +864,30 @@
&& entry->info.count == REGION_TAG_COUNT))
{
(void) snprintf(buf, sizeof(buf),
- _("region trailer: BAD, tag %d type %d offset %d count %d\n"),
- entry->info.tag, entry->info.type,
- entry->info.offset, entry->info.count);
+ _("region trailer: BAD, tag %u type %u offset %d count %u\n"),
+ (unsigned) entry->info.tag, (unsigned) entry->info.type,
+ entry->info.offset, (unsigned) entry->info.count);
goto exit;
}
/*@=sizeoftype@*/
memset(info, 0, sizeof(*info));
/* Is the no. of tags in the region less than the total no. of tags? */
- ril = entry->info.offset/sizeof(*pe);
+ ril = (uint32_t) entry->info.offset/sizeof(*pe);
if ((entry->info.offset % sizeof(*pe)) || ril > il) {
(void) snprintf(buf, sizeof(buf),
- _("region size: BAD, ril(%d) > il(%d)\n"), ril, il);
+ _("region size: BAD, ril(%u) > il(%u)\n"), (unsigned) ril, (unsigned)il);
goto exit;
}
/* Find a header-only digest/signature tag. */
- for (i = ril; i < il; i++) {
+ for (i = ril; i < (unsigned) il; i++) {
xx = headerVerifyInfo(1, dl, pe+i, &entry->info, 0);
if (xx != -1) {
(void) snprintf(buf, sizeof(buf),
- _("tag[%d]: BAD, tag %d type %d offset %d count %d\n"),
- i, entry->info.tag, entry->info.type,
- entry->info.offset, entry->info.count);
+ _("tag[%u]: BAD, tag %u type %u offset %d count %u\n"),
+ (unsigned) i, (unsigned) entry->info.tag, (unsigned) entry->info.type,
+ entry->info.offset, (unsigned) entry->info.count);
goto exit;
}
@@ -951,9 +951,9 @@
xx = headerVerifyInfo(ril-1, dl, pe+1, &entry->info, 0);
if (xx != -1) {
(void) snprintf(buf, sizeof(buf),
- _("tag[%d]: BAD, tag %d type %d offset %d count %d\n"),
- xx+1, entry->info.tag, entry->info.type,
- entry->info.offset, entry->info.count);
+ _("tag[%d]: BAD, tag %u type %u offset %d count %u\n"),
+ xx+1, (unsigned) entry->info.tag, (unsigned) entry->info.type,
+ entry->info.offset, (unsigned) entry->info.count);
rc = RPMRC_FAIL;
} else {
(void) snprintf(buf, sizeof(buf), "Header sanity check: OK\n");
@@ -991,9 +991,9 @@
goto exit;
}
- ildl[0] = htonl(ril);
- ildl[1] = (regionEnd - dataStart);
- ildl[1] = htonl(ildl[1]);
+ ildl[0] = (uint32_t) htonl(ril);
+ ildl[1] = (uint32_t) (regionEnd - dataStart);
+ ildl[1] = (uint32_t) htonl(ildl[1]);
op = pgpStatsAccumulator(dig, 10); /* RPMTS_OP_DIGEST */
(void) rpmswEnter(op, 0);
@@ -1012,12 +1012,12 @@
dig->nbytes += nb;
b = (unsigned char *) pe;
- nb = (htonl(ildl[0]) * sizeof(*pe));
+ nb = (size_t) (htonl(ildl[0]) * sizeof(*pe));
(void) rpmDigestUpdate(dig->hdrmd5ctx, b, nb);
dig->nbytes += nb;
b = (unsigned char *) dataStart;
- nb = htonl(ildl[1]);
+ nb = (size_t) htonl(ildl[1]);
(void) rpmDigestUpdate(dig->hdrmd5ctx, b, nb);
dig->nbytes += nb;
(void) rpmswExit(op, dig->nbytes);
@@ -1036,9 +1036,9 @@
}
/*@fallthrough@*/
case RPMTAG_SHA1HEADER:
- ildl[0] = htonl(ril);
- ildl[1] = (regionEnd - dataStart);
- ildl[1] = htonl(ildl[1]);
+ ildl[0] = (uint32_t) htonl(ril);
+ ildl[1] = (uint32_t) (regionEnd - dataStart);
+ ildl[1] = (uint32_t) htonl(ildl[1]);
op = pgpStatsAccumulator(dig, 10); /* RPMTS_OP_DIGEST */
(void) rpmswEnter(op, 0);
@@ -1057,12 +1057,12 @@
dig->nbytes += nb;
b = (unsigned char *) pe;
- nb = (htonl(ildl[0]) * sizeof(*pe));
+ nb = (size_t) (htonl(ildl[0]) * sizeof(*pe));
(void) rpmDigestUpdate(dig->hdrsha1ctx, b, nb);
dig->nbytes += nb;
b = (unsigned char *) dataStart;
- nb = htonl(ildl[1]);
+ nb = (size_t) htonl(ildl[1]);
(void) rpmDigestUpdate(dig->hdrsha1ctx, b, nb);
dig->nbytes += nb;
(void) rpmswExit(op, dig->nbytes);
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/rpmdb.c
============================================================================
$ cvs diff -u -r1.208 -r1.209 rpmdb.c
--- rpm/rpmdb/rpmdb.c 14 Nov 2007 23:56:33 -0000 1.208
+++ rpm/rpmdb/rpmdb.c 15 Nov 2007 14:30:25 -0000 1.209
@@ -1377,7 +1377,7 @@
* @param s (directory) path
* @return tagnum with (directory) path hash
*/
-static inline unsigned taghash(const unsigned char *s)
+static inline unsigned taghash(const char * s)
/*@*/
{
unsigned int r = 0;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/sqlite.c
============================================================================
$ cvs diff -u -r1.22 -r1.23 sqlite.c
--- rpm/rpmdb/sqlite.c 14 Nov 2007 23:56:33 -0000 1.22
+++ rpm/rpmdb/sqlite.c 15 Nov 2007 14:30:25 -0000 1.23
@@ -76,7 +76,7 @@
/*@only@*/ /*@relnull@*/
char ** av; /* item ptrs */
/*@only@*/ /*@relnull@*/
- int * avlen; /* item sizes */
+ size_t * avlen; /* item sizes */
int nalloc;
int ac; /* no. of items */
int rx; /* Which row are we on? 1, 2, 3 ... */
@@ -430,7 +430,7 @@
int32_t v = sqlite3_column_int(scp->pStmt, i);
nb = sizeof(v);
if (_debug)
-fprintf(stderr, "\t%d %s %s %d\n", i, cname, vtype, v);
+fprintf(stderr, "\t%d %s %s %d\n", i, cname, vtype, (int) v);
if (nb > 0) {
scp->av[scp->ac] = memcpy(xmalloc(nb), &v, nb);
scp->avlen[scp->ac] = nb;
@@ -1105,7 +1105,7 @@
scp->cmd = sqlite3_mprintf("DELETE FROM '%q' WHERE key=? AND value=?;",
dbi->dbi_subfile);
- rc = sqlite3_prepare(sqldb->db, scp->cmd, strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
+ rc = sqlite3_prepare(sqldb->db, scp->cmd, (int)strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
if (rc) rpmlog(RPMLOG_WARNING, "cdel(%s) prepare %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
rc = sql_bind_key(dbi, scp, 1, key);
if (rc) rpmlog(RPMLOG_WARNING, "cdel(%s) bind key %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
@@ -1183,7 +1183,7 @@
dbi->dbi_subfile);
break;
}
- rc = sqlite3_prepare(sqldb->db, scp->cmd, strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
+ rc = sqlite3_prepare(sqldb->db, scp->cmd, (int)strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
if (rc) rpmlog(RPMLOG_WARNING, "cget(%s) sequential prepare %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
rc = sql_step(dbi, scp);
@@ -1194,7 +1194,7 @@
scp->keys = xcalloc(scp->nkeys, sizeof(*scp->keys));
for (ix = 0; ix < scp->nkeys; ix++) {
scp->keys[ix] = xmalloc(sizeof(*scp->keys[0]));
- scp->keys[ix]->size = scp->avlen[ix+1];
+ scp->keys[ix]->size = (u_int32_t) scp->avlen[ix+1];
scp->keys[ix]->data = xmalloc(scp->keys[ix]->size);
memcpy(scp->keys[ix]->data, scp->av[ix+1], scp->avlen[ix+1]);
}
@@ -1215,7 +1215,7 @@
/* Prepare SQL statement to retrieve the value for the current key */
scp->cmd = sqlite3_mprintf("SELECT value FROM '%q' WHERE key=?;", dbi->dbi_subfile);
- rc = sqlite3_prepare(sqldb->db, scp->cmd, strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
+ rc = sqlite3_prepare(sqldb->db, scp->cmd, (int)strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
if (rc) rpmlog(RPMLOG_WARNING, "cget(%s) prepare %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
}
@@ -1273,7 +1273,7 @@
scp->ldata = _free(scp->ldata);
}
- data->size = scp->avlen[1];
+ data->size = (u_int32_t) scp->avlen[1];
data->data = xmalloc(data->size);
if (! (data->flags & DB_DBT_MALLOC) )
scp->ldata = data->data;
@@ -1328,7 +1328,7 @@
default:
scp->cmd = sqlite3_mprintf("INSERT OR REPLACE INTO '%q' VALUES(?, ?);",
dbi->dbi_subfile);
- rc = sqlite3_prepare(sqldb->db, scp->cmd, strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
+ rc = sqlite3_prepare(sqldb->db, scp->cmd, (int)strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
if (rc) rpmlog(RPMLOG_WARNING, "cput(%s) prepare %s (%d)\n",dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
rc = sql_bind_key(dbi, scp, 1, key);
if (rc) rpmlog(RPMLOG_WARNING, "cput(%s) key bind %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmpgp.h
============================================================================
$ cvs diff -u -r2.52 -r2.53 rpmpgp.h
--- rpm/rpmio/rpmpgp.h 14 Nov 2007 21:13:18 -0000 2.52
+++ rpm/rpmio/rpmpgp.h 15 Nov 2007 14:30:26 -0000 2.53
@@ -1035,13 +1035,13 @@
/*@modifies *lenp @*/
{
if (*s < 192) {
- (*lenp) = *s++;
+ *lenp = (unsigned int) *s++;
return 1;
} else if (*s < 255) {
- (*lenp) = ((((unsigned)s[0]) - 192) << 8) + s[1] + 192;
+ *lenp = (unsigned int) ((((unsigned)s[0]) - 192) << 8) + s[1] + 192;
return 2;
} else {
- (*lenp) = pgpGrab(s+1, 4);
+ *lenp = pgpGrab(s+1, 4);
return 5;
}
}
@@ -1056,7 +1056,7 @@
/*@requires maxRead(p) >= 1 @*/
/*@*/
{
- return ((p[0] << 8) | p[1]);
+ return (unsigned int) ((p[0] << 8) | p[1]);
}
/**
@@ -1086,7 +1086,7 @@
static char hex[] = "0123456789abcdef";
while (nbytes-- > 0) {
unsigned int i;
- i = *s++;
+ i = (unsigned int) *s++;
*t++ = hex[ (i >> 4) & 0xf ];
*t++ = hex[ (i ) & 0xf ];
}
@@ -1141,7 +1141,7 @@
/*@*/
{
do {
- if (vs->val == val)
+ if (vs->val == (int)val)
break;
} while ((++vs)->val != -1);
return vs->str;
@@ -1159,7 +1159,7 @@
/*@*/
{
do {
- int vlen = strlen(vs->str);
+ size_t vlen = strlen(vs->str);
if (vlen <= (se-s) && !strncmp(s, vs->str, vlen))
break;
} while ((++vs)->val != -1);
@@ -1502,7 +1502,7 @@
int pgpIsPkt(const byte * p)
/*@*/
{
- unsigned int val = *p++;
+ unsigned int val = (unsigned int) *p++;
pgpTag tag;
int rc;
@@ .
Received on Thu Nov 15 15:30:26 2007