Skip to contentSkip to conversation

NFC: microread: Pass err variable to async_cb()

PATCH In review Nigel Christian 3 participants 4 messages Jun 1, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFC: microread: Pass err variable to async_cb()

In the case MICROREAD_CB_TYPE_READER_ALL clang reports a dead code warning. The error code is being directly passed to async_cb(). Fix this by passing the err variable, which is also done in another path.

Addresses-Coverity: ("Unused value")

---
 drivers/nfc/microread/microread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/microread/microread.c +1 -1
index 8d3988457c58..130b0f554016 100644
@@ -367,7 +367,7 @@ static void microread_im_transceive_cb(void *context, struct sk_buff *skb,
 				err = -EPROTO;
 				kfree_skb(skb);
 				info->async_cb(info->async_cb_context, NULL,
-					       -EPROTO);
+					       err);
 				return;
 			}
 
Signature · 1 line
2.31.1
#1 lore raw
Quoted 16 lines · Nigel Christian

In the case MICROREAD_CB_TYPE_READER_ALL clang reports a dead code warning. The error code is being directly passed to async_cb(). Fix this by passing the err variable, which is also done in another path.

Addresses-Coverity: ("Unused value")

---
 drivers/nfc/microread/microread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/microread/microread.c +0 -0
index 8d3988457c58..130b0f554016 100644

drivers/nfc/microread/microread.c static void microread_im_transceive_cb(void *context, struct sk_buff *skb, · line 367

Quoted 1 line
drivers/nfc/microread/microread.c +0 -0
@@ -367,7 +367,7 @@ static void microread_im_transceive_cb(void *context, struct sk_buff *skb,
 				err = -EPROTO;

Remove this line instead, please. The err is argument passed by value so assigning it within a function is ugly.

drivers/nfc/microread/microread.c static void microread_im_transceive_cb(void *context, struct sk_buff *skb, · line 373

Quoted 8 lines
drivers/nfc/microread/microread.c +1 -1
 				kfree_skb(skb);
 				info->async_cb(info->async_cb_context, NULL,
-					       -EPROTO);
+					       err);
 				return;
 			}
 

Best regards,
Krzysztof

#2 lore raw
In reply to Nigel Christian
Quoted 16 lines · Nigel Christian

In the case MICROREAD_CB_TYPE_READER_ALL clang reports a dead code warning. The error code is being directly passed to async_cb(). Fix this by passing the err variable, which is also done in another path.

Addresses-Coverity: ("Unused value")

---
 drivers/nfc/microread/microread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/microread/microread.c +0 -0
index 8d3988457c58..130b0f554016 100644

drivers/nfc/microread/microread.c static void microread_im_transceive_cb(void *context, struct sk_buff *skb, · line 370

Quoted 5 lines
drivers/nfc/microread/microread.c +1 -1
@@ -367,7 +367,7 @@ static void microread_im_transceive_cb(void *context, struct sk_buff *skb,
 				err = -EPROTO;
 				kfree_skb(skb);
 				info->async_cb(info->async_cb_context, NULL,
-					       -EPROTO);
+					       err);

It would be better to just delete the "err = -EPROTO;" assignment.

Literals are more readable. Avoid pointless indirection.

regards,
dan carpenter

#3 lore raw
Quoted 25 lines · Dan Carpenter
Quoted 16 lines · Nigel Christian

In the case MICROREAD_CB_TYPE_READER_ALL clang reports a dead code warning. The error code is being directly passed to async_cb(). Fix this by passing the err variable, which is also done in another path.

Addresses-Coverity: ("Unused value")

---
 drivers/nfc/microread/microread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/microread/microread.c +0 -0
index 8d3988457c58..130b0f554016 100644

drivers/nfc/microread/microread.c static void microread_im_transceive_cb(void *context, struct sk_buff *skb, · line 370

Quoted 5 lines
drivers/nfc/microread/microread.c +1 -1
@@ -367,7 +367,7 @@ static void microread_im_transceive_cb(void *context, struct sk_buff *skb,
 				err = -EPROTO;
 				kfree_skb(skb);
 				info->async_cb(info->async_cb_context, NULL,
-					       -EPROTO);
+					       err);

It would be better to just delete the "err = -EPROTO;" assignment.

Quoted 1 line

Literals are more readable. Avoid pointless indirection.

Yeah, my bad. v2 sent! Thanks Dan!

Quoted 5 lines

regards,
dan carpenter