linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix a few smatch warnings
@ 2019-06-13 13:03 Sakari Ailus
  2019-06-13 13:03 ` [PATCH 1/2] v4l2-fwnode: Avoid using PTR_ERR(NULL) Sakari Ailus
  2019-06-13 13:04 ` [PATCH 2/2] ov9640: Don't check for NULL on devm_gpiod_get return values Sakari Ailus
  0 siblings, 2 replies; 4+ messages in thread
From: Sakari Ailus @ 2019-06-13 13:03 UTC (permalink / raw)
  To: linux-media; +Cc: hverkuil

Hi,

This small set fixes a few trivial smatch warnings. They're not really
bugs either but changing the code cleans it up as well.

Sakari Ailus (2):
  v4l2-fwnode: Avoid using PTR_ERR(NULL)
  ov9640: Don't check for NULL on devm_gpiod_get return values

 drivers/media/i2c/ov9640.c            | 4 ++--
 drivers/media/v4l2-core/v4l2-fwnode.c | 6 +-----
 2 files changed, 3 insertions(+), 7 deletions(-)

-- 
2.11.0


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

* [PATCH 1/2] v4l2-fwnode: Avoid using PTR_ERR(NULL)
  2019-06-13 13:03 [PATCH 0/2] Fix a few smatch warnings Sakari Ailus
@ 2019-06-13 13:03 ` Sakari Ailus
  2019-06-13 13:22   ` [PATCH v1.1 " Sakari Ailus
  2019-06-13 13:04 ` [PATCH 2/2] ov9640: Don't check for NULL on devm_gpiod_get return values Sakari Ailus
  1 sibling, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2019-06-13 13:03 UTC (permalink / raw)
  To: linux-media; +Cc: hverkuil

PTR_ERR(NULL) yields 0 which is commonly used to denote success. This is
the case here, and PTR_ERR(NULL) is apparently shunned upon. Fix this by
explicitly returning 0 if fwnode == NULL.

Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index dea8917fd912..fed71943983a 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -1098,11 +1098,7 @@ v4l2_fwnode_reference_parse_int_props(struct device *dev,
 		}
 	}
 
-	return PTR_ERR(fwnode) == -ENOENT ? 0 : PTR_ERR(fwnode);
-
-error:
-	fwnode_handle_put(fwnode);
-	return ret;
+	return !fwnode || PTR_ERR(fwnode) == -ENOENT ? 0 : PTR_ERR(fwnode);
 }
 
 int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev,
-- 
2.11.0


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

* [PATCH 2/2] ov9640: Don't check for NULL on devm_gpiod_get return values
  2019-06-13 13:03 [PATCH 0/2] Fix a few smatch warnings Sakari Ailus
  2019-06-13 13:03 ` [PATCH 1/2] v4l2-fwnode: Avoid using PTR_ERR(NULL) Sakari Ailus
@ 2019-06-13 13:04 ` Sakari Ailus
  1 sibling, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2019-06-13 13:04 UTC (permalink / raw)
  To: linux-media; +Cc: hverkuil

devm_gpiod_get never returns NULL; therefore it's not necessary to check
for that. PTR_ERR(NULL) also yields zero, which is confusing to smatch.

Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/ov9640.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ov9640.c b/drivers/media/i2c/ov9640.c
index d6831f28378b..482609665305 100644
--- a/drivers/media/i2c/ov9640.c
+++ b/drivers/media/i2c/ov9640.c
@@ -691,14 +691,14 @@ static int ov9640_probe(struct i2c_client *client,
 
 	priv->gpio_power = devm_gpiod_get(&client->dev, "Camera power",
 					  GPIOD_OUT_LOW);
-	if (IS_ERR_OR_NULL(priv->gpio_power)) {
+	if (IS_ERR(priv->gpio_power)) {
 		ret = PTR_ERR(priv->gpio_power);
 		return ret;
 	}
 
 	priv->gpio_reset = devm_gpiod_get(&client->dev, "Camera reset",
 					  GPIOD_OUT_HIGH);
-	if (IS_ERR_OR_NULL(priv->gpio_reset)) {
+	if (IS_ERR(priv->gpio_reset)) {
 		ret = PTR_ERR(priv->gpio_reset);
 		return ret;
 	}
-- 
2.11.0


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

* [PATCH v1.1 1/2] v4l2-fwnode: Avoid using PTR_ERR(NULL)
  2019-06-13 13:03 ` [PATCH 1/2] v4l2-fwnode: Avoid using PTR_ERR(NULL) Sakari Ailus
@ 2019-06-13 13:22   ` Sakari Ailus
  0 siblings, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2019-06-13 13:22 UTC (permalink / raw)
  To: linux-media; +Cc: hverkuil

PTR_ERR(NULL) yields 0 which is commonly used to denote success. This is
the case here, and PTR_ERR(NULL) is apparently shunned upon. Fix this by
explicitly returning 0 if fwnode == NULL.

Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
since v1:

- Fix rebase mess.

 drivers/media/v4l2-core/v4l2-fwnode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index dea8917fd912..a46b713a7fbf 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -1098,7 +1098,7 @@ v4l2_fwnode_reference_parse_int_props(struct device *dev,
 		}
 	}
 
-	return PTR_ERR(fwnode) == -ENOENT ? 0 : PTR_ERR(fwnode);
+	return !fwnode || PTR_ERR(fwnode) == -ENOENT ? 0 : PTR_ERR(fwnode);
 
 error:
 	fwnode_handle_put(fwnode);
-- 
2.11.0


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

end of thread, other threads:[~2019-06-13 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 13:03 [PATCH 0/2] Fix a few smatch warnings Sakari Ailus
2019-06-13 13:03 ` [PATCH 1/2] v4l2-fwnode: Avoid using PTR_ERR(NULL) Sakari Ailus
2019-06-13 13:22   ` [PATCH v1.1 " Sakari Ailus
2019-06-13 13:04 ` [PATCH 2/2] ov9640: Don't check for NULL on devm_gpiod_get return values Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).