[PATCH] NFC: microread: Pass err variable to async_cb()

Subsystems: nfc subsystem, the rest

STALE1897d

3 messages, 3 authors, 2021-06-01 · open the first message on its own page

[PATCH] NFC: microread: Pass err variable to async_cb()

From: Nigel Christian <hidden>
Date: 2021-06-01 13:00:39

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") 
Signed-off-by: Nigel Christian <redacted>
---
 drivers/nfc/microread/microread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c
index 8d3988457c58..130b0f554016 100644
--- a/drivers/nfc/microread/microread.c
+++ b/drivers/nfc/microread/microread.c
@@ -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;
 			}
 
-- 
2.31.1

Re: [PATCH] NFC: microread: Pass err variable to async_cb()

From: Krzysztof Kozlowski <hidden>
Date: 2021-06-01 13:07:56

On 01/06/2021 15:00, Nigel Christian wrote:
quoted hunk
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") 
Signed-off-by: Nigel Christian <redacted>
---
 drivers/nfc/microread/microread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c
index 8d3988457c58..130b0f554016 100644
--- a/drivers/nfc/microread/microread.c
+++ b/drivers/nfc/microread/microread.c
@@ -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.
 				kfree_skb(skb);
 				info->async_cb(info->async_cb_context, NULL,
-					       -EPROTO);
+					       err);
 				return;
 			}
 

Best regards,
Krzysztof

Re: [PATCH] NFC: microread: Pass err variable to async_cb()

From: Dan Carpenter <hidden>
Date: 2021-06-01 13:38:16

On Tue, Jun 01, 2021 at 09:00:33AM -0400, Nigel Christian wrote:
quoted hunk
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") 
Signed-off-by: Nigel Christian <redacted>
---
 drivers/nfc/microread/microread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c
index 8d3988457c58..130b0f554016 100644
--- a/drivers/nfc/microread/microread.c
+++ b/drivers/nfc/microread/microread.c
@@ -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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help