Skip to contentSkip to conversation

misc/TI-ST: Adjustments for three function implementations

PATCH New SF Markus Elfring 1 participant 4 messages Jan 10, 2018

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

cover misc/TI-ST: Adjustments for three function implementations

From: Markus Elfring <[email protected]>
Date: Wed, 10 Jan 2018 16:26:36 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Delete an error message for a failed memory allocation in kim_probe() Improve a size determination in kim_probe()
Delete an unnecessary return statement in two functions

 drivers/misc/ti-st/st_kim.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/3 misc/ti-st: Delete an error message for a failed memory allocation in kim_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 10 Jan 2018 16:04:52 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/misc/ti-st/st_kim.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/misc/ti-st/st_kim.c +2 -3
index b77aacafc3fc..68ebdf466b17 100644
@@ -736,10 +736,9 @@ static int kim_probe(struct platform_device *pdev)
 	}
 
 	kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC);
-	if (!kim_gdata) {
-		pr_err("no mem to allocate");
+	if (!kim_gdata)
 		return -ENOMEM;
-	}
+
 	platform_set_drvdata(pdev, kim_gdata);
 
 	err = st_core_init(&kim_gdata->core_data);
Signature · 1 line
2.15.1
#2 lore raw

PATCH 2/3 misc/ti-st: Improve a size determination in kim_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 10 Jan 2018 16:10:45 +0100

Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 drivers/misc/ti-st/st_kim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/ti-st/st_kim.c +1 -1
index 68ebdf466b17..948e3461d02e 100644
@@ -735,7 +735,7 @@ static int kim_probe(struct platform_device *pdev)
 		st_kim_devices[0] = pdev;
 	}
 
-	kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC);
+	kim_gdata = kzalloc(sizeof(*kim_gdata), GFP_ATOMIC);
 	if (!kim_gdata)
 		return -ENOMEM;
 
Signature · 1 line
2.15.1
#3 lore raw

PATCH 3/3 misc/ti-st: Delete an unnecessary return statement in two functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 10 Jan 2018 16:16:55 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected functions.

---
 drivers/misc/ti-st/st_kim.c | 2 --
 1 file changed, 2 deletions(-)
drivers/misc/ti-st/st_kim.c +0 -2
index 948e3461d02e..e33eb4bcb608 100644
@@ -206,7 +206,6 @@ static void kim_int_recv(struct kim_data_s *kim_gdata,
 		kim_gdata->rx_skb->cb[1] = 0;
 
 	}
-	return;
 }
 
 static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
@@ -436,7 +435,6 @@ void st_kim_recv(void *disc_data, const unsigned char *data, long count)
 	 * from other fw responses when data gathering is complete
 	 */
 	kim_int_recv(kim_gdata, data, count);
-	return;
 }
 
 /* to signal completion of line discipline installation
Signature · 1 line
2.15.1