diff options
author | Werner Koch <wk@gnupg.org> | 2016-01-13 15:08:42 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-01-13 15:08:42 +0100 |
commit | c7ca0f73dbe7c080b79f93f90f00ba2396fc4bd0 (patch) | |
tree | 0148dd57d0618522515d0da351db23794cf0d1a8 | |
parent | gpg: Improve error code from lock_all. (diff) | |
download | gnupg2-c7ca0f73dbe7c080b79f93f90f00ba2396fc4bd0.tar.xz gnupg2-c7ca0f73dbe7c080b79f93f90f00ba2396fc4bd0.zip |
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>
-rw-r--r-- | kbx/keybox-search.c | 8 | ||||
-rw-r--r-- | kbx/keybox.h | 9 | ||||
-rw-r--r-- | sm/keydb.c | 14 | ||||
-rw-r--r-- | sm/keydb.h | 2 |
4 files changed, 18 insertions, 15 deletions
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c index 1edb4ae38..681d5c0e1 100644 --- a/kbx/keybox-search.c +++ b/kbx/keybox-search.c @@ -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) { 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. The value at R_SKIPPED is updated by the number of skipped long records (counts PGP and X.509). */ -int +gpg_error_t keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc, keybox_blobtype_t want_blobtype, size_t *r_descindex, unsigned long *r_skipped) { - int rc; + gpg_error_t rc; size_t n; int need_words, any_skip; 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.uid_no = uid_no; } - else if (rc == -1) + else if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF) { _keybox_release_blob (blob); hd->eof = 1; diff --git a/kbx/keybox.h b/kbx/keybox.h index 9f91c53bd..3c60971a8 100644 --- a/kbx/keybox.h +++ b/kbx/keybox.h @@ -91,10 +91,11 @@ int keybox_get_cert (KEYBOX_HANDLE hd, ksba_cert_t *ret_cert); #endif /*KEYBOX_WITH_X509*/ int keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value); -int keybox_search_reset (KEYBOX_HANDLE hd); -int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc, - keybox_blobtype_t want_blobtype, - size_t *r_descindex, unsigned long *r_skipped); +gpg_error_t keybox_search_reset (KEYBOX_HANDLE hd); +gpg_error_t keybox_search (KEYBOX_HANDLE hd, + KEYBOX_SEARCH_DESC *desc, size_t ndesc, + keybox_blobtype_t want_blobtype, + size_t *r_descindex, unsigned long *r_skipped); off_t keybox_offset (KEYBOX_HANDLE hd); gpg_error_t keybox_seek (KEYBOX_HANDLE hd, off_t offset); diff --git a/sm/keydb.c b/sm/keydb.c index 0ef3c8f42..f5705cb45 100644 --- a/sm/keydb.c +++ b/sm/keydb.c @@ -928,10 +928,11 @@ keydb_rebuild_caches (void) /* * Start the next search on this handle right at the beginning */ -int +gpg_error_t keydb_search_reset (KEYDB_HANDLE hd) { - int i, rc = 0; + int i; + gpg_error_t rc = 0; if (!hd) return gpg_error (GPG_ERR_INV_VALUE); @@ -950,8 +951,7 @@ keydb_search_reset (KEYDB_HANDLE hd) break; } } - return rc; /* fixme: we need to map error codes or share them with - all modules*/ + return rc; } /* @@ -980,8 +980,10 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc) NULL, &skipped); break; } - if (rc == -1) /* EOF -> switch to next resource */ - hd->current++; + if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF) + { /* EOF -> switch to next resource */ + hd->current++; + } else if (!rc) hd->found = hd->current; } diff --git a/sm/keydb.h b/sm/keydb.h index 03de1c69e..3c0f2d6ee 100644 --- a/sm/keydb.h +++ b/sm/keydb.h @@ -54,7 +54,7 @@ int keydb_delete (KEYDB_HANDLE hd, int unlock); int keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved); 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_first (KEYDB_HANDLE hd); int keydb_search_next (KEYDB_HANDLE hd); |