[PATCH] Compilation issues related to me4000.c

Hi!

Iīm using gcc 2.95.4 and it reports some problems with the me4000 driver:

1) Unused variables in xilinx_download. Thatīs because some code is 
disabled (license issue) using the preprocessor.
2) Warnings about useless code like it: *pointer ++;

The first can be solved using the preprocessor in the way that GNU 
project recommends:

#define VAR 1
...
if (VAR)

Instead of

#if VAR

I think the second is a bug in the driver. The compiler interprets it 
like this: *(pointer++);
Thatīs really useless ;-)
I think the code was created to do: (*pointer)++;

The attached patch implements both solutions and makes the code compile 
without warnings (at least for 2.95.4 ;-)

Regards, SET

-- 
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Visit my home page: http://welcome.to/SetSoft or
http://www.geocities.com/SiliconValley/Vista/6552/
Alternative e-mail: set_at_computer.org set_at_ieee.org 
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA Phone: +(5411) 4759 0013
Index: comedi/drivers/me4000.c
===================================================================
RCS file: /var/cvs/comedi/comedi/drivers/me4000.c,v
retrieving revision 1.4
diff -u -r1.4 me4000.c
--- comedi/drivers/me4000.c	18 Oct 2003 21:29:27 -0000	1.4
+++ comedi/drivers/me4000.c	4 Feb 2004 13:34:44 -0000
_at__at_ -705,13 +705,16 _at__at_
     return 0;
 }
 
-
+#define FIRMWARE_NOT_AVAILABLE 1
+#if FIRMWARE_NOT_AVAILABLE
+extern unsigned char *xilinx_firm;
+#endif
 
 static int xilinx_download(comedi_device *dev){
-    int size = 0;
     u32 value = 0;
-    int idx = 0;
     wait_queue_head_t queue;
+    int idx = 0;
+    int size = 0;
 
     CALL_PDEBUG("In xilinx_download()\n");
 
_at__at_ -742,25 +745,26 _at__at_
     value = inl(info->plx_regbase + PLX_ICR);
     value &= ~0x100;
     outl(value, info->plx_regbase + PLX_ICR);
-#if 1
+    if(FIRMWARE_NOT_AVAILABLE){
 	comedi_error(dev, "xilinx firmware unavailable due to licensing, aborting");
 	return -EIO;
-#else
+    }
+    else{
     /* Download Xilinx firmware */
-    size = (xilinx_firm[0] << 24) + (xilinx_firm[1] << 16) + (xilinx_firm[2] <<  8) + xilinx_firm[3];
-    udelay(10);
-
-    for(idx = 0; idx < size; idx++){
-	outb(xilinx_firm[16+idx], info->program_regbase);
+	size = (xilinx_firm[0] << 24) + (xilinx_firm[1] << 16) + (xilinx_firm[2] <<  8) + xilinx_firm[3];
 	udelay(10);
 
-	/* Check if BUSY flag is low */
-	if(inl(info->plx_regbase + PLX_ICR) & 0x20){
-	    printk(KERN_ERR"comedi%d: me4000: xilinx_download(): Xilinx is still busy (idx = %d)\n", dev->minor, idx);
-	    return -EIO;
+	for(idx = 0; idx < size; idx++){
+	    outb(xilinx_firm[16+idx], info->program_regbase);
+	    udelay(10);
+
+	    /* Check if BUSY flag is low */
+	    if(inl(info->plx_regbase + PLX_ICR) & 0x20){
+		printk(KERN_ERR"comedi%d: me4000: xilinx_download(): Xilinx is still busy (idx = %d)\n", dev->minor, idx);
+		return -EIO;
+	    }
 	}
     }
-#endif
 
     /* If done flag is high download was successful */
     if (inl(info->plx_regbase + PLX_ICR) & 0x4){
_at__at_ -1087,11 +1091,11 _at__at_
 
 	if(cmd->flags & TRIG_ROUND_NEAREST){
 	    if(rest > 33){
-		*init_ticks ++;
+		(*init_ticks) ++;
 	    }
 	}
 	else if(cmd->flags & TRIG_ROUND_UP){
-	    if(rest) *init_ticks ++;
+	    if(rest) (*init_ticks) ++;
 	}
     }
 
_at__at_ -1101,11 +1105,11 _at__at_
 
 	if(cmd->flags & TRIG_ROUND_NEAREST){
 	    if(rest > 33){
-		*scan_ticks ++;
+		(*scan_ticks) ++;
 	    }
 	}
 	else if(cmd->flags & TRIG_ROUND_UP){
-	    if(rest) *scan_ticks ++;
+	    if(rest) (*scan_ticks) ++;
 	}
     }
 
_at__at_ -1115,11 +1119,11 _at__at_
 
 	if(cmd->flags & TRIG_ROUND_NEAREST){
 	    if(rest > 33){
-		*chan_ticks ++;
+		(*chan_ticks) ++;
 	    }
 	}
 	else if(cmd->flags & TRIG_ROUND_UP){
-	    if(rest) *chan_ticks ++;
+	    if(rest) (*chan_ticks) ++;
 	}
     }
 

Received on 2004-02-04Z18:05:05