Skip to contentSkip to conversation

media: ti: cal: remove unnecessary error check

PATCH In review Dan Carpenter 2 participants 2 messages Sep 22 – Sep 23

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

PATCH 1/1 media: ti: cal: remove unnecessary error check

The v4l2_subdev_lock_and_get_active_state() function never returns error pointers. As the comments explain, it "returns the locked active state for the subdevice, or NULL if the subdev does not support active state." None of the other callers check for an error pointer return.

Delete this unnecessary check.

---
I feel like if we don't delete the IS_ERR() check someone will eventually try to convert it into a NULL check which would be a bug.

 drivers/media/platform/ti/cal/cal-video.c | 2 --
 1 file changed, 2 deletions(-)
drivers/media/platform/ti/cal/cal-video.c +0 -2
index 59f0cc4f0d1a..1990cab77344 100644
@@ -130,8 +130,6 @@ static int cal_call_active_state_set_fmt(struct v4l2_subdev *source,
 	int ret;
 
 	source_state = v4l2_subdev_lock_and_get_active_state(source);
-	if (IS_ERR(source_state))
-		return PTR_ERR(source_state);
 
 	ret = v4l2_subdev_call(source, pad, set_fmt, NULL, source_state, fmt);
 	if (source_state)
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Dan,
Thank you for the patch.

Quoted 5 lines · Dan Carpenter

The v4l2_subdev_lock_and_get_active_state() function never returns error pointers. As the comments explain, it "returns the locked active state for the subdevice, or NULL if the subdev does not support active state." None of the other callers check for an error pointer return.

Quoted 7 lines

Delete this unnecessary check.

---
I feel like if we don't delete the IS_ERR() check someone will eventually try to convert it into a NULL check which would be a bug.

It makes sense for me. Hence

Thanks and regards,
Yemike Abhilash Chandra

Quoted 16 lines
  drivers/media/platform/ti/cal/cal-video.c | 2 --
  1 file changed, 2 deletions(-)
drivers/media/platform/ti/cal/cal-video.c +0 -2
index 59f0cc4f0d1a..1990cab77344 100644
@@ -130,8 +130,6 @@ static int cal_call_active_state_set_fmt(struct v4l2_subdev *source,
  	int ret;
 
  	source_state = v4l2_subdev_lock_and_get_active_state(source);
-	if (IS_ERR(source_state))
-		return PTR_ERR(source_state);
 
  	ret = v4l2_subdev_call(source, pad, set_fmt, NULL, source_state, fmt);
  	if (source_state)