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

scd: Simplify the loop of DEVINFO.

* scd/app.c (app_send_devinfo): Factor out lock/unlock.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2021-11-02 14:06:16 +09:00
parent 99e00ec6db
commit 49f7fcb90b

View File

@ -424,16 +424,12 @@ app_send_devinfo (ctrl_t ctrl, int keep_looping)
app_t a;
int no_device;
card_list_w_lock ();
while (1)
{
card_list_w_lock ();
no_device = (card_top == NULL);
if (no_device && keep_looping < 0)
{
card_list_w_unlock ();
break;
}
send_status_direct (ctrl, "DEVINFO_START", "");
for (c = card_top; c; c = c->next)
@ -452,13 +448,11 @@ app_send_devinfo (ctrl_t ctrl, int keep_looping)
send_status_direct (ctrl, "DEVINFO_END", "");
if (no_device && !keep_looping)
{
card_list_w_unlock ();
break;
}
card_list_wait ();
card_list_w_unlock ();
}
card_list_w_unlock ();
return no_device ? gpg_error (GPG_ERR_NOT_FOUND): 0;
}