All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Daney <ddaney-M3mlKVOIwJVv6pq1l3V1OdBPR1lH4CV8@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: David Daney
	<david.s.daney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Justin P. Mattock"
	<justinmattock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	reiserfs-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	clemens-P6GI/4k7KOmELgA04lAiVw@public.gmane.org,
	debora-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux1394-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
Date: Tue, 15 Jun 2010 09:20:39 -0700	[thread overview]
Message-ID: <4C17A857.8030306@caviumnetworks.com> (raw)
In-Reply-To: <20100615134039.6ccfc17a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>

On 06/15/2010 04:40 AM, Jean Delvare wrote:
> Hi David,
>
> On Mon, 14 Jun 2010 14:28:57 -0700, David Daney wrote:
>> On 06/14/2010 01:53 PM, Jean Delvare wrote:
>>> Hi Justin,
>>>
>>> On Mon, 14 Jun 2010 13:26:46 -0700, Justin P. Mattock wrote:
>>>> could be a right solution, could be wrong
>>>> here is the warning:
>>>>     CC      drivers/i2c/i2c-core.o
>>>> drivers/i2c/i2c-core.c: In function 'i2c_register_adapter':
>>>> drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not used
>>>>
>>>>    Signed-off-by: Justin P. Mattock<justinmattock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>
>>>> ---
>>>>    drivers/i2c/i2c-core.c |    2 ++
>>>>    1 files changed, 2 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>>>> index 1cca263..79c6c26 100644
>>>> --- a/drivers/i2c/i2c-core.c
>>>> +++ b/drivers/i2c/i2c-core.c
>>>> @@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>>>>    	mutex_lock(&core_lock);
>>>>    	dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap,
>>>>    				 __process_new_adapter);
>>>> +	if(!dummy)
>>>> +		dummy = 0;
>>>
>>> One word: scripts/checkpatch.pl
>>>
>>> In other news, the above is just plain wrong. First we force people to
>>> read the result of bus_for_each_drv() and then when they do and don't
>>> need the value, gcc complains, so we add one more layer of useless
>>> code, which developers and possibly tools will later wonder and
>>> complain about? I can easily imagine that a static code analyzer would
>>> spot the above code as being a potential bug.
>>>
>>> Let's stop this madness now please.
>>>
>>> Either __must_check goes away from bus_for_each_drv() and from every
>>> other function which raises this problem, or we must disable that new
>>> type of warning gcc 4.6.0 generates. Depends which warnings we value
>>> more, as we can't sanely have both.
>>>
>>
>> That is the crux of the whole thing.  Putting in crap to get rid of the
>> __must_check warning someone obviously wanted to provoke is just plain
>> wrong.
>
> __process_new_adapter() calls i2c_do_add_adapter() which always returns
> 0. Why should I check the return value of bus_for_each_drv() when I
> know it will always be 0 by construction?
>
> Also note that the same function is also called through
> bus_for_each_dev() somewhere else in i2c-core, and there is no warning
> there because bus_for_each_dev() is not marked __must_check. How
> consistent is this? If bus_for_each_dev() is OK without __must_check,
> then I can't see why bus_for_each_drv() wouldn't be.
>

Well, I would advocate removing the __must_check then.


David Daney

WARNING: multiple messages have this Message-ID (diff)
From: David Daney <ddaney@caviumnetworks.com>
To: Jean Delvare <khali@linux-fr.org>
Cc: David Daney <david.s.daney@gmail.com>,
	"Justin P. Mattock" <justinmattock@gmail.com>,
	linux-kernel@vger.kernel.org, reiserfs-devel@vger.kernel.org,
	linux-bluetooth@vger.kernel.org, clemens@ladisch.de,
	debora@linux.vnet.ibm.com, dri-devel@lists.freedesktop.org,
	linux-i2c@vger.kernel.org, linux1394-devel@lists.sourceforge.net,
	linux-media@vger.kernel.org
