1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd: Clean up app_send_active_apps and app_send_card_list.

* scd/app.c (send_card_and_app_list): Only handle the case with
WANTCARD=NULL.
(app_send_card_list): Follow the change.
(app_send_active_apps): Factor out the case with WANTCARD!=NULL.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2024-11-12 15:36:35 +09:00
parent 2f6b479919
commit d994ffc56a
No known key found for this signature in database
GPG Key ID: 640114AF89DE6054

View File

@ -2749,16 +2749,13 @@ send_serialno_and_app_status (card_t card, int with_apps, ctrl_t ctrl)
/* Common code for app_send_card_list and app_send_active_apps. */ /* Common code for app_send_card_list and app_send_active_apps. */
static gpg_error_t static gpg_error_t
send_card_and_app_list (ctrl_t ctrl, card_t wantcard, int with_apps) send_card_and_app_list (ctrl_t ctrl, int with_apps)
{ {
gpg_error_t err; gpg_error_t err;
card_t c; card_t c;
card_t *cardlist = NULL; card_t *cardlist = NULL;
int n, ncardlist; int n, ncardlist;
if (wantcard)
return send_serialno_and_app_status (wantcard, with_apps, ctrl);
card_list_r_lock (); card_list_r_lock ();
for (n=0, c = card_top; c; c = c->next) for (n=0, c = card_top; c; c = c->next)
n++; n++;
@ -2781,8 +2778,6 @@ send_card_and_app_list (ctrl_t ctrl, card_t wantcard, int with_apps)
{ {
card_t card = cardlist[n]; card_t card = cardlist[n];
if (wantcard && wantcard != card)
continue;
lock_card (card, ctrl); lock_card (card, ctrl);
err = send_serialno_and_app_status (card, with_apps, ctrl); err = send_serialno_and_app_status (card, with_apps, ctrl);
unlock_card (card); unlock_card (card);
@ -2803,7 +2798,7 @@ send_card_and_app_list (ctrl_t ctrl, card_t wantcard, int with_apps)
gpg_error_t gpg_error_t
app_send_card_list (ctrl_t ctrl) app_send_card_list (ctrl_t ctrl)
{ {
return send_card_and_app_list (ctrl, NULL, 0); return send_card_and_app_list (ctrl, 0);
} }
@ -2812,7 +2807,10 @@ app_send_card_list (ctrl_t ctrl)
gpg_error_t gpg_error_t
app_send_active_apps (card_t card, ctrl_t ctrl) app_send_active_apps (card_t card, ctrl_t ctrl)
{ {
return send_card_and_app_list (ctrl, card, 1); if (!card)
return send_card_and_app_list (ctrl, 1);
else
return send_serialno_and_app_status (card, 1, ctrl);
} }