mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] NFC: fdp: fix handling return value of fdp_nci_create_conn
@ 2015-12-10  7:53 Andrzej Hajda
  2015-12-10  8:35 ` [PATCH v2] " Andrzej Hajda
  0 siblings, 1 reply; 2+ messages in thread
From: Andrzej Hajda @ 2015-12-10  7:53 UTC (permalink / raw)
  To: open list:NFC SUBSYSTEM
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz,
	open list

The function can return negative values, so its result should
be assigned to signed variable.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/nfc/fdp/fdp.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
index ccb07a1..440fac3 100644
--- a/drivers/nfc/fdp/fdp.c
+++ b/drivers/nfc/fdp/fdp.c
@@ -368,11 +368,10 @@ static int fdp_nci_patch_otp(struct nci_dev *ndev)
 		goto out;
 
 	/* Patch data connection creation */
-	conn_id = fdp_nci_create_conn(ndev);
-	if (conn_id < 0) {
-		r = conn_id;
+	r = fdp_nci_create_conn(ndev);
+	if (r < 0)
 		goto out;
-	}
+	conn_id = r;
 
 	/* Send the patch over the data connection */
 	r = fdp_nci_send_patch(ndev, conn_id, NCI_PATCH_TYPE_OTP);
@@ -439,11 +438,10 @@ static int fdp_nci_patch_ram(struct nci_dev *ndev)
 		goto out;
 
 	/* Patch data connection creation */
-	conn_id = fdp_nci_create_conn(ndev);
-	if (conn_id < 0) {
-		r = conn_id;
-		goto out;
-	}
+	r = fdp_nci_create_conn(ndev);
+	if (r < 0)
+		got out;
+	conn_id = r;
 
 	/* Send the patch over the data connection */
 	r = fdp_nci_send_patch(ndev, conn_id, NCI_PATCH_TYPE_RAM);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-10  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-10  7:53 [PATCH] NFC: fdp: fix handling return value of fdp_nci_create_conn Andrzej Hajda
2015-12-10  8:35 ` [PATCH v2] " Andrzej Hajda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®