Skip to contentSkip to conversation

ADV7...: Adjustments for four function implementations

PATCH New SF Markus Elfring 1 participant 5 messages Sep 2, 2017

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

cover ADV7...: Adjustments for four function implementations

From: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 14:49:43 +0200

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

Markus Elfring (4):
Delete an error message for a failed memory allocation in adv76xx_probe() Adjust a null pointer check in three functions
Delete an error message for a failed memory allocation in adv7842_probe() Improve a size determination in adv7842_probe()

 drivers/media/i2c/adv7604.c | 10 ++++------
 drivers/media/i2c/adv7842.c |  6 ++----
 2 files changed, 6 insertions(+), 10 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/4 adv7604: Delete an error message for a failed memory allocation in adv76xx_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 11:28:55 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/media/i2c/adv7604.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/i2c/adv7604.c +1 -3
index 660bacb8f7d9..cc693ef71f33 100644
@@ -3319,7 +3319,5 @@ static int adv76xx_probe(struct i2c_client *client,
-	if (!state) {
-		v4l_err(client, "Could not allocate adv76xx_state memory!\n");
+	if (!state)
 		return -ENOMEM;
-	}
 
 	state->i2c_clients[ADV76XX_PAGE_IO] = client;
 
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/4 adv7604: Adjust a null pointer check in three functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 11:43:00 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

---
 drivers/media/i2c/adv7604.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/i2c/adv7604.c +3 -3
index cc693ef71f33..0a774d025858 100644
@@ -1948,7 +1948,7 @@ static int adv76xx_set_format(struct v4l2_subdev *sd,
 		return -EINVAL;
 
 	info = adv76xx_format_info(state, format->format.code);
-	if (info = NULL)
+	if (!info)
 		info = adv76xx_format_info(state, MEDIA_BUS_FMT_YUYV8_2X8);
 
 	adv76xx_fill_format(state, &format->format);
@@ -2256,7 +2256,7 @@ static int adv76xx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
 		return 0;
 	}
 
-	if (data = NULL)
+	if (!data)
 		return -ENODATA;
 
 	if (edid->start_block >= state->edid.blocks)
@@ -3480,7 +3480,7 @@ static int adv76xx_probe(struct i2c_client *client,
 		state->i2c_clients[i]  			adv76xx_dummy_client(sd, state->pdata.i2c_addresses[i],
 					     0xf2 + i);
-		if (state->i2c_clients[i] = NULL) {
+		if (!state->i2c_clients[i]) {
 			err = -ENOMEM;
 			v4l2_err(sd, "failed to create i2c client %u\n", i);
 			goto err_i2c;
Signature · 1 line
2.14.1
#3 lore raw

PATCH 3/4 adv7842: Delete an error message for a failed memory allocation in adv7842_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 12:50:19 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/media/i2c/adv7842.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/i2c/adv7842.c +1 -3
index 303effda1a2e..366a294edd7b 100644
@@ -3471,7 +3471,5 @@ static int adv7842_probe(struct i2c_client *client,
-	if (!state) {
-		v4l_err(client, "Could not allocate adv7842_state memory!\n");
+	if (!state)
 		return -ENOMEM;
-	}
 
 	/* platform data */
 	state->pdata = *pdata;
Signature · 1 line
2.14.1
#4 lore raw

PATCH 4/4 adv7842: Improve a size determination in adv7842_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 12:53:15 +0200

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/media/i2c/adv7842.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/adv7842.c +1 -1
index 366a294edd7b..aa8b3bcdd750 100644
@@ -3467,5 +3467,5 @@ static int adv7842_probe(struct i2c_client *client,
 		return -ENODEV;
 	}
 
-	state = devm_kzalloc(&client->dev, sizeof(struct adv7842_state), GFP_KERNEL);
+	state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
 	if (!state)
Signature · 1 line
2.14.1