linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Justin P. Mattock" <justinmattock@gmail.com>
To: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Valdis.Kletnieks@vt.edu, linux-kernel@vger.kernel.org,
	Peter Stuge <peter@stuge.se>,
	tpmdd-devel@lists.sourceforge.net,
	Debora Velarde <debora@linux.vnet.ibm.com>,
	Rajiv Andrade <srajiv@linux.vnet.ibm.com>,
	Marcel Selhorst <m.selhorst@sirrix.com>
Subject: Re: [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' set but	not used
Date: Tue, 15 Jun 2010 01:30:48 -0700	[thread overview]
Message-ID: <4C173A38.7060405@gmail.com> (raw)
In-Reply-To: <4C173216.3040007@s5r6.in-berlin.de>

On 06/15/2010 12:56 AM, Stefan Richter wrote:
> (adding Cc: tpm maintainers, after I had cut the Cc list earlier...)
>
> Justin P. Mattock wrote:
>> On 06/14/2010 11:57 PM, Stefan Richter wrote:
>>> Justin P. Mattock wrote:
>>>> On 06/14/2010 10:29 PM, Peter Stuge wrote:
>>>>> Justin P. Mattock wrote:
>>>>>> I have no manual in front of me. Did a quick google, but came up with
>>>>>> (no hits) info on what that function does. grep showed too many
>>>>>> entries
>>>>>> to really see why/what this is.
>>>>>
>>>>> Check out the tool cscope. (Or kscope, if you prefer a GUI.)
>>>>
>>>> thanks for this tool.. I think this is what I need.. running around not
>>>> knowing what/where the manual is for a call is a bit daunting.
>>>
>>> Similar to cscope/kscope but online:
>>> http://lxr.free-electrons.com/
>>> http://lxr.linux.no/linux
>>>
>>> E.g. http://lxr.free-electrons.com/ident?i=transmit_cmd
>>
>> hmm.. yeah I use those guys a lot.. with grep also.. I think what might
>> throw me off is things like def.orig = def.new then def.orig gets lost
>> in the mix(or it's there, but the grep becomes gigantic in code
>> results.) main thing I look for is googling "somedefinition linux man"
>> for some idea of what that function does.
>>
>> Justin P. Mattock
>
> I'm afraid that even if there was inline documentation of the function,
> it would still be near impossible to guess what to do with unused return
> codes if one is not familiar with the hardware and with the driver.
>
> To quote your original patch again:
>
>> Im getting this warning when compiling:
>>   CC      drivers/char/tpm/tpm.o
>> drivers/char/tpm/tpm.c: In function 'tpm_gen_interrupt':
>> drivers/char/tpm/tpm.c:508:10: warning: variable 'rc' set but not used
>>
>> The below patch gets rid of the warning,
>> but I'm not sure if it's the best solution.
>>
>>   Signed-off-by: Justin P. Mattock<justinmattock@gmail.com>
>>
>> ---
>>   drivers/char/tpm/tpm.c |    2 ++
>>   1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
>> index 05ad4a1..3d685dc 100644
>> --- a/drivers/char/tpm/tpm.c
>> +++ b/drivers/char/tpm/tpm.c
>> @@ -514,6 +514,8 @@ void tpm_gen_interrupt(struct tpm_chip *chip)
>>
>>   	rc = transmit_cmd(chip,&tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
>>   			"attempting to determine the timeouts");
>> +	if (!rc)
>> +		rc = 0;
>>   }
>>   EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
>
> So, void tpm_gen_interrupt() itself clearly is not prepared to do
> anything about an error return from transmit_cmd.  The question is, is
> this OK and can the "rc = " simply be removed, or should
> tpm_gen_interrupt gain some error handling, or should tpm_gen_interrupt
> be changed to a non-void function and its callers check for errors in
> tpm_gen_interrupt?
>

still not sure what that mechanism is doing..

I was going by the warning message i.g.  set but not used
so as soon as it was being used even by adding printk, gcc was happy.
But shutting it off seemed a better approach why? because at the time I 
knew it would work, or fixed it temporarily until somebody who's code 
this is can look at it and send out a better solution(hence what you did).

> It could very well be that there is really no need or no possibility for
> error handling.  But until somebody familiar with the matter has figured
> this out, it is in fact better to leave the compiler warning in place.
>

yep.. I agree..

> Just silencing the compiler if the possibility exists that there is an
> actual flaw here is not the way to go.  Still, good that you reported it
> even with an RFC patch, since the authors were obviously unaware of such
> a warning until now.

I did not like the idea of silencing it.. due to the fact that it can be 
forgotten(or lost in the sands of time per-see)
best I just file a bug report then..in these types of cases.

In any case I still have more warnings..(and that's just my .config)
who knows how many more there are.. If you guys like I can go ahead in 
the next few days and send out another set(minus the rc = 0; thing that 
I did) then go from there.

keep in mind I'm just tackling the ones I think are easy.. ones with 
double variables I left until later down the line..

Justin P. Mattock

  reply	other threads:[~2010-06-15  8:30 UTC|newest]

Thread overview: 53+ 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 ` [PATCH 1/8]reiserfs:stree.c Fix variable set but not used Justin P. Mattock
2010-06-14 20:48   ` Nick Bowler
2010-06-14 21:09     ` Justin P. Mattock
2010-06-14 21:05   ` Edward Shishkin
2010-06-14 21:21     ` Justin P. Mattock
2010-06-14 21:47       ` Edward Shishkin
2010-06-14 22:50         ` Justin P. Mattock
2010-06-14 23:07           ` Stefan Richter
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-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 ` [PATCH 4/8]drivers:tmp.c Fix warning: variable 'rc' " Justin P. Mattock
2010-06-15  0:13   ` Valdis.Kletnieks
2010-06-15  2:12     ` Justin P. Mattock
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  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 [this message]
2010-06-15  9:19             ` Jean Delvare
2010-06-15  9:41               ` Justin P. Mattock
2010-06-15 18:53   ` Sergey V.
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 ` [PATCH 6/8]i2c:i2c_core Fix warning: variable 'dummy' " Justin P. Mattock
2010-06-14 20:53   ` Jean Delvare
2010-06-14 21:06     ` Justin P. Mattock
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 16:20         ` David Daney
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 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
2010-06-15 11:38   ` [PATCH 7/8]ieee1394/sdp2 Fix warning: variable 'unit_characteristics' set but not used Jean Delvare
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-15  5:16   ` Mauro Carvalho Chehab
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=4C173A38.7060405@gmail.com \
    --to=justinmattock@gmail.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=debora@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.selhorst@sirrix.com \
    --cc=peter@stuge.se \
    --cc=srajiv@linux.vnet.ibm.com \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=tpmdd-devel@lists.sourceforge.net \
    /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 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).