2.3.10 patches

Riley Williams (rhw@MemAlpha.CX)
Tue, 13 Jul 1999 02:08:28 +0100 (GMT)


Hi there.

I just went through the warnings that were thrown up when compiling
2.3.10 on my system, and the following patches basically fell out to
fix several of them, so here they are.

Before anybody asks, I ignored the various "defined but not used"
warnings, as those are generally minor. These are the more major
warnings...

First, a case of missing braces leading to incorrect logic. The macro
IFDEBUG expands to an if statement, and it's used at least once in the
then branch of another if statement, leading to incorrect nesting. The
following patch block puts the braces round all of the IFDEBUG blocks
to implement the nesting implied by the indentation, which looks
correct throughout...

===8<=== CUT ===>8===
--- linux-2.3.10/drivers/net/arlan-proc.c~ Tue Jul 6 18:11:40 1999
+++ linux-2.3.10/drivers/net/arlan-proc.c Tue Jul 13 00:52:07 1999
@@ -233,14 +233,16 @@
DEBUGSHM(1, "arlan: registration mode is %d\n", arlan->registrationMode, u_char);

printk("arlan: name= ");
+
IFDEBUG(1)
-
+ {
- for (i = 0; i < 16; i++)
+ for (i = 0; i < 16; i++)
- {
+ {
- char c;
+ char c;
- READSHM(c, arlan->name[i], char);
+ READSHM(c, arlan->name[i], char);
- if (c)
+ if (c)
- printk("%c", c);
+ printk("%c", c);
+ }
}
printk("\n");

@@ -302,7 +304,10 @@
for (i = 0; i < memlen; i++)
WRITESHM(arlan_mem[i], 0x00, char);

- IFDEBUG(1) printk(KERN_INFO "Arlan: memory tests ok\n");
+ IFDEBUG(1)
+ {
+ printk(KERN_INFO "Arlan: memory tests ok\n");
+ }

/* set reset flag and then release reset */
WRITESHM(arlan->resetFlag, 0xff, u_char);
@@ -330,10 +335,22 @@
READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char);

IFDEBUG(10)
+ {
- if (configuredStatusFlag != 0)
+ if (configuredStatusFlag != 0)
+ {
- IFDEBUG(10) printk("arlan: CARD IS CONFIGURED\n");
+ IFDEBUG(10)
+ {
+ printk("arlan: CARD IS CONFIGURED\n");
+ }
+ }
- else
+ else
+ {
- IFDEBUG(10) printk("arlan: card is NOT configured\n");
+ IFDEBUG(10)
+ {
+ printk("arlan: card is NOT configured\n");
+ }
+ }
+ }

if (testMemory || (READSHMB(arlan->diagnosticInfo) != 0xff))
if (arlan_hw_test_memory(dev))
@@ -347,7 +364,10 @@
if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0)
return -1;

- IFDEBUG(50) printk("1st Noop successfully executed !!\n");
+ IFDEBUG(50)
+ {
+ printk("1st Noop successfully executed !!\n");
+ }

/* try to turn on the arlan interrupts */
clearClearInterrupt(dev);
@@ -361,21 +381,32 @@
return -1;


- IFDEBUG(50) printk("2nd Noop successfully executed !!\n");
+ IFDEBUG(50)
+ {
+ printk("2nd Noop successfully executed !!\n");
+ }

READSHM(irqLevel, arlan->irqLevel, u_char)

if (irqLevel != dev->irq)
{
- IFDEBUG(1) printk(KERN_WARNING "arlan dip switches set irq to %d\n", irqLevel);
+ IFDEBUG(1)
+ {
+ printk(KERN_WARNING "arlan dip switches set irq to %d\n", irqLevel);
+ }
printk(KERN_WARNING "device driver irq set to %d - does not match\n", dev->irq);
dev->irq = irqLevel;
}
else
- IFDEBUG(2) printk("irq level is OK\n");
+ IFDEBUG(2)
+ {
+ printk("irq level is OK\n");
+ }
-

- IFDEBUG(3) arlan_print_diagnostic_info(dev);
+ IFDEBUG(3)
+ {
+ arlan_print_diagnostic_info(dev);
+ }

arlan_command(dev, ARLAN_COMMAND_CONF);

===8<=== CUT ===>8===

Next, two function calls which return results that are ignored. I'm
not sure whether they should be ignored, but the following patch
documents the fact that they currently are.

