smartcard: Improve on_message_from_device readability

This removes a not really useful switch/case, and changes the function
to exit early on error cases, rather than exiting early in the nominal
case.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Christophe Fergeau 2019-02-08 17:26:27 +01:00 committed by Frediano Ziglio
parent 6c79fd31e0
commit 9a605dcc67

View File

@ -198,11 +198,8 @@ RedMsgItem *smartcard_char_device_on_message_from_device(RedCharDeviceSmartcard
vheader->length = ntohl(vheader->length);
vheader->reader_id = ntohl(vheader->reader_id);
switch (vheader->type) {
case VSC_Init:
return NULL;
default:
break;
if (vheader->type == VSC_Init) {
return NULL;
}
/* We pass any VSC_Error right now - might need to ignore some? */
if (dev->priv->reader_id == VSCARD_UNDEFINED_READER_ID) {
@ -210,10 +207,10 @@ RedMsgItem *smartcard_char_device_on_message_from_device(RedCharDeviceSmartcard
"error: reader_id not assigned for message of type %d",
vheader->type);
}
if (dev->priv->scc) {
return smartcard_new_vsc_msg_item(dev->priv->reader_id, vheader);
if (dev->priv->scc == NULL) {
return NULL;
}
return NULL;
return smartcard_new_vsc_msg_item(dev->priv->reader_id, vheader);
}
static int smartcard_char_device_add_to_readers(RedsState *reds, SpiceCharDeviceInstance *char_device)