From 0a3cfdec02106998006653f8ad340e996261a3d5 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Sat, 12 Jun 2004 15:49:05 +0000 Subject: [PATCH] Various compiler warning cleanups. Fix various compiler warnings; we almost compile cleanly with --std=c99 and -D_BSD_SOURCE. --- decodekey.c | 2 +- keydb_db3.c | 2 +- keydb_fs.c | 22 +++++++++++++++------- keydb_pg.c | 4 ++-- onak.c | 1 + 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/decodekey.c b/decodekey.c index 5818488..eb0a79d 100644 --- a/decodekey.c +++ b/decodekey.c @@ -271,7 +271,7 @@ uint64_t *keysubkeys(struct openpgp_publickey *key) subkeys[count++] = get_packetid(cursubkey->packet); cursubkey = cursubkey -> next; } - subkeys[count] = NULL; + subkeys[count] = 0; } return subkeys; diff --git a/keydb_db3.c b/keydb_db3.c index 191ebc6..3515bf4 100644 --- a/keydb_db3.c +++ b/keydb_db3.c @@ -355,7 +355,7 @@ int fetch_key(uint64_t keyid, struct openpgp_publickey **publickey, return (numkeys); } -int worddb_cmp(const char *d1, const char *d2) +int worddb_cmp(const void *d1, const void *d2) { return memcmp(d1, d2, 12); } diff --git a/keydb_fs.c b/keydb_fs.c index 69a76b1..7de5bac 100644 --- a/keydb_fs.c +++ b/keydb_fs.c @@ -45,7 +45,7 @@ static uint32_t calchash(uint8_t * ptr) { register uint32_t h = FNV_offset_basis; register uint32_t p = FNV_mixing_prime; - register uint32_t n = strlen(ptr); + register uint32_t n = strlen((char *) ptr); register uint8_t *c = ptr; while (n--) { h *= p; @@ -58,7 +58,7 @@ static uint32_t calchash(uint8_t * ptr) void keypath(char *buffer, uint64_t _keyid) { uint64_t keyid = _keyid << 32; - snprintf(buffer, PATH_MAX, "%s/key/%02X/%02X/%08lX/%016llX", + snprintf(buffer, PATH_MAX, "%s/key/%02X/%02X/%08X/%016llX", config.db_dir, (uint8_t) ((keyid >> 56) & 0xFF), (uint8_t) ((keyid >> 48) & 0xFF), (uint32_t) (keyid >> 32), _keyid); @@ -67,7 +67,7 @@ void keypath(char *buffer, uint64_t _keyid) void keydir(char *buffer, uint64_t _keyid) { uint64_t keyid = _keyid << 32; - snprintf(buffer, PATH_MAX, "%s/key/%02X/%02X/%08lX", config.db_dir, + snprintf(buffer, PATH_MAX, "%s/key/%02X/%02X/%08X", config.db_dir, (uint8_t) ((keyid >> 56) & 0xFF), (uint8_t) ((keyid >> 48) & 0xFF), (uint32_t) (keyid >> 32)); @@ -88,7 +88,7 @@ void prove_path_to(uint64_t keyid, char *what) (uint8_t) ((keyid >> 16) & 0xFF)); mkdir(buffer, 0777); - snprintf(buffer, PATH_MAX, "%s/%s/%02X/%02X/%08lX", config.db_dir, what, + snprintf(buffer, PATH_MAX, "%s/%s/%02X/%02X/%08X", config.db_dir, what, (uint8_t) ((keyid >> 24) & 0xFF), (uint8_t) ((keyid >> 16) & 0xFF), (uint32_t) (keyid)); mkdir(buffer, 0777); @@ -96,14 +96,14 @@ void prove_path_to(uint64_t keyid, char *what) void wordpath(char *buffer, char *word, uint32_t hash, uint64_t keyid) { - snprintf(buffer, PATH_MAX, "%s/words/%02X/%02X/%08lX/%s/%016llX", + snprintf(buffer, PATH_MAX, "%s/words/%02X/%02X/%08X/%s/%016llX", config.db_dir, (uint8_t) ((hash >> 24) & 0xFF), (uint8_t) ((hash >> 16) & 0xFF), hash, word, keyid); } void worddir(char *buffer, char *word, uint32_t hash) { - snprintf(buffer, PATH_MAX, "%s/words/%02X/%02X/%08lX/%s", config.db_dir, + snprintf(buffer, PATH_MAX, "%s/words/%02X/%02X/%08X/%s", config.db_dir, (uint8_t) ((hash >> 24) & 0xFF), (uint8_t) ((hash >> 16) & 0xFF), hash, word); } @@ -375,16 +375,20 @@ int fetch_key_text(const char *search, { struct ll *wordlist = NULL, *wl = NULL; struct ll *keylist = NULL; + char *searchtext = NULL; int addedkeys = 0; logthing(LOGTHING_CRITICAL, "Search was '%s'", search); - wl = wordlist = makewordlist(wordlist, search); + searchtext = strdup(search); + wl = wordlist = makewordlist(wordlist, searchtext); keylist = internal_get_key_by_word(wordlist->object, NULL); if (!keylist) { llfree(wordlist, NULL); + free(searchtext); + searchtext = NULL; return 0; } @@ -395,6 +399,8 @@ int fetch_key_text(const char *search, if (!nkl) { llfree(wordlist, NULL); llfree(keylist, free); + free(searchtext); + searchtext = NULL; return 0; } llfree(keylist, free); @@ -417,6 +423,8 @@ int fetch_key_text(const char *search, } llfree(keylist, free); + free(searchtext); + searchtext = NULL; return addedkeys; } diff --git a/keydb_pg.c b/keydb_pg.c index b5afc9e..8d974fd 100644 --- a/keydb_pg.c +++ b/keydb_pg.c @@ -40,7 +40,7 @@ static PGconn *dbconn = NULL; */ static int keydb_fetchchar(void *fd, size_t count, unsigned char *c) { - return (!lo_read(dbconn, *(int *) fd, c, count)); + return (!lo_read(dbconn, *(int *) fd, (char *) c, count)); } /** @@ -48,7 +48,7 @@ static int keydb_fetchchar(void *fd, size_t count, unsigned char *c) */ static int keydb_putchar(void *fd, size_t count, unsigned char *c) { - return !(lo_write(dbconn, *(int *) fd, c, count)); + return !(lo_write(dbconn, *(int *) fd, (char *) c, count)); } /** diff --git a/onak.c b/onak.c index 15154c4..9b2021f 100644 --- a/onak.c +++ b/onak.c @@ -10,6 +10,7 @@ * $Id: onak.c,v 1.22 2004/05/31 14:16:49 noodles Exp $ */ +#include #include #include #include -- 2.39.5