===8<=== CUT ===>8===
--- linux-2.3.10/drivers/net/tlan.c~ Tue Apr 13 00:18:33 1999
+++ linux-2.3.10/drivers/net/tlan.c Tue Jul 13 00:22:22 1999
@@ -2528,13 +2528,13 @@

for ( i = ( 0x1 << ( num_bits - 1 ) ); i; i >>= 1 ) {
TLan_ClearBit( TLAN_NET_SIO_MCLK, sio );
- TLan_GetBit( TLAN_NET_SIO_MCLK, sio );
+ (void) TLan_GetBit( TLAN_NET_SIO_MCLK, sio );
if ( data & i )
TLan_SetBit( TLAN_NET_SIO_MDATA, sio );
else
TLan_ClearBit( TLAN_NET_SIO_MDATA, sio );
TLan_SetBit( TLAN_NET_SIO_MCLK, sio );
- TLan_GetBit( TLAN_NET_SIO_MCLK, sio );
+ (void) TLan_GetBit( TLAN_NET_SIO_MCLK, sio );
}

} /* TLan_MiiSendData */
===8<=== CUT ===>8===

Next, a couple of "variable may be undefined when used" warnings.
Whilst they are documented as being bogus warnings, it's actually
simple to get rid of them in the first place, and here's how.

===8<=== CUT ===>8===
--- linux-2.3.10/drivers/sound/sonicvibes.c~ Tue Jul 6 03:58:25 1999
+++ linux-2.3.10/drivers/sound/sonicvibes.c Tue Jul 13 01:06:58 1999
@@ -503,7 +503,7 @@
static unsigned setpll(struct sv_state *s, unsigned char reg, unsigned rate)
{
unsigned long flags;
- unsigned char r, m, n;
+ unsigned char r, m=0, n=0;
unsigned xm, xn, xr, xd, metric = ~0U;
/* the warnings about m and n used uninitialized are bogus and may safely be ignored */

===8<=== CUT ===>8===

Next, a for loop that does absolutely nothing, although the fact is
hidden by the location of the semicolon. This patch unhides that fact,
although I'd guess that it's actually a bug that needs some attention.

===8<=== CUT ===>8===
--- linux-2.3.10/drivers/sound/sonicvibes.c~ Tue Jul 6 03:58:25 1999
+++ linux-2.3.10/drivers/sound/sonicvibes.c Tue Jul 13 01:06:58 1999
@@ -512,7 +512,8 @@
if (rate > 150000000/ADCMULT)
rate = 150000000/ADCMULT;
/* slight violation of specs, needed for continuous sampling rates */
- for (r = 0; rate < 75000000/ADCMULT; r += 0x20, rate <<= 1);
+ for (r = 0; rate < 75000000/ADCMULT; r += 0x20, rate <<= 1)
+ /* Do nothing */;
for (xn = 3; xn < 35; xn++)
for (xm = 3; xm < 130; xm++) {
xr = REFFREQUENCY/ADCMULT * xm / xn;
===8<=== CUT ===>8===

Next, a procedure that's declared static, but is neither defined nor
used. This patch just comments the definition out.

===8<=== CUT ===>8===
--- linux-2.3.10/net/irda/irproc.c~ Sun May 30 18:27:04 1999
+++ linux-2.3.10/net/irda/irproc.c Tue Jul 13 01:16:34 1999
@@ -42,8 +42,10 @@
int unused);
extern int discovery_proc_read(char *buf, char **start, off_t offset, int len,
int unused);
+/*
static int proc_discovery_read(char *buf, char **start, off_t offset, int len,
int unused);
+*/

/* enum irda_directory_inos { */
/* PROC_IRDA_LAP = 1, */
===8<=== CUT ===>8===

Finally, a redundant condition that causes a "variable used undefined"
warning to be thrown up. This patch fixes it.

===8<=== CUT ===>8===
--- linux-2.3.10/drivers/net/hamradio/mkiss.c~ Wed Jul 7 03:05:50 1999
+++ linux-2.3.10/drivers/net/hamradio/mkiss.c Tue Jul 13 01:12:42 1999
@@ -810,7 +810,7 @@
c = *s++;
else if (len > 1)
c = crc >> 8;
- else if (len > 0)
+ else
c = crc & 0xff;

len--;
===8<=== CUT ===>8===

Hope those help somebody...

Best wishes from Riley.

+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* ftp://ftp.MemAlpha.cx/pub/rhw/Linux
* http://www.MemAlpha.cx/kernel.versions.html

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/