aboutsummaryrefslogtreecommitdiffstats
path: root/g10/tdbio.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-06-04 16:08:26 +0000
committerWerner Koch <[email protected]>2015-06-04 16:08:26 +0000
commita4a15195c2a3729025a3ba3439ac8860083fceeb (patch)
tree2c88b60ff534373b33930223eedf80c1c9f7f14e /g10/tdbio.c
parentgpg: Cleanup error code path in case of a bad trustdb. (diff)
downloadgnupg-a4a15195c2a3729025a3ba3439ac8860083fceeb.tar.gz
gnupg-a4a15195c2a3729025a3ba3439ac8860083fceeb.zip
gpg: Replace -1 by GPG_ERR_NOT_FOUND in tdbio.c
* g10/tdbio.c (lookup_hashtable): Return GPG_ERR_NOT_FOUND. * g10/tdbdump.c (import_ownertrust): Test for GPG_ERR_NOT_FOUND. * g10/trustdb.c (read_trust_record): Ditto. (tdb_get_ownertrust, tdb_get_min_ownertrust): Ditto. (tdb_update_ownertrust, update_min_ownertrust): Ditto. (tdb_clear_ownertrusts, update_validity): Ditto. (tdb_cache_disabled_value): Ditto. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/tdbio.c')
-rw-r--r--g10/tdbio.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/g10/tdbio.c b/g10/tdbio.c
index 4c93c96c3..69b978985 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -1245,10 +1245,9 @@ drop_from_hashtable (ulong table, byte *key, int keylen, ulong recnum)
* the result in REC. The return value of CMP() should be True if the
* record is the desired one.
*
- * Return: -1 if not found, 0 if found or another error code.
- * FIXME: Use GPG_ERR_NOT_FOUND instead of -1.
+ * Return: 0 if found, GPG_ERR_NOT_FOUND, or another error code.
*/
-static int
+static gpg_error_t
lookup_hashtable (ulong table, const byte *key, size_t keylen,
int (*cmpfnc)(const void*, const TRUSTREC *),
const void *cmpdata, TRUSTREC *rec )
@@ -1271,7 +1270,7 @@ lookup_hashtable (ulong table, const byte *key, size_t keylen,
item = rec->r.htbl.item[msb % ITEMS_PER_HTBL_RECORD];
if (!item)
- return -1; /* Not found. */
+ return gpg_error (GPG_ERR_NOT_FOUND);
rc = tdbio_read_record (item, rec, 0);
if (rc)
@@ -1327,14 +1326,14 @@ lookup_hashtable (ulong table, const byte *key, size_t keylen,
}
}
else
- return -1; /* not found */
+ return gpg_error (GPG_ERR_NOT_FOUND);
}
}
if ((*cmpfnc)(cmpdata, rec))
return 0; /* really found */
- return -1; /* no: not found */
+ return gpg_error (GPG_ERR_NOT_FOUND); /* no: not found */
}
@@ -1805,10 +1804,9 @@ cmp_trec_fpr ( const void *fpr, const TRUSTREC *rec )
* Given a 20 byte FINGERPRINT search its trust record and return
* that at REC.
*
- * Return: -1 if not found, 0 if found or another error code.
- * FIXME: Use GPG_ERR_NOT_FOUND instead of -1.
+ * Return: 0 if found, GPG_ERR_NOT_FOUND, or another error code.
*/
-int
+gpg_error_t
tdbio_search_trust_byfpr (const byte *fingerprint, TRUSTREC *rec)
{
int rc;
@@ -1824,10 +1822,9 @@ tdbio_search_trust_byfpr (const byte *fingerprint, TRUSTREC *rec)
* Given a primary public key object PK search its trust record and
* return that at REC.
*
- * Return: -1 if not found, 0 if found or another error code.
- * FIXME: Use GPG_ERR_NOT_FOUND instead of -1.
+ * Return: 0 if found, GPG_ERR_NOT_FOUND, or another error code.
*/
-int
+gpg_error_t
tdbio_search_trust_bypk (PKT_public_key *pk, TRUSTREC *rec)
{
byte fingerprint[MAX_FINGERPRINT_LEN];