* parport_pc: Fix subscription bugs
@ 2009-06-01 9:00 Michael Buesch
2009-06-01 9:14 ` Alan Cox
0 siblings, 1 reply; 5+ messages in thread
From: Michael Buesch @ 2009-06-01 9:00 UTC (permalink / raw)
To: Andrew Morton; +Cc: LKML
This patch fixes array subscription bugs in the parport_pc driver.
drivers/parport/parport_pc.c: In function ‘parport_irq_probe’:
drivers/parport/parport_pc.c:1589: warning: array subscript is above array bounds
drivers/parport/parport_pc.c: In function ‘parport_pc_probe_port’:
drivers/parport/parport_pc.c:1579: warning: array subscript is above array bounds
The patch also fixes a few other array bugs, which the compiler was
unable to find. Coding style violations are also fixed.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Cc: Stable <stable@kernel.org>
---
These are real bugs, not just bogus compiler warnings.
Index: wireless-testing/drivers/parport/parport_pc.c
===================================================================
--- wireless-testing.orig/drivers/parport/parport_pc.c 2009-04-29 22:43:55.000000000 +0200
+++ wireless-testing/drivers/parport/parport_pc.c 2009-06-01 10:51:48.000000000 +0200
@@ -1243,23 +1243,23 @@ static void __devinit show_parconfig_sms
printk(KERN_INFO "SMSC LPT Config: enabled=%s power=%s\n",
(cr23*4 >=0x100) ?"yes":"no", (cr1 & 4) ? "yes" : "no");
printk(KERN_INFO "SMSC LPT Config: Port mode=%s, EPP version =%s\n",
(cr1 & 0x08 ) ? "Standard mode only (SPP)" : modes[cr4 & 0x03],
(cr4 & 0x40) ? "1.7" : "1.9");
}
-
+
/* Heuristics ! BIOS setup for this mainboard device limits
the choices to standard settings, i.e. io-address and IRQ
are related, however DMA can be 1 or 3, assume DMA_A=DMA1,
DMA_C=DMA3 (this is true e.g. for TYAN 1564D Tomcat IV) */
- if(cr23*4 >=0x100) { /* if active */
- while((superios[i].io!= 0) && (i<NR_SUPERIOS))
+ if (cr23 * 4 >= 0x100) { /* if active */
+ while ((i < NR_SUPERIOS) && (superios[i].io != 0))
i++;
- if(i==NR_SUPERIOS)
+ if (i == NR_SUPERIOS) {
printk(KERN_INFO "Super-IO: too many chips!\n");
- else {
+ } else {
int d;
switch (cr23*4) {
case 0x3bc:
superios[i].io = 0x3bc;
superios[i].irq = 7;
break;
@@ -1329,18 +1329,18 @@ static void __devinit show_parconfig_win
printk("dma=%d\n",cr74 & 0x07);
printk(KERN_INFO "Winbond LPT Config: irqtype=%s, ECP fifo threshold=%d\n",
irqtypes[crf0>>7], (crf0>>3)&0x0f);
printk(KERN_INFO "Winbond LPT Config: Port mode=%s\n", modes[crf0 & 0x07]);
}
- if(cr30 & 0x01) { /* the settings can be interrogated later ... */
- while((superios[i].io!= 0) && (i<NR_SUPERIOS))
+ if (cr30 & 0x01) { /* the settings can be interrogated later ... */
+ while ((i < NR_SUPERIOS) && (superios[i].io != 0))
i++;
- if(i==NR_SUPERIOS)
+ if (i == NR_SUPERIOS) {
printk(KERN_INFO "Super-IO: too many chips!\n");
- else {
+ } else {
superios[i].io = (cr60<<8)|cr61;
superios[i].irq = cr70&0x0f;
superios[i].dma = (((cr74 & 0x07) > 3) ?
PARPORT_DMA_NONE : (cr74 & 0x07));
}
}
@@ -1572,30 +1572,32 @@ static void __devinit detect_and_report_
release_region(0x2e, 1);
}
#endif /* CONFIG_PARPORT_PC_SUPERIO */
static int get_superio_dma (struct parport *p)
{
- int i=0;
- while( (superios[i].io != p->base) && (i<NR_SUPERIOS))
+ int i = 0;
+
+ while ((i < NR_SUPERIOS) && (superios[i].io != p->base))
i++;
- if (i!=NR_SUPERIOS)
+ if (i != NR_SUPERIOS)
return superios[i].dma;
return PARPORT_DMA_NONE;
}
static int get_superio_irq (struct parport *p)
{
- int i=0;
- while( (superios[i].io != p->base) && (i<NR_SUPERIOS))
+ int i = 0;
+
+ while ((i < NR_SUPERIOS) && (superios[i].io != p->base))
i++;
- if (i!=NR_SUPERIOS)
+ if (i != NR_SUPERIOS)
return superios[i].irq;
return PARPORT_IRQ_NONE;
}
-
+
/* --- Mode detection ------------------------------------- */
/*
* Checks for port existence, all ports support SPP MODE
* Returns:
--
Greetings, Michael.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: parport_pc: Fix subscription bugs
2009-06-01 9:00 parport_pc: Fix subscription bugs Michael Buesch
@ 2009-06-01 9:14 ` Alan Cox
2009-06-01 9:27 ` Michael Buesch
0 siblings, 1 reply; 5+ messages in thread
From: Alan Cox @ 2009-06-01 9:14 UTC (permalink / raw)
To: Michael Buesch; +Cc: Andrew Morton, LKML
On Mon, 1 Jun 2009 11:00:33 +0200
Michael Buesch <mb@bu3sch.de> wrote:
> This patch fixes array subscription bugs in the parport_pc driver.
>
> drivers/parport/parport_pc.c: In function ‘parport_irq_probe’:
> drivers/parport/parport_pc.c:1589: warning: array subscript is above array bounds
> drivers/parport/parport_pc.c: In function ‘parport_pc_probe_port’:
> drivers/parport/parport_pc.c:1579: warning: array subscript is above array bounds
>
> The patch also fixes a few other array bugs, which the compiler was
> unable to find. Coding style violations are also fixed.
Which makes it very hard to see what you are actually changing and
whether it is a bug. It certainly looks like one but the changes muddled
in with a random subset of format fixes (even in the area patched only
some style is fixed) looks pretty clunky - surely a for() loop would be
far cleaner.
But yes agreed - its a bug, it wants fixing and style can be sorted later.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: parport_pc: Fix subscription bugs
2009-06-01 9:14 ` Alan Cox
@ 2009-06-01 9:27 ` Michael Buesch
2009-06-01 9:58 ` Alan Cox
0 siblings, 1 reply; 5+ messages in thread
From: Michael Buesch @ 2009-06-01 9:27 UTC (permalink / raw)
To: Alan Cox; +Cc: Andrew Morton, LKML
On Monday 01 June 2009 11:14:40 Alan Cox wrote:
> On Mon, 1 Jun 2009 11:00:33 +0200
> Michael Buesch <mb@bu3sch.de> wrote:
>
> > This patch fixes array subscription bugs in the parport_pc driver.
> >
> > drivers/parport/parport_pc.c: In function ‘parport_irq_probe’:
> > drivers/parport/parport_pc.c:1589: warning: array subscript is above array bounds
> > drivers/parport/parport_pc.c: In function ‘parport_pc_probe_port’:
> > drivers/parport/parport_pc.c:1579: warning: array subscript is above array bounds
> >
> > The patch also fixes a few other array bugs, which the compiler was
> > unable to find. Coding style violations are also fixed.
>
> Which makes it very hard to see what you are actually changing and
> whether it is a bug. It certainly looks like one but the changes muddled
> in with a random subset of format fixes (even in the area patched only
> some style is fixed)
Yeah well. If I did not fix the style violations, somebody else would have complained
already that when somebody touches some code he should also fix the style issues. ;)
Happened to be several times, so I chose to fix them here...
--
Greetings, Michael.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: parport_pc: Fix subscription bugs
2009-06-01 9:27 ` Michael Buesch
@ 2009-06-01 9:58 ` Alan Cox
2009-06-01 10:17 ` Michael Buesch
0 siblings, 1 reply; 5+ messages in thread
From: Alan Cox @ 2009-06-01 9:58 UTC (permalink / raw)
To: Michael Buesch; +Cc: Andrew Morton, LKML
> Yeah well. If I did not fix the style violations, somebody else would have complained
> already that when somebody touches some code he should also fix the style issues. ;)
> Happened to be several times, so I chose to fix them here...
Yes Andrew likes code to become horrible and inconsistent it seems ;)
I'll post a follow up to your patch to whack the whole thing into style
and switch those loops.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: parport_pc: Fix subscription bugs
2009-06-01 9:58 ` Alan Cox
@ 2009-06-01 10:17 ` Michael Buesch
0 siblings, 0 replies; 5+ messages in thread
From: Michael Buesch @ 2009-06-01 10:17 UTC (permalink / raw)
To: Alan Cox; +Cc: Andrew Morton, LKML
On Monday 01 June 2009 11:58:19 Alan Cox wrote:
> > Yeah well. If I did not fix the style violations, somebody else would have complained
> > already that when somebody touches some code he should also fix the style issues. ;)
> > Happened to be several times, so I chose to fix them here...
>
> Yes Andrew likes code to become horrible and inconsistent it seems ;)
>
> I'll post a follow up to your patch to whack the whole thing into style
> and switch those loops.
Cool. Thanks a lot Alan. :)
--
Greetings, Michael.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-06-01 10:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-01 9:00 parport_pc: Fix subscription bugs Michael Buesch
2009-06-01 9:14 ` Alan Cox
2009-06-01 9:27 ` Michael Buesch
2009-06-01 9:58 ` Alan Cox
2009-06-01 10:17 ` Michael Buesch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox