Skip to contentSkip to conversation

video: ssd1307fb: Adjustments for ssd1307fb_probe()

PATCH In review SF Markus Elfring 2 participants 7 messages Nov 25, 2017 – Mar 28, 2018

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

cover video: ssd1307fb: Adjustments for ssd1307fb_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 25 Nov 2017 16:56:46 +0100

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

Markus Elfring (2):
Delete an error message for a failed memory allocation Improve a size determination

 drivers/video/fbdev/ssd1307fb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.15.0
#1 lore raw

PATCH 1/2 video: ssd1307fb: Delete an error message for a failed memory allocation in ssd1307fb_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 25 Nov 2017 16:45:56 +0100

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

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/ssd1307fb.c | 1 -
 1 file changed, 1 deletion(-)
drivers/video/fbdev/ssd1307fb.c +0 -1
index f599520374dd..fb0ef1922d49 100644
@@ -630,7 +630,6 @@ static int ssd1307fb_probe(struct i2c_client *client,
 
 	ssd1307fb_defio = devm_kzalloc(&client->dev, sizeof(struct fb_deferred_io), GFP_KERNEL);
 	if (!ssd1307fb_defio) {
-		dev_err(&client->dev, "Couldn't allocate deferred io.\n");
 		ret = -ENOMEM;
 		goto fb_alloc_error;
 	}
Signature · 1 line
2.15.0
#2 lore raw

PATCH 2/2 video: ssd1307fb: Improve a size determination in ssd1307fb_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 25 Nov 2017 16:50:26 +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/video/fbdev/ssd1307fb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/fbdev/ssd1307fb.c +2 -1
index fb0ef1922d49..bb32b2dd1f7a 100644
@@ -628,7 +628,8 @@ static int ssd1307fb_probe(struct i2c_client *client,
 		goto fb_alloc_error;
 	}
 
-	ssd1307fb_defio = devm_kzalloc(&client->dev, sizeof(struct fb_deferred_io), GFP_KERNEL);
+	ssd1307fb_defio = devm_kzalloc(&client->dev, sizeof(*ssd1307fb_defio),
+				       GFP_KERNEL);
 	if (!ssd1307fb_defio) {
 		ret = -ENOMEM;
 		goto fb_alloc_error;
Signature · 1 line
2.15.0
#3 lore raw
In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 25 Nov 2017 16:56:46 +0100

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

Markus Elfring (2):
Delete an error message for a failed memory allocation

This patch removes the information about the device for which the allocation fails.

Quoted 1 line

Improve a size determination

This patch depends on the earlier patch (which is not being merged) so please re-base it if you want it to be applied.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

#4 lore raw
Quoted 3 lines
Quoted 1 line

Delete an error message for a failed memory allocation

This patch removes the information about the device for which the allocation fails.

How do you think about to take another look if a Linux allocation failure report could be sufficient in this use case?

Quoted 3 lines
Quoted 1 line

Improve a size determination

This patch depends on the earlier patch (which is not being merged)

Partly, yes.

Quoted 1 line

so please re-base it if you want it to be applied.

Would you dare to reduce any context lines for this update step so that such a small adjustment will still work?

Regards,
Markus

#5 lore raw

PATCH v2 1/1 video: ssd1307fb: Improve a size determination in ssd1307fb_probe()

In reply to Bartlomiej Zolnierkiewicz

From: Markus Elfring <[email protected]>
Date: Sun, 7 Jan 2018 19:27:28 +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.

---

v2:
This update suggestion was rebased on source files from the software "Linux next-20180105".

 drivers/video/fbdev/ssd1307fb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/fbdev/ssd1307fb.c +2 -1
index f599520374dd..6439231f2db2 100644
@@ -628,7 +628,8 @@ static int ssd1307fb_probe(struct i2c_client *client,
 		goto fb_alloc_error;
 	}
 
-	ssd1307fb_defio = devm_kzalloc(&client->dev, sizeof(struct fb_deferred_io), GFP_KERNEL);
+	ssd1307fb_defio = devm_kzalloc(&client->dev, sizeof(*ssd1307fb_defio),
+				       GFP_KERNEL);
 	if (!ssd1307fb_defio) {
 		dev_err(&client->dev, "Couldn't allocate deferred io.\n");
 		ret = -ENOMEM;
Signature · 1 line
2.15.1
#6 lore raw

Re: [PATCH v2] video: ssd1307fb: Improve a size determination in ssd1307fb_probe()

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 7 Jan 2018 19:27:28 +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.

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics