Re: [PATCH v2 08/26] media: v4l2-async: shut up an unitialized symbol warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Thu, 02 Nov 2017 04:51:40 +0200
Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Wednesday, 1 November 2017 23:05:45 EET Mauro Carvalho Chehab wrote:
> > Smatch reports this warning:
> > 	drivers/media/v4l2-core/v4l2-async.c:597 v4l2_async_register_subdev()
> > error: uninitialized symbol 'ret'.
> > 
> > However, there's nothing wrong there. So, just shut up the
> > warning.  
> 
> Nothing wrong, really ? ret does seem to be used uninitialized when the 
> function returns at the very last line.

There's nothing wrong. If you follow the logic, you'll see that
the line:

	return ret;

is called only at "err_unbind" label, with is called only on
two places:

                ret = v4l2_async_match_notify(notifier, v4l2_dev, sd, asd);
                if (ret)
                        goto err_unbind;

                ret = v4l2_async_notifier_try_complete(notifier);
                if (ret)
                        goto err_unbind;

There, ret is defined.

Yeah, the logic there is confusing.

Thanks,
Mauro

media: v4l2-async: shut up an unitialized symbol warning

Smatch reports this warning:
	drivers/media/v4l2-core/v4l2-async.c:597 v4l2_async_register_subdev() error: uninitialized symbol 'ret'.

However, there's nothing wrong there. Yet, the logic is more
complex than it should. So, rework it to make clearer about
what happens when ret != 0.

Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxxx>
---
 drivers/media/v4l2-core/v4l2-async.c |   38 +++++++++++++++--------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

--- patchwork.orig/drivers/media/v4l2-core/v4l2-async.c
+++ patchwork/drivers/media/v4l2-core/v4l2-async.c
@@ -532,7 +532,7 @@ int v4l2_async_register_subdev(struct v4
 {
 	struct v4l2_async_notifier *subdev_notifier;
 	struct v4l2_async_notifier *notifier;
-	int ret;
+	int ret = 0;
 
 	/*
 	 * No reference taken. The reference is held by the device
@@ -560,11 +560,11 @@ int v4l2_async_register_subdev(struct v4
 
 		ret = v4l2_async_match_notify(notifier, v4l2_dev, sd, asd);
 		if (ret)
-			goto err_unbind;
+			break;
 
 		ret = v4l2_async_notifier_try_complete(notifier);
 		if (ret)
-			goto err_unbind;
+			break;
 
 		goto out_unlock;
 	}
@@ -572,26 +572,22 @@ int v4l2_async_register_subdev(struct v4
 	/* None matched, wait for hot-plugging */
 	list_add(&sd->async_list, &subdev_list);
 
-out_unlock:
-	mutex_unlock(&list_lock);
-
-	return 0;
-
-err_unbind:
-	/*
-	 * Complete failed. Unbind the sub-devices bound through registering
-	 * this async sub-device.
-	 */
-	subdev_notifier = v4l2_async_find_subdev_notifier(sd);
-	if (subdev_notifier)
-		v4l2_async_notifier_unbind_all_subdevs(subdev_notifier);
-
-	if (sd->asd)
-		v4l2_async_notifier_call_unbind(notifier, sd, sd->asd);
-	v4l2_async_cleanup(sd);
+	if (ret) {
+		/*
+		 * Complete failed. Unbind the sub-devices bound through registering
+		 * this async sub-device.
+		 */
+		subdev_notifier = v4l2_async_find_subdev_notifier(sd);
+		if (subdev_notifier)
+			v4l2_async_notifier_unbind_all_subdevs(subdev_notifier);
+
+		if (sd->asd)
+			v4l2_async_notifier_call_unbind(notifier, sd, sd->asd);
+		v4l2_async_cleanup(sd);
+	}
 
+out_unlock:
 	mutex_unlock(&list_lock);
-
 	return ret;
 }
 EXPORT_SYMBOL(v4l2_async_register_subdev);






[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux