From d994ffc56a0221051a7e3dae2fe649d3819c534a Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 12 Nov 2024 15:36:35 +0900 Subject: [PATCH] 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 --- scd/app.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scd/app.c b/scd/app.c index 7d4518024..d09b931e6 100644 --- a/scd/app.c +++ b/scd/app.c @@ -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. */ 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; card_t c; card_t *cardlist = NULL; int n, ncardlist; - if (wantcard) - return send_serialno_and_app_status (wantcard, with_apps, ctrl); - card_list_r_lock (); for (n=0, c = card_top; c; c = c->next) n++; @@ -2781,8 +2778,6 @@ send_card_and_app_list (ctrl_t ctrl, card_t wantcard, int with_apps) { card_t card = cardlist[n]; - if (wantcard && wantcard != card) - continue; lock_card (card, ctrl); err = send_serialno_and_app_status (card, with_apps, ctrl); unlock_card (card); @@ -2803,7 +2798,7 @@ send_card_and_app_list (ctrl_t ctrl, card_t wantcard, int with_apps) gpg_error_t 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 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); }