* [PATCH] pdc2026x: remove surplus initialiser
@ 2008-01-19 15:55 Alan Cox
2008-01-19 16:54 ` Sergei Shtylyov
2008-01-21 23:13 ` Bartlomiej Zolnierkiewicz
0 siblings, 2 replies; 5+ messages in thread
From: Alan Cox @ 2008-01-19 15:55 UTC (permalink / raw)
To: bzolnier, linux-ide
Signed-off-by: Alan Cox <alan@redhat.com>
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c
--- linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 14:47:56.000000000 +0000
+++ linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 15:00:08.000000000 +0000
@@ -138,7 +138,7 @@
static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif)
{
struct pci_dev *dev = to_pci_dev(hwif->dev);
- u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10);
+ u16 CIS, mask = (hwif->channel) ? (1<<11) : (1<<10);
pci_read_config_word(dev, 0x50, &CIS);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pdc2026x: remove surplus initialiser
2008-01-19 15:55 [PATCH] pdc2026x: remove surplus initialiser Alan Cox
@ 2008-01-19 16:54 ` Sergei Shtylyov
2008-01-19 20:00 ` Alan Cox
2008-01-21 23:13 ` Bartlomiej Zolnierkiewicz
1 sibling, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2008-01-19 16:54 UTC (permalink / raw)
To: Alan Cox; +Cc: bzolnier, linux-ide
Hello.
Alan Cox wrote:
> Signed-off-by: Alan Cox <alan@redhat.com>
> diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c
> --- linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 14:47:56.000000000 +0000
> +++ linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 15:00:08.000000000 +0000
> @@ -138,7 +138,7 @@
> static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif)
> {
> struct pci_dev *dev = to_pci_dev(hwif->dev);
> - u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10);
> + u16 CIS, mask = (hwif->channel) ? (1<<11) : (1<<10);
>
> pci_read_config_word(dev, 0x50, &CIS);
Since we ignore the result of this function, if it fails CIS may be left
uninitialized if the function fails. So, the initializer is not as useless as
it seems (and there's a lot more of such cases in drivers/ide/pci/ :-)...
MBR, Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pdc2026x: remove surplus initialiser
2008-01-19 16:54 ` Sergei Shtylyov
@ 2008-01-19 20:00 ` Alan Cox
2008-01-21 23:13 ` Bartlomiej Zolnierkiewicz
0 siblings, 1 reply; 5+ messages in thread
From: Alan Cox @ 2008-01-19 20:00 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: bzolnier, linux-ide
On Sat, 19 Jan 2008 19:54:03 +0300
Sergei Shtylyov <sshtylyov@ru.mvista.com> wrote:
> Hello.
>
> Alan Cox wrote:
>
> > Signed-off-by: Alan Cox <alan@redhat.com>
>
> > diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c
> > --- linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 14:47:56.000000000 +0000
> > +++ linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 15:00:08.000000000 +0000
> > @@ -138,7 +138,7 @@
> > static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif)
> > {
> > struct pci_dev *dev = to_pci_dev(hwif->dev);
> > - u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10);
> > + u16 CIS, mask = (hwif->channel) ? (1<<11) : (1<<10);
> >
> > pci_read_config_word(dev, 0x50, &CIS);
>
> Since we ignore the result of this function, if it fails CIS may be left
> uninitialized if the function fails. So, the initializer is not as useless as
> it seems (and there's a lot more of such cases in drivers/ide/pci/ :-)..
If pci_read_config_word fails you are in very deep doodoo anyway. I don't
think anyone checks it because there isn't an answer to "now what"
Alan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pdc2026x: remove surplus initialiser
2008-01-19 15:55 [PATCH] pdc2026x: remove surplus initialiser Alan Cox
2008-01-19 16:54 ` Sergei Shtylyov
@ 2008-01-21 23:13 ` Bartlomiej Zolnierkiewicz
1 sibling, 0 replies; 5+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-01-21 23:13 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-ide
On Saturday 19 January 2008, Alan Cox wrote:
>
> Signed-off-by: Alan Cox <alan@redhat.com>
applied with:
- s/pdc2026x/pdc202xx_old/ in patch summary
- drive-by CodingStyle fixups
> diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c
> --- linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 14:47:56.000000000 +0000
> +++ linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 15:00:08.000000000 +0000
> @@ -138,7 +138,7 @@
> static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif)
> {
> struct pci_dev *dev = to_pci_dev(hwif->dev);
> - u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10);
> + u16 CIS, mask = (hwif->channel) ? (1<<11) : (1<<10);
>
> pci_read_config_word(dev, 0x50, &CIS);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pdc2026x: remove surplus initialiser
2008-01-19 20:00 ` Alan Cox
@ 2008-01-21 23:13 ` Bartlomiej Zolnierkiewicz
0 siblings, 0 replies; 5+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-01-21 23:13 UTC (permalink / raw)
To: Alan Cox; +Cc: Sergei Shtylyov, linux-ide
On Saturday 19 January 2008, Alan Cox wrote:
> On Sat, 19 Jan 2008 19:54:03 +0300
> Sergei Shtylyov <sshtylyov@ru.mvista.com> wrote:
>
> > Hello.
> >
> > Alan Cox wrote:
> >
> > > Signed-off-by: Alan Cox <alan@redhat.com>
> >
> > > diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c
> > > --- linux.vanilla-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 14:47:56.000000000 +0000
> > > +++ linux-2.6.24-rc8-mm1/drivers/ide/pci/pdc202xx_old.c 2008-01-19 15:00:08.000000000 +0000
> > > @@ -138,7 +138,7 @@
> > > static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif)
> > > {
> > > struct pci_dev *dev = to_pci_dev(hwif->dev);
> > > - u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10);
> > > + u16 CIS, mask = (hwif->channel) ? (1<<11) : (1<<10);
> > >
> > > pci_read_config_word(dev, 0x50, &CIS);
> >
> > Since we ignore the result of this function, if it fails CIS may be left
> > uninitialized if the function fails. So, the initializer is not as useless as
pci_[bus]_read_config_*() functions always assign some value according to
drivers/pci/access.c (except for unaligned access to word/dword register).
> > it seems (and there's a lot more of such cases in drivers/ide/pci/ :-)..
A lot of "patch" opportunities!
> If pci_read_config_word fails you are in very deep doodoo anyway. I don't
> think anyone checks it because there isn't an answer to "now what"
Yep, moreover we cannot just assume that "0" is a safe default value
because it doesn't have to be (i.e. in the above case cable bit set to
"0" means 80-wires cable).
Thanks,
Bart
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-01-21 23:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-19 15:55 [PATCH] pdc2026x: remove surplus initialiser Alan Cox
2008-01-19 16:54 ` Sergei Shtylyov
2008-01-19 20:00 ` Alan Cox
2008-01-21 23:13 ` Bartlomiej Zolnierkiewicz
2008-01-21 23:13 ` Bartlomiej Zolnierkiewicz
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).