1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-06-13 18:21:03 +02:00

kbx: Change return type of search functions to gpg_error_t.

* kbx/keybox-search.c (keybox_search_reset): Change return type to
gpg_error_t.
(keybox_search): Ditto.  Also handle GPG_ERR_EOF.
* sm/keydb.c (keydb_search_reset): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-01-13 15:08:42 +01:00
parent 9b6c91469a
commit c7ca0f73db
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
4 changed files with 18 additions and 15 deletions

View File

@ -732,7 +732,7 @@ release_sn_array (struct sn_array_s *array, size_t size)
*/ */
int gpg_error_t
keybox_search_reset (KEYBOX_HANDLE hd) keybox_search_reset (KEYBOX_HANDLE hd)
{ {
if (!hd) if (!hd)
@ -760,12 +760,12 @@ keybox_search_reset (KEYBOX_HANDLE hd)
If WANT_BLOBTYPE is not 0 only blobs of this type are considered. If WANT_BLOBTYPE is not 0 only blobs of this type are considered.
The value at R_SKIPPED is updated by the number of skipped long The value at R_SKIPPED is updated by the number of skipped long
records (counts PGP and X.509). */ records (counts PGP and X.509). */
int gpg_error_t
keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc, keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
keybox_blobtype_t want_blobtype, keybox_blobtype_t want_blobtype,
size_t *r_descindex, unsigned long *r_skipped) size_t *r_descindex, unsigned long *r_skipped)
{ {
int rc; gpg_error_t rc;
size_t n; size_t n;
int need_words, any_skip; int need_words, any_skip;
KEYBOXBLOB blob = NULL; KEYBOXBLOB blob = NULL;
@ -1021,7 +1021,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
hd->found.pk_no = pk_no; hd->found.pk_no = pk_no;
hd->found.uid_no = uid_no; hd->found.uid_no = uid_no;
} }
else if (rc == -1) else if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
{ {
_keybox_release_blob (blob); _keybox_release_blob (blob);
hd->eof = 1; hd->eof = 1;

View File

@ -91,10 +91,11 @@ int keybox_get_cert (KEYBOX_HANDLE hd, ksba_cert_t *ret_cert);
#endif /*KEYBOX_WITH_X509*/ #endif /*KEYBOX_WITH_X509*/
int keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value); int keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value);
int keybox_search_reset (KEYBOX_HANDLE hd); gpg_error_t keybox_search_reset (KEYBOX_HANDLE hd);
int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc, gpg_error_t keybox_search (KEYBOX_HANDLE hd,
keybox_blobtype_t want_blobtype, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
size_t *r_descindex, unsigned long *r_skipped); keybox_blobtype_t want_blobtype,
size_t *r_descindex, unsigned long *r_skipped);
off_t keybox_offset (KEYBOX_HANDLE hd); off_t keybox_offset (KEYBOX_HANDLE hd);
gpg_error_t keybox_seek (KEYBOX_HANDLE hd, off_t offset); gpg_error_t keybox_seek (KEYBOX_HANDLE hd, off_t offset);

View File

@ -928,10 +928,11 @@ keydb_rebuild_caches (void)
/* /*
* Start the next search on this handle right at the beginning * Start the next search on this handle right at the beginning
*/ */
int gpg_error_t
keydb_search_reset (KEYDB_HANDLE hd) keydb_search_reset (KEYDB_HANDLE hd)
{ {
int i, rc = 0; int i;
gpg_error_t rc = 0;
if (!hd) if (!hd)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
@ -950,8 +951,7 @@ keydb_search_reset (KEYDB_HANDLE hd)
break; break;
} }
} }
return rc; /* fixme: we need to map error codes or share them with return rc;
all modules*/
} }
/* /*
@ -980,8 +980,10 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc)
NULL, &skipped); NULL, &skipped);
break; break;
} }
if (rc == -1) /* EOF -> switch to next resource */ if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
hd->current++; { /* EOF -> switch to next resource */
hd->current++;
}
else if (!rc) else if (!rc)
hd->found = hd->current; hd->found = hd->current;
} }

View File

@ -54,7 +54,7 @@ int keydb_delete (KEYDB_HANDLE hd, int unlock);
int keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved); int keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved);
void keydb_rebuild_caches (void); void keydb_rebuild_caches (void);
int keydb_search_reset (KEYDB_HANDLE hd); gpg_error_t keydb_search_reset (KEYDB_HANDLE hd);
int keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc); int keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc);
int keydb_search_first (KEYDB_HANDLE hd); int keydb_search_first (KEYDB_HANDLE hd);
int keydb_search_next (KEYDB_HANDLE hd); int keydb_search_next (KEYDB_HANDLE hd);