From: Jonathan McDowell Date: Wed, 16 Mar 2011 04:15:22 +0000 (-0700) Subject: Clean up remaining uses of %llX for printing keyids X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/b8790eaafd4ed0be8ab280581dedd3ff81ba752b Clean up remaining uses of %llX for printing keyids It should be PRIX64 to ensure we use the right format for both 32 and 64 bit platforms. --- diff --git a/keyd.c b/keyd.c index c802264..eab3b54 100644 --- a/keyd.c +++ b/keyd.c @@ -69,7 +69,7 @@ void iteratefunc(void *ctx, struct openpgp_publickey *key) storebuf.buffer = malloc(8192); logthing(LOGTHING_TRACE, - "Iterating over 0x%016llX.", + "Iterating over 0x%016" PRIX64 ".", get_keyid(key)); flatten_publickey(key, @@ -164,7 +164,8 @@ int sock_do(int fd) storebuf.offset = 0; if (ret == 0) { logthing(LOGTHING_INFO, - "Fetching 0x%llX, result: %d", + "Fetching 0x%" PRIX64 + ", result: %d", keyid, config.dbbackend-> fetch_key(keyid, &key, false)); @@ -294,7 +295,8 @@ int sock_do(int fd) } if (ret == 0) { logthing(LOGTHING_INFO, - "Deleting 0x%llX, result: %d", + "Deleting 0x%" PRIX64 + ", result: %d", keyid, config.dbbackend->delete_key( keyid, false)); diff --git a/keydb.c b/keydb.c index 42eebfe..4dc9332 100644 --- a/keydb.c +++ b/keydb.c @@ -185,7 +185,7 @@ int generic_update_keys(struct openpgp_publickey **keys, bool sendsync) for (curkey = *keys; curkey != NULL; curkey = curkey->next) { intrans = config.dbbackend->starttrans(); logthing(LOGTHING_INFO, - "Fetching key 0x%llX, result: %d", + "Fetching key 0x%" PRIX64 ", result: %d", get_keyid(curkey), config.dbbackend->fetch_key(get_keyid(curkey), &oldkey, intrans)); diff --git a/keydb_dynamic.c b/keydb_dynamic.c index e22b00d..ba7792f 100644 --- a/keydb_dynamic.c +++ b/keydb_dynamic.c @@ -428,7 +428,7 @@ static int dynamic_update_keys(struct openpgp_publickey **keys, bool sendsync) for (curkey = *keys; curkey != NULL; curkey = curkey->next) { intrans = dynamic_starttrans(); logthing(LOGTHING_INFO, - "Fetching key 0x%llX, result: %d", + "Fetching key 0x%" PRIX64 ", result: %d", get_keyid(curkey), dynamic_fetch_key(get_keyid(curkey), &oldkey, intrans)); diff --git a/keydb_file.c b/keydb_file.c index 88bb680..e99c268 100644 --- a/keydb_file.c +++ b/keydb_file.c @@ -83,7 +83,7 @@ static int file_fetch_key(uint64_t keyid, struct openpgp_publickey **publickey, char keyfile[1024]; int fd = -1; - snprintf(keyfile, 1023, "%s/0x%llX", config.db_dir, + snprintf(keyfile, 1023, "%s/0x%" PRIX64, config.db_dir, keyid & 0xFFFFFFFF); fd = open(keyfile, O_RDONLY); // | O_SHLOCK); @@ -118,7 +118,7 @@ static int file_store_key(struct openpgp_publickey *publickey, bool intrans, char keyfile[1024]; int fd = -1; - snprintf(keyfile, 1023, "%s/0x%llX", config.db_dir, + snprintf(keyfile, 1023, "%s/0x%" PRIX64, config.db_dir, get_keyid(publickey) & 0xFFFFFFFF); fd = open(keyfile, O_WRONLY | O_CREAT, 0664); // | O_EXLOCK); @@ -149,7 +149,7 @@ static int file_delete_key(uint64_t keyid, bool intrans) { char keyfile[1024]; - snprintf(keyfile, 1023, "%s/0x%llX", config.db_dir, + snprintf(keyfile, 1023, "%s/0x%" PRIX64, config.db_dir, keyid & 0xFFFFFFFF); return unlink(keyfile); diff --git a/keydb_fs.c b/keydb_fs.c index bc3c890..0dc9de5 100644 --- a/keydb_fs.c +++ b/keydb_fs.c @@ -57,7 +57,7 @@ static uint32_t calchash(uint8_t * ptr) static void keypath(char *buffer, uint64_t _keyid) { uint64_t keyid = _keyid << 32; - snprintf(buffer, PATH_MAX, "%s/key/%02X/%02X/%08X/%016llX", + snprintf(buffer, PATH_MAX, "%s/key/%02X/%02X/%08X/%016" PRIX64, config.db_dir, (uint8_t) ((keyid >> 56) & 0xFF), (uint8_t) ((keyid >> 48) & 0xFF), (uint32_t) (keyid >> 32), _keyid); @@ -95,7 +95,7 @@ static void prove_path_to(uint64_t keyid, char *what) static void wordpath(char *buffer, char *word, uint32_t hash, uint64_t keyid) { - snprintf(buffer, PATH_MAX, "%s/words/%02X/%02X/%08X/%s/%016llX", + snprintf(buffer, PATH_MAX, "%s/words/%02X/%02X/%08X/%s/%016" PRIX64, config.db_dir, (uint8_t) ((hash >> 24) & 0xFF), (uint8_t) ((hash >> 16) & 0xFF), hash, word, keyid); } @@ -109,7 +109,7 @@ static void worddir(char *buffer, char *word, uint32_t hash) static void subkeypath(char *buffer, uint64_t subkey, uint64_t keyid) { - snprintf(buffer, PATH_MAX, "%s/subkeys/%02X/%02X/%08X/%016llX", + snprintf(buffer, PATH_MAX, "%s/subkeys/%02X/%02X/%08X/%016" PRIX64, config.db_dir, (uint8_t) ((subkey >> 24) & 0xFF), (uint8_t) ((subkey >> 16) & 0xFF), @@ -346,11 +346,11 @@ static int fs_delete_key(uint64_t keyid, bool intrans) ret = fetch_key(keyid, &pk, true); if (ret) { - logthing(LOGTHING_DEBUG, "Wordlist for key %016llX", + logthing(LOGTHING_DEBUG, "Wordlist for key %016" PRIX64, keyid); wl = wordlist = makewordlistfromkey(wordlist, pk); logthing(LOGTHING_DEBUG, - "Wordlist for key %016llX done", keyid); + "Wordlist for key %016" PRIX64 " done", keyid); while (wl) { uint32_t hash = calchash((uint8_t *) (wl->object)); prove_path_to(hash, "words"); diff --git a/keydb_pg.c b/keydb_pg.c index 85ea500..6b5d320 100644 --- a/keydb_pg.c +++ b/keydb_pg.c @@ -150,12 +150,13 @@ static int pg_fetch_key(uint64_t keyid, struct openpgp_publickey **publickey, if (keyid > 0xFFFFFFFF) { snprintf(statement, 1023, - "SELECT keydata FROM onak_keys WHERE keyid = '%llX'", + "SELECT keydata FROM onak_keys WHERE keyid = '%" + PRIX64 "'", keyid); } else { snprintf(statement, 1023, "SELECT keydata FROM onak_keys WHERE keyid " - "LIKE '%%%llX'", + "LIKE '%%%" PRIX64 "'", keyid); } result = PQexec(dbconn, statement); @@ -282,7 +283,8 @@ static int pg_delete_key(uint64_t keyid, bool intrans) } snprintf(statement, 1023, - "SELECT keydata FROM onak_keys WHERE keyid = '%llX'", + "SELECT keydata FROM onak_keys WHERE keyid = '%" + PRIX64 "'", keyid); result = PQexec(dbconn, statement); @@ -298,24 +300,25 @@ static int pg_delete_key(uint64_t keyid, bool intrans) PQclear(result); snprintf(statement, 1023, - "DELETE FROM onak_keys WHERE keyid = '%llX'", + "DELETE FROM onak_keys WHERE keyid = '%" PRIX64 "'", keyid); result = PQexec(dbconn, statement); PQclear(result); snprintf(statement, 1023, - "DELETE FROM onak_sigs WHERE signee = '%llX'", + "DELETE FROM onak_sigs WHERE signee = '%" PRIX64 "'", keyid); result = PQexec(dbconn, statement); PQclear(result); snprintf(statement, 1023, - "DELETE FROM onak_uids WHERE keyid = '%llX'", + "DELETE FROM onak_uids WHERE keyid = '%" PRIX64 "'", keyid); result = PQexec(dbconn, statement); } else if (PQresultStatus(result) != PGRES_TUPLES_OK) { logthing(LOGTHING_ERROR, - "Problem retrieving key (%llX) from DB.", + "Problem retrieving key (%" PRIX64 + ") from DB.", keyid); } @@ -391,7 +394,7 @@ static int pg_store_key(struct openpgp_publickey *publickey, bool intrans, snprintf(statement, 1023, "INSERT INTO onak_keys (keyid, keydata) VALUES " - "('%llX', '%d')", + "('%" PRIX64 "', '%d')", get_keyid(publickey), key_oid); result = PQexec(dbconn, statement); @@ -414,7 +417,7 @@ static int pg_store_key(struct openpgp_publickey *publickey, bool intrans, snprintf(statement, 1023, "INSERT INTO onak_uids " "(keyid, uid, pri) " - "VALUES ('%llX', '%s', '%c')", + "VALUES ('%" PRIX64 "', '%s', '%c')", get_keyid(publickey), safeuid, (uids[i] == primary) ? 't' : 'f'); @@ -448,7 +451,7 @@ static int pg_store_key(struct openpgp_publickey *publickey, bool intrans, packets = packets->next) { snprintf(statement, 1023, "INSERT INTO onak_sigs (signer, signee) " - "VALUES ('%llX', '%llX')", + "VALUES ('%" PRIX64 "', '%" PRIX64 "')", sig_keyid(packets->packet), get_keyid(publickey)); result = PQexec(dbconn, statement); @@ -475,7 +478,8 @@ static char *pg_keyid2uid(uint64_t keyid) char *uid = NULL; snprintf(statement, 1023, - "SELECT uid FROM onak_uids WHERE keyid = '%llX' AND pri = 't'", + "SELECT uid FROM onak_uids WHERE keyid = '%" PRIX64 + "' AND pri = 't'", keyid); result = PQexec(dbconn, statement); @@ -491,7 +495,8 @@ static char *pg_keyid2uid(uint64_t keyid) uid = strdup(PQgetvalue(result, 0, 0)); } else if (PQresultStatus(result) != PGRES_TUPLES_OK) { logthing(LOGTHING_ERROR, - "Problem retrieving key (%llX) from DB.", + "Problem retrieving key (%" PRIX64 + ") from DB.", keyid); } @@ -525,7 +530,8 @@ static struct ll *pg_getkeysigs(uint64_t keyid, bool *revoked) } snprintf(statement, 1023, - "SELECT DISTINCT signer FROM onak_sigs WHERE signee = '%llX'", + "SELECT DISTINCT signer FROM onak_sigs WHERE signee = '%" + PRIX64 "'", keyid); result = PQexec(dbconn, statement); diff --git a/lookup.c b/lookup.c index e670d49..fafef12 100644 --- a/lookup.c +++ b/lookup.c @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) case OP_GET: if (ishex) { logthing(LOGTHING_NOTICE, - "Getting keyid 0x%llX", + "Getting keyid 0x%" PRIX64, keyid); result = config.dbbackend->fetch_key(keyid, &publickey, false);