Subject: Re: [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' set but not used
Date: Tue, 15 Jun 2010 09:20:39 -0700	[thread overview]
Message-ID: <4C17A857.8030306@caviumnetworks.com> (raw)
In-Reply-To: <20100615134039.6ccfc17a@hyperion.delvare>

On 06/15/2010 04:40 AM, Jean Delvare wrote:
> Hi David,
>
> On Mon, 14 Jun 2010 14:28:57 -0700, David Daney wrote:
>> On 06/14/2010 01:53 PM, Jean Delvare wrote:
>>> Hi Justin,
>>>
>>> On Mon, 14 Jun 2010 13:26:46 -0700, Justin P. Mattock wrote:
>>>> could be a right solution, could be wrong
>>>> here is the warning:
>>>>     CC      drivers/i2c/i2c-core.o
>>>> drivers/i2c/i2c-core.c: In function 'i2c_register_adapter':
>>>> drivers/i2c/i2c-core.c:757:15: warning: variable 'dummy' set but not used
>>>>
>>>>    Signed-off-by: Justin P. Mattock<justinmattock@gmail.com>
>>>>
>>>> ---
>>>>    drivers/i2c/i2c-core.c |    2 ++
>>>>    1 files changed, 2 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>>>> index 1cca263..79c6c26 100644
>>>> --- a/drivers/i2c/i2c-core.c
>>>> +++ b/drivers/i2c/i2c-core.c
>>>> @@ -794,6 +794,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>>>>    	mutex_lock(&core_lock);
>>>>    	dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap,
>>>>    				 __process_new_adapter);
>>>> +	if(!dummy)
>>>> +		dummy = 0;
>>>
>>> One word: scripts/checkpatch.pl
>>>
>>> In other news, the above is just plain wrong. First we force people to
>>> read the result of bus_for_each_drv() and then when they do and don't
>>> need the value, gcc complains, so we add one more layer of useless
>>> code, which developers and possibly tools will later wonder and
>>> complain about? I can easily imagine that a static code analyzer would
>>> spot the above code as being a potential bug.
>>>
>>> Let's stop this madness now please.
>>>
>>> Either __must_check goes away from bus_for_each_drv() and from every
>>> other function which raises this problem, or we must disable that new
>>> type of warning gcc 4.6.0 generates. Depends which warnings we value
>>> more, as we can't sanely have both.
>>>
>>
>> That is the crux of the whole thing.  Putting in crap to get rid of the
>> __must_check warning someone obviously wanted to provoke is just plain
>> wrong.
>
> __process_new_adapter() calls i2c_do_add_adapter() which always returns
> 0. Why should I check the return value of bus_for_each_drv() when I
> know it will always be 0 by construction?
>
> Also note that the same function is also called through
> bus_for_each_dev() somewhere else in i2c-core, and there is no warning
> there because bus_for_each_dev() is not marked __must_check. How
> consistent is this? If bus_for_each_dev() is OK without __must_check,
> then I can't see why bus_for_each_drv() wouldn't be.
>

Well, I would advocate removing the __must_check then.


David Daney

  parent reply	other threads:[~2010-06-15 16:20 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-14 20:26 [PATCH 0/8] Fix gcc 4.6.0 set but not used warning messages Justin P. Mattock
2010-06-14 20:26 ` Justin P. Mattock
2010-06-14 20:26 ` [PATCH 1/8]reiserfs:stree.c Fix variable set but not used Justin P. Mattock
     [not found]   ` <1276547208-26569-2-git-send-email-justinmattock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-14 20:48     ` Nick Bowler
2010-06-14 20:48       ` Nick Bowler
     [not found]       ` <20100614204805.GA12589-7BP4RkwGw0uXmMXjJBpWqg@public.gmane.org>
2010-06-14 21:09         ` Justin P. Mattock
2010-06-14 21:09           ` Justin P. Mattock
2010-06-14 21:09         ` Justin P. Mattock
2010-06-14 21:05     ` Edward Shishkin
2010-06-14 21:05       ` Edward Shishkin
     [not found]       ` <4C1699AA.3000900-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-14 21:21         ` Justin P. Mattock
2010-06-14 21:21           ` Justin P. Mattock
2010-06-14 21:47           ` Edward Shishkin
     [not found]             ` <4C16A372.6020604-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-14 22:50               ` Justin P. Mattock
2010-06-14 22:50                 ` Justin P. Mattock
2010-06-14 23:07                 ` Stefan Richter
     [not found]                   ` <tkrat.d7bea45e7dbad972-MtYdepGKPcBMYopoZt5u/LNAH6kLmebB@public.gmane.org>
2010-06-15  0:01                     ` Justin P. Mattock
2010-06-15  0:01                       ` Justin P. Mattock
2010-06-14 20:26 ` [PATCH 2/8]bluetooth/hci_ldisc.c Fix warning: variable 'tty' " Justin P. Mattock
2010-06-14 20:26   ` Justin P. Mattock
2010-06-15  0:24   ` Gustavo F. Padovan
2010-06-15  0:24     ` Gustavo F. Padovan
2010-06-14 20:26 ` [PATCH 3/8]char/hpet.c Fix variable 'hpet' " Justin P. Mattock
2010-06-14 20:26   ` Justin P. Mattock
2010-06-14 20:26 ` [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' " Justin P. Mattock
2010-06-14 20:26   ` Justin P. Mattock
     [not found]   ` <1276547208-26569-5-git-send-email-justinmattock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-15  0:13     ` Valdis.Kletnieks-PjAqaU27lzQ
2010-06-15  0:13       ` Valdis.Kletnieks
2010-06-15  2:12       ` Justin P. Mattock
2010-06-15  2:12         ` Justin P. Mattock
     [not found]         ` <4C16E18F.9050901-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-15  3:49           ` Valdis.Kletnieks-PjAqaU27lzQ
2010-06-15  3:49             ` Valdis.Kletnieks
2010-06-15  3:56             ` Justin P. Mattock
2010-06-15  5:29               ` Peter Stuge
2010-06-15  5:58                 ` Justin P. Mattock
2010-06-15  5:58                   ` Justin P. Mattock
2010-06-15  6:57                   ` Stefan Richter
2010-06-15  7:27                     ` Justin P. Mattock
2010-06-15  7:56                       ` Stefan Richter
2010-06-15  8:30                         ` Justin P. Mattock
     [not found]                 ` <20100615052944.7746.qmail-Y+HMSxxDrH8@public.gmane.org>
2010-06-15  5:58                   ` Justin P. Mattock
2010-06-15  9:19                   ` Jean Delvare
2010-06-15  9:19                     ` Jean Delvare
2010-06-15  9:19                     ` Jean Delvare
2010-06-15  9:41                     ` Justin P. Mattock
2010-06-15  9:41                       ` Justin P. Mattock
2010-06-15 18:53     ` Sergey V.
2010-06-15 18:53       ` Sergey V.
     [not found]       ` <201006152253.44326.sftp.mtuci-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-15 19:36         ` Justin P. Mattock
2010-06-15 19:36           ` Justin P. Mattock
2010-06-14 20:26 ` [PATCH 5/8]drm:drm_gem Fix warning: variable 'dev' " Justin P. Mattock
2010-06-14 20:26   ` Justin P. Mattock
2010-06-14 20:26 ` [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' " Justin P. Mattock
2010-06-14 20:26   ` Justin P. Mattock
2010-06-14 20:53   ` Jean Delvare
2010-06-14 21:06     ` Justin P. Mattock
     [not found]       ` <4C1699C4.3010809-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-15 11:43         ` Jean Delvare
2010-06-15 11:43           ` Jean Delvare
2010-06-15 11:43           ` Jean Delvare
2010-06-15 16:51           ` Justin P. Mattock
2010-06-14 21:28     ` David Daney
2010-06-15 11:40       ` Jean Delvare
2010-06-15 11:40         ` Jean Delvare
     [not found]         ` <20100615134039.6ccfc17a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-15 16:20           ` David Daney [this message]
2010-06-15 16:20             ` David Daney
     [not found]             ` <4C17A857.8030306-M3mlKVOIwJVv6pq1l3V1OdBPR1lH4CV8@public.gmane.org>
2010-06-16  9:45               ` Jean Delvare
2010-06-16  9:45                 ` Jean Delvare
2010-06-16  9:45                 ` Jean Delvare
2010-06-14 20:26 ` [PATCH 7/8]ieee1394/sdp2 Fix warning: variable 'unit_characteristics' " Justin P. Mattock
2010-06-14 20:26   ` Justin P. Mattock
2010-06-14 21:44   ` [PATCH] ieee1394: sbp2: remove unused code Stefan Richter
2010-06-14 22:35     ` Justin P. Mattock
2010-06-14 23:22       ` Stefan Richter
2010-06-14 23:58         ` Justin P. Mattock
2010-06-15  0:08         ` (no subject) Stefan Richter
2010-06-15  0:00       ` [PATCH] ieee1394: remove unused variables Stefan Richter
2010-06-15  0:05       ` [PATCH] ieee1394: sbp2: remove unused code Stefan Richter
2010-06-15  1:59         ` Justin P. Mattock
     [not found]   ` <1276547208-26569-8-git-send-email-justinmattock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-15 11:38     ` [PATCH 7/8]ieee1394/sdp2 Fix warning: variable 'unit_characteristics' set but not used Jean Delvare
2010-06-15 11:38       ` Jean Delvare
2010-06-15 11:38       ` Jean Delvare
2010-06-15 16:52       ` Justin P. Mattock
2010-06-15 16:52         ` Justin P. Mattock
2010-06-14 20:26 ` [PATCH 8/8]tuners:tuner-simple Fix warning: variable 'tun' " Justin P. Mattock
2010-06-14 20:26   ` Justin P. Mattock
     [not found]   ` <1276547208-26569-9-git-send-email-justinmattock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-15  5:16     ` Mauro Carvalho Chehab
2010-06-15  5:16       ` Mauro Carvalho Chehab
     [not found]       ` <4C170CA4.2020805-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-06-15  5:37         ` Justin P. Mattock
2010-06-15  5:37           ` Justin P. Mattock
2010-06-15  5:50       ` Justin P. Mattock

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=4C17A857.8030306@caviumnetworks.com \
    --to=ddaney-m3mlkvoiwjvv6pq1l3v1odbpr1lh4cv8@public.gmane.org \
    --cc=clemens-P6GI/4k7KOmELgA04lAiVw@public.gmane.org \
    --cc=david.s.daney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=debora-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=justinmattock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux1394-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=reiserfs-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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.