]> the.earth.li Git - onak.git/blobdiff - keydb_db4.c
Clean up use of shifts beyond composite types
[onak.git] / keydb_db4.c
index e63ac077f1ed07ef92a00d6d66527ee03c69c5e1..d1947fea5869a7f338cb06484c32ebe5eb016259 100644 (file)
@@ -72,10 +72,13 @@ DB *keydb_fp(struct onak_db4_dbctx *privctx, struct openpgp_fingerprint *fp)
 {
        uint64_t keytrun;
 
-       keytrun = (fp->fp[4] << 24) |
-                       (fp->fp[5] << 16) |
-                       (fp->fp[6] <<  8) |
-                       (fp->fp[7]);
+       keytrun = fp->fp[4];
+       keytrun <<= 8;
+       keytrun |= fp->fp[5];
+       keytrun <<= 8;
+       keytrun |= fp->fp[6];
+       keytrun <<= 8;
+       keytrun |= fp->fp[7];
 
        return(privctx->dbconns[keytrun % privctx->numdbs]);
 }
@@ -472,12 +475,6 @@ static int db4_fetch_key_id(struct onak_dbctx *dbctx, uint64_t keyid,
        return (numkeys);
 }
 
-
-int worddb_cmp(const void *d1, const void *d2)
-{
-       return memcmp(d1, d2, 12);
-}
-
 /**
  *     fetch_key_text - Trys to find the keys that contain the supplied text.
  *     @search: The text to search for.
@@ -661,7 +658,6 @@ static int db4_delete_key(struct onak_dbctx *dbctx,
        int i;
        char **uids = NULL;
        char *primary = NULL;
-       unsigned char worddb_data[12];
        struct ll *wordlist = NULL;
        struct ll *curword  = NULL;
        bool deadlock = false;
@@ -701,13 +697,6 @@ static int db4_delete_key(struct onak_dbctx *dbctx,
 
                for (curword = wordlist; curword != NULL && !deadlock;
                                curword = curword->next) {
-                       memset(&key, 0, sizeof(key));
-                       memset(&data, 0, sizeof(data));
-                       key.data = curword->object;
-                       key.size = strlen(key.data);
-                       data.data = worddb_data;
-                       data.size = sizeof(worddb_data);
-
                        /*
                         * New style uses the fingerprint as the data
                         * Old (unsupported) style was the 64 bit keyid
@@ -829,7 +818,7 @@ static int db4_delete_key(struct onak_dbctx *dbctx,
                        memset(&key, 0, sizeof(key));
                        key.data = subkeyids[i].fp;
                        key.size = subkeyids[i].length;
-                       privctx->subkeydb->del(privctx->subkeydb,
+                       ret = privctx->subkeydb->del(privctx->subkeydb,
                                        privctx->txn, &key, 0);
                        if (ret != 0 && ret != DB_NOTFOUND) {
                                logthing(LOGTHING_ERROR,