From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] [PATCH] Fix warning in drivers/usb/media/ov511.c
Date: Sat, 18 Feb 2006 11:48:57 +0000 [thread overview]
Message-ID: <43F709A9.9010304@bfs.de> (raw)
In-Reply-To: <1139970072.25492.4.camel@localhost.localdomain>
hi alexey,
several usb drivers return -EPERM. perhaps
gkh will accept a cleanup patch for this issue.
re,
walter
Alexey Dobriyan wrote:
> [jumps from train]
>
> Gentlemen, instead of broke-arounding non-issues, I suggest to
> actually read sensor_get_exposure(). You'll notice quite a few strange
> things for 1.5-screenful function, I promise:
>
> drivers/usb/media/ov511.c:
> 1856 static int
> 1857 sensor_get_exposure(struct usb_ov511 *ov, unsigned char *val)
> 1858 {
> 1859 int rc;
> 1860
> 1861 switch (ov->sensor) {
> 1862 case SEN_OV7610:
> 1863 case SEN_OV6620:
> 1864 case SEN_OV6630:
> 1865 case SEN_OV7620:
> 1866 case SEN_OV76BE:
> 1867 case SEN_OV8600:
> 1868 rc = i2c_r(ov, 0x10);
> 1869 if (rc < 0)
> 1870 return rc;
>
> Oops, it can return error value. So, instead checking return value of
> sensor_get_exposure(), you tell gcc to STFU. Notice that *val is not
> touched on this path.
>
> 1871 else
> 1872 *val = rc;
>
> It's touched here, but the function will return 0.
>
> 1873 break;
> 1874 case SEN_KS0127:
> 1875 case SEN_KS0127B:
> 1876 case SEN_SAA7111A:
> 1877 val = NULL;
>
> Now, who can explain this line? Change of "val" will be forgotten right
> after "return".
>
> 1878 PDEBUG(3, "Unsupported with this sensor");
> 1879 return -EPERM;
>
> This looks slightly bizarre. -EPERM occurs usually when Joe User tries
> to do something not under root.
>
> 1880 default:
> 1881 err("Sensor not supported for get_exposure");
> 1882 return -EINVAL;
>
> "Invalid argument". So there should be valid argument, right? Wrong.
> "Sensor not supported".
>
> 1883 }
> 1884
> 1885 PDEBUG(3, "%d", *val);
> 1886 ov->exposure = *val;
> 1887
> 1888 return 0;
> 1889 }
>
> As was noted, "unsigned char >> 8" somewhere near line 5396 is pretty
> funny too.
>
> Resume:
> Patch is rejected because it's very wrong, fixes problem in the
> wrong place and only makes whole situation worse.
>
> Future "may be used uninitialized" patches must contain
> description of code path that can lead to said uninitialized using.
>
> Fed my pet project to 3.4.4:
> -Wall -- no warnings
> -Wall -O -- out little friends and I can prove they are bogus.
> -Wall -O[123s] -- ditto
>
> Alexey "warnings by commitee" Dobriyan
>
> On Wed, Feb 15, 2006 at 03:41:25PM -0600, Matthew Martin wrote:
>> Gcc 4.0.2 had the warning:
>
>> drivers/usb/media/ov511.c: In function 'show_exposure':
>> drivers/usb/media/ov511.c:5642: warning: 'exp' may be used uninitialized
>> in this function
>
>> --- orig-linux-2.6.15/drivers/usb/media/ov511.c
>> +++ linux-2.6.15/drivers/usb/media/ov511.c
>> @@ -5639,7 +5639,7 @@ static CLASS_DEVICE_ATTR(hue, S_IRUGO, s
>> static ssize_t show_exposure(struct class_device *cd, char *buf)
>> {
>> struct usb_ov511 *ov = cd_to_ov(cd);
>> - unsigned char exp;
>> + unsigned char exp = 0;
>>
>> if (!ov->dev)
>> return -ENODEV;
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next prev parent reply other threads:[~2006-02-18 11:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-15 2:21 [KJ] [PATCH] Fix warning in drivers/usb/media/ov511.c Matthew Martin
2006-02-15 3:04 ` Greg KH
2006-02-15 16:30 ` Nico Golde
2006-02-15 17:05 ` Greg KH
2006-02-15 21:41 ` Matthew Martin
2006-02-15 23:01 ` Nishanth Aravamudan
2006-02-15 23:16 ` Håkon Løvdal
2006-02-15 23:27 ` Greg KH
2006-02-15 23:31 ` Randy.Dunlap
2006-02-15 23:37 ` Håkon Løvdal
2006-02-16 0:38 ` Greg KH
2006-02-16 1:49 ` Matthew Martin
2006-02-16 14:51 ` Matthew Martin
2006-02-16 15:43 ` Nishanth Aravamudan
2006-02-16 17:20 ` Randy.Dunlap
2006-02-17 21:53 ` Alexey Dobriyan
2006-02-18 11:48 ` walter harms [this message]
2006-02-18 16:28 ` Greg KH
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=43F709A9.9010304@bfs.de \
--to=wharms@bfs.de \
--cc=kernel-janitors@vger.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.