From 73e0d48b8c28fb39a0bb6713c875e9919a9af546 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Thu, 11 Jun 2009 13:06:31 +0100 Subject: parport_pc: Fix subscription bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/parport/parport_pc.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'drivers/parport/parport_pc.c') diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index 4e63cc9e277..24984c4a1ba 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c @@ -1246,17 +1246,17 @@ static void __devinit show_parconfig_smsc37c669(int io, int key) (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= 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: @@ -1332,12 +1332,12 @@ static void __devinit show_parconfig_winbond(int io, int key) 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 3) ? @@ -1575,24 +1575,26 @@ static void __devinit detect_and_report_it87(void) static int get_superio_dma (struct parport *p) { - int i=0; - while( (superios[i].io != p->base) && (ibase)) 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) && (ibase)) i++; - if (i!=NR_SUPERIOS) + if (i != NR_SUPERIOS) return superios[i].irq; return PARPORT_IRQ_NONE; } - + /* --- Mode detection ------------------------------------- */ -- cgit v1.2.3