From: Panu Matilainen Date: Wed, 28 May 2008 06:53:30 +0000 (+0300) Subject: Move key size fixups from rpmdbAdd & Remove to td2key() X-Git-Tag: tznext/4.11.0.1.tizen20130304~3995 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=903c5d9fec67bc15695807fb507912206e039d40;p=tools%2Flibrpm-tizen.git Move key size fixups from rpmdbAdd & Remove to td2key() --- diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 3a00cfe..6a3799e 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -2396,6 +2396,12 @@ static int td2key(rpmtd tagdata, DBT *key) key->size = strlen(str); break; } + + if (key->size == 0) + key->size = strlen((char *)key->data); + if (key->size == 0) + key->size++; /* XXX "/" fixup. */ + return 1; } @@ -2531,11 +2537,6 @@ int rpmdbRemove(rpmdb db, int rid, unsigned int hdrNum, * */ set = NULL; - if (key.size == 0) - key.size = strlen((char *)key.data); - if (key.size == 0) - key.size++; /* XXX "/" fixup. */ - rc = dbiGet(dbi, dbcursor, &key, &data, DB_SET); if (rc == 0) { /* success */ (void) dbt2set(dbi, &data, &set); @@ -2831,11 +2832,6 @@ int rpmdbAdd(rpmdb db, int iid, Header h, set = NULL; - if (key.size == 0) - key.size = strlen((char *)key.data); - if (key.size == 0) - key.size++; /* XXX "/" fixup. */ - rc = dbiGet(dbi, dbcursor, &key, &data, DB_SET); if (rc == 0) { /* success */ /* With duplicates, cursor is positioned, discard the record. */