aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2006-01-30 18:33:12 +0000
committerEric Andersen <andersen@codepoet.org>2006-01-30 18:33:12 +0000
commit2cdd4d56ffc3b467d5ffa76e3c4cd009dc311097 (patch)
tree39987feb16177a5908fd7965f0589fdcc2874850
parentd78aea8b8eb1da818c04929a2bddbed01a796c58 (diff)
downloadbusybox-w32-2cdd4d56ffc3b467d5ffa76e3c4cd009dc311097.tar.gz
busybox-w32-2cdd4d56ffc3b467d5ffa76e3c4cd009dc311097.tar.bz2
busybox-w32-2cdd4d56ffc3b467d5ffa76e3c4cd009dc311097.zip
passing around an int as a void* is a very bad idea
-rw-r--r--archival/rpm.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/archival/rpm.c b/archival/rpm.c
index 88e748550..7f69f0510 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -247,18 +247,15 @@ rpm_index **rpm_gettags(int fd, int *num_tags)
247 247
248int bsearch_rpmtag(const void *key, const void *item) 248int bsearch_rpmtag(const void *key, const void *item)
249{ 249{
250 int *tag = (int *)key;
250 rpm_index **tmp = (rpm_index **) item; 251 rpm_index **tmp = (rpm_index **) item;
251 /* gcc throws warnings here when sizeof(void*)!=sizeof(int) ... 252 return (*tag - tmp[0]->tag);
252 * it's ok to ignore it because this isn't a 'real' pointer */
253 return ((int) key - tmp[0]->tag);
254} 253}
255 254
256int rpm_getcount(int tag) 255int rpm_getcount(int tag)
257{ 256{
258 rpm_index **found; 257 rpm_index **found;
259 /* gcc throws warnings here when sizeof(void*)!=sizeof(int) ... 258 found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
260 * it's ok to ignore it because tag won't be used as a pointer */
261 found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
262 if (!found) return 0; 259 if (!found) return 0;
263 else return found[0]->count; 260 else return found[0]->count;
264} 261}
@@ -266,9 +263,7 @@ int rpm_getcount(int tag)
266char *rpm_getstring(int tag, int itemindex) 263char *rpm_getstring(int tag, int itemindex)
267{ 264{
268 rpm_index **found; 265 rpm_index **found;
269 /* gcc throws warnings here when sizeof(void*)!=sizeof(int) ... 266 found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
270 * it's ok to ignore it because tag won't be used as a pointer */
271 found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
272 if (!found || itemindex >= found[0]->count) return NULL; 267 if (!found || itemindex >= found[0]->count) return NULL;
273 if (found[0]->type == RPM_STRING_TYPE || found[0]->type == RPM_I18NSTRING_TYPE || found[0]->type == RPM_STRING_ARRAY_TYPE) { 268 if (found[0]->type == RPM_STRING_TYPE || found[0]->type == RPM_I18NSTRING_TYPE || found[0]->type == RPM_STRING_ARRAY_TYPE) {
274 int n; 269 int n;
@@ -284,7 +279,7 @@ int rpm_getint(int tag, int itemindex)
284 int n, *tmpint; 279 int n, *tmpint;
285 /* gcc throws warnings here when sizeof(void*)!=sizeof(int) ... 280 /* gcc throws warnings here when sizeof(void*)!=sizeof(int) ...
286 * it's ok to ignore it because tag won't be used as a pointer */ 281 * it's ok to ignore it because tag won't be used as a pointer */
287 found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag); 282 found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
288 if (!found || itemindex >= found[0]->count) return -1; 283 if (!found || itemindex >= found[0]->count) return -1;
289 tmpint = (int *) (map + found[0]->offset); 284 tmpint = (int *) (map + found[0]->offset);
290 if (found[0]->type == RPM_INT32_TYPE) { 285 if (found[0]->type == RPM_INT32_TYPE) {