mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-01 16:33:02 +01:00
gpg: Minor rework for better readibility of get_best_pubkey_byname.
* g10/getkey.c (get_best_pubkey_byname): Change return type to gpg_error_t. Use var name err instead of rc. Move a gpg_error_from_syserror closer to the call. -- Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
6496dc1f9d
commit
1c35e29af9
26
g10/getkey.c
26
g10/getkey.c
@ -1583,24 +1583,23 @@ pubkey_cmp (ctrl_t ctrl, const char *name, struct pubkey_cmp_cookie *old,
|
||||
/* This function works like get_pubkey_byname, but if the name
|
||||
* resembles a mail address, the results are ranked and only the best
|
||||
* result is returned. */
|
||||
int
|
||||
gpg_error_t
|
||||
get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk,
|
||||
const char *name, KBNODE *ret_keyblock,
|
||||
int include_unusable, int no_akl)
|
||||
{
|
||||
int rc;
|
||||
gpg_error_t err;
|
||||
struct getkey_ctx_s *ctx = NULL;
|
||||
|
||||
if (retctx)
|
||||
*retctx = NULL;
|
||||
|
||||
rc = get_pubkey_byname (ctrl, &ctx, pk, name, ret_keyblock,
|
||||
NULL, include_unusable, no_akl);
|
||||
if (rc)
|
||||
err = get_pubkey_byname (ctrl, &ctx, pk, name, ret_keyblock,
|
||||
NULL, include_unusable, no_akl);
|
||||
if (err)
|
||||
{
|
||||
if (ctx)
|
||||
getkey_end (ctrl, ctx);
|
||||
return rc;
|
||||
getkey_end (ctrl, ctx);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (is_valid_mailbox (name) && ctx)
|
||||
@ -1647,16 +1646,17 @@ get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk,
|
||||
{
|
||||
ctx = xtrycalloc (1, sizeof **retctx);
|
||||
if (! ctx)
|
||||
rc = gpg_error_from_syserror ();
|
||||
err = gpg_error_from_syserror ();
|
||||
else
|
||||
{
|
||||
ctx->kr_handle = keydb_new ();
|
||||
if (! ctx->kr_handle)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
xfree (ctx);
|
||||
ctx = NULL;
|
||||
if (retctx)
|
||||
*retctx = NULL;
|
||||
rc = gpg_error_from_syserror ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1671,7 +1671,7 @@ get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk,
|
||||
{
|
||||
release_kbnode (*ret_keyblock);
|
||||
*ret_keyblock = NULL;
|
||||
rc = getkey_next (ctrl, ctx, NULL, ret_keyblock);
|
||||
err = getkey_next (ctrl, ctx, NULL, ret_keyblock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1684,7 +1684,7 @@ get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk,
|
||||
}
|
||||
}
|
||||
|
||||
if (rc && ctx)
|
||||
if (err && ctx)
|
||||
{
|
||||
getkey_end (ctrl, ctx);
|
||||
ctx = NULL;
|
||||
@ -1695,7 +1695,7 @@ get_best_pubkey_byname (ctrl_t ctrl, GETKEY_CTX *retctx, PKT_public_key *pk,
|
||||
else
|
||||
getkey_end (ctrl, ctx);
|
||||
|
||||
return rc;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
@ -319,10 +319,10 @@ int get_pubkey_byname (ctrl_t ctrl,
|
||||
|
||||
/* Likewise, but only return the best match if NAME resembles a mail
|
||||
* address. */
|
||||
int get_best_pubkey_byname (ctrl_t ctrl,
|
||||
GETKEY_CTX *retctx, PKT_public_key *pk,
|
||||
const char *name, KBNODE *ret_keyblock,
|
||||
int include_unusable, int no_akl);
|
||||
gpg_error_t get_best_pubkey_byname (ctrl_t ctrl,
|
||||
GETKEY_CTX *retctx, PKT_public_key *pk,
|
||||
const char *name, KBNODE *ret_keyblock,
|
||||
int include_unusable, int no_akl);
|
||||
|
||||
/* Get a public key directly from file FNAME. */
|
||||
gpg_error_t get_pubkey_fromfile (ctrl_t ctrl,
|
||||
|
Loading…
x
Reference in New Issue
Block a user