All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: "Linux Media Mailing List" <linux-media@vger.kernel.org>,
	"Mauro Carvalho Chehab" <mchehab@infradead.org>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Hans Verkuil" <hans.verkuil@cisco.com>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	"Sebastian Reichel" <sre@kernel.org>
Subject: Re: [PATCH v2 08/26] media: v4l2-async: shut up an unitialized symbol warning
Date: Mon, 11 Dec 2017 16:10:58 -0200	[thread overview]
Message-ID: <20171211161058.6cdedb7a@vento.lan> (raw)
In-Reply-To: <1844403.anYkCZaVIn@avalon>

Em Thu, 02 Nov 2017 04:51:40 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> 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@s-opensource.com>
---
 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);

  parent reply	other threads:[~2017-12-11 18:11 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 20:56 [PATCH v2 01/26] media: atmel-isc: avoid returning a random value at isc_parse_dt() Mauro Carvalho Chehab
2017-11-01 20:59 ` Mauro Carvalho Chehab
2017-11-01 21:03   ` Mauro Carvalho Chehab
2017-11-01 21:07   ` Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 02/26] media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code Mauro Carvalho Chehab
2017-11-01 21:05   ` Mauro Carvalho Chehab
2017-11-07 18:29   ` Daniel Scheller
2017-11-01 21:05 ` [PATCH v2 03/26] media: led-class-flash: better handle NULL flash struct Mauro Carvalho Chehab
2017-11-02  9:08   ` Sakari Ailus
2017-11-01 21:05 ` [PATCH v2 04/26] media: tda8290: initialize agc gain Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 05/26] media: s5c73m3-core: fix logic on a timeout condition Mauro Carvalho Chehab
2017-11-02  7:12   ` Andrzej Hajda
2017-11-01 21:05 ` [PATCH v2 06/26] media: xc5000: better handle I2C error messages Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 07/26] media: radio-si476x: fix behavior when seek->range* are defined Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 08/26] media: v4l2-async: shut up an unitialized symbol warning Mauro Carvalho Chehab
2017-11-02  2:51   ` Laurent Pinchart
2017-11-02  8:49     ` Sakari Ailus
2017-12-11 18:10     ` Mauro Carvalho Chehab [this message]
2017-12-11 22:13       ` Laurent Pinchart
2017-12-14 12:12         ` Sakari Ailus
2017-11-01 21:05 ` [PATCH v2 09/26] media: cx25821-alsa: fix usage of a pointer printk Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 10/26] media: xc4000: don't ignore error if hwmodel fails Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 11/26] media: qt1010: fix bogus warnings Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 12/26] media: davinci: fix a debug printk Mauro Carvalho Chehab
2017-11-09 21:33   ` Lad, Prabhakar
2017-11-01 21:05 ` [PATCH v2 13/26] media: rcar: " Mauro Carvalho Chehab
2017-11-01 21:05   ` Mauro Carvalho Chehab
2017-11-02  8:15   ` Niklas Söderlund
2017-11-02  8:15     ` Niklas Söderlund
2017-11-01 21:05 ` [PATCH v2 14/26] media: xilinx: " Mauro Carvalho Chehab
2017-11-01 21:05   ` Mauro Carvalho Chehab
2017-11-02  2:43   ` Laurent Pinchart
2017-11-02  2:43     ` Laurent Pinchart
2017-11-02  9:20     ` Sakari Ailus
2017-11-02  9:20       ` Sakari Ailus
2017-11-02  9:57     ` [PATCH 1/1] of: Make return types of to_of_node and of_fwnode_handle macros consistent Sakari Ailus
2017-11-02  9:57       ` Sakari Ailus
2017-11-02  9:57       ` Sakari Ailus
2017-11-02  9:59     ` [RESEND PATCH " Sakari Ailus
2017-11-02  9:59       ` Sakari Ailus
2017-11-02  9:59       ` Sakari Ailus
2017-11-02 17:37       ` Laurent Pinchart
2017-11-02 17:37         ` Laurent Pinchart
2017-11-06 21:45       ` Rob Herring
2017-11-06 21:45         ` Rob Herring
2017-11-01 21:05 ` [PATCH v2 15/26] media: pt1: fix logic when pt1_nr_tables is zero or negative Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 16/26] media: drxd_hard: better handle I2C errors Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 17/26] media: mxl111sf: improve error handling logic Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 18/26] media: dvbsky: shut up a bogus warning Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 19/26] media: ov9650: fix bogus warnings Mauro Carvalho Chehab
2017-11-02 10:06   ` Nicholas Mc Guire
2017-11-02 10:22     ` Nicholas Mc Guire
2017-11-01 21:05 ` [PATCH v2 20/26] media: imx274: don't randomly return if range_count is zero Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 21/26] media: m88rs2000: handle the case where tuner doesn't have get_frequency Mauro Carvalho Chehab
2017-11-01 21:05 ` [PATCH v2 22/26] [RFC] media: cxd2841er: ensure that status will always be available Mauro Carvalho Chehab
2017-11-01 21:06 ` [PATCH v2 23/26] media: drxj: better handle errors Mauro Carvalho Chehab
2017-11-01 21:06 ` [PATCH v2 24/26] media: stv090x: Only print tuner lock if get_status is available Mauro Carvalho Chehab
2017-11-01 21:06 ` [PATCH v2 25/26] media: mb86a16: be more resilient if I2C fails on sync Mauro Carvalho Chehab
2017-11-01 21:06 ` [PATCH v2 26/26] media: mb86a16: avoid division by zero Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171211161058.6cdedb7a@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=hans.verkuil@cisco.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.