Skip to contentSkip to conversation

Multiple & vs. && and | vs. || bugs in 2.5.63

PATCH In review Norbert Kiesel 2 participants 3 messages Mar 2, 2003

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Multiple & vs. && and | vs. || bugs in 2.5.63

Hi,

here are patches for some | vs. || and & vs. && bugs I found with find ${1:-.} -name \*.c | xargs grep -En \
'![a-zA-Z0-9_ ]+(\|[^|]|\&[^&])|([^|]\||[^&]\&) *!'

I also emailed them to the maintainers/authors if I could find them, but failed for some (e.g. uart00.c).

so long
Norbert

drivers/pnp/pnpbios/core.c renamed from drivers/pnp/pnpbios/core.c~ +2 -2
@@ -322,7 +322,7 @@
 	u16 status;
 	if (!pnp_bios_present())
 		return PNP_FUNCTION_NOT_SUPPORTED;
-	if ( !boot & pnpbios_dont_use_current_config )
+	if ( !boot && pnpbios_dont_use_current_config )
 		return PNP_FUNCTION_NOT_SUPPORTED;
 	status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0,
 			       nodenum, sizeof(char), data, 65536);
@@ -350,7 +350,7 @@
 	u16 status;
 	if (!pnp_bios_present())
 		return PNP_FUNCTION_NOT_SUPPORTED;
-	if ( !boot & pnpbios_dont_use_current_config )
+	if ( !boot && pnpbios_dont_use_current_config )
 		return PNP_FUNCTION_NOT_SUPPORTED;
 	status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, boot ? 2 : 1, PNP_DS, 0, 0,
 			       data, 65536, 0, 0);
drivers/media/dvb/dvb-core/dvb_demux.c renamed from drivers/media/dvb/dvb-core/dvb_demux.c~ +1 -1
@@ -221,7 +221,7 @@
 			return 0;
 		neq|=f->maskandnotmode[i]&xor;
 	}
-	if (f->doneq & !neq)
+	if (f->doneq && !neq)
 		return 0;
 
         return dvbdmxfeed->cb.sec(dvbdmxfeed->secbuf, dvbdmxfeed->seclen, 
drivers/video/console/fbcon.c renamed from drivers/video/console/fbcon.c~ +1 -1
@@ -456,7 +456,7 @@
 	region.color = attr_bgcol_ec(p, vc);
 	region.rop = ROP_COPY;
 
-	if (rw & !bottom_only) {
+	if (rw && !bottom_only) {
 		region.dx = info->var.xoffset + rs;
 		region.dy = 0;
 		region.width = rw;
sound/oss/gus_midi.c renamed from sound/oss/gus_midi.c~ +1 -1
@@ -179,7 +179,7 @@
 		qhead++;
 	}
 	spin_unlock_irqrestore(&lock,flags);
-	return (qlen > 0) | !(GUS_MIDI_STATUS() & MIDI_XMIT_EMPTY);
+	return (qlen > 0) || !(GUS_MIDI_STATUS() & MIDI_XMIT_EMPTY);
 }
 
 #define MIDI_SYNTH_NAME	"Gravis Ultrasound Midi"
mm/slab.c renamed from mm/slab.c~ +1 -1
@@ -1643,7 +1643,7 @@
 	if (cachep->ctor && cachep->flags & SLAB_POISON) {
 		unsigned long	ctor_flags = SLAB_CTOR_CONSTRUCTOR;
 
-		if (!flags & __GFP_WAIT)
+		if (!(flags & __GFP_WAIT))
 			ctor_flags |= SLAB_CTOR_ATOMIC;
 
 		cachep->ctor(objp, cachep, ctor_flags);
net/sctp/tsnmap.c renamed from net/sctp/tsnmap.c~ +1 -1
@@ -246,7 +246,7 @@
 	/* The Gap Ack Block happens to end at the end of the
 	 * overflow map.
 	 */
-	if (started & !ended) {
+	if (started && !ended) {
 		ended++;
 		_end = map->len + map->len - 1;
 	}
drivers/serial/uart00.c renamed from drivers/serial/uart00.c~ +2 -2
@@ -235,8 +235,8 @@
 
 	status = UART_GET_MSR(port);
 
-	if (!status & (UART_MSR_DCTS_MSK | UART_MSR_DDSR_MSK | 
-		       UART_MSR_TERI_MSK | UART_MSR_DDCD_MSK))
+	if (!(status & (UART_MSR_DCTS_MSK | UART_MSR_DDSR_MSK | 
+			UART_MSR_TERI_MSK | UART_MSR_DDCD_MSK)))
 		return;
 
 	if (status & UART_MSR_DDCD_MSK)
#1 lore raw

mm/slab.c line 1649

Quoted 11 lines · Norbert Kiesel
mm/slab.c renamed from mm/slab.c~ +1 -1
@@ -1643,7 +1643,7 @@
 	if (cachep->ctor && cachep->flags & SLAB_POISON) {
 		unsigned long	ctor_flags = SLAB_CTOR_CONSTRUCTOR;
 
-		if (!flags & __GFP_WAIT)
+		if (!(flags & __GFP_WAIT))
 			ctor_flags |= SLAB_CTOR_ATOMIC;
 
 		cachep->ctor(objp, cachep, ctor_flags);

Holy cow! This is major.

akpm, please expedite.

-- wli

#2 lore raw
Quoted 11 lines · Norbert Kiesel
Quoted 11 lines
mm/slab.c renamed from mm/slab.c~ +1 -1
@@ -1643,7 +1643,7 @@
 	if (cachep->ctor && cachep->flags & SLAB_POISON) {
 		unsigned long	ctor_flags = SLAB_CTOR_CONSTRUCTOR;
 
-		if (!flags & __GFP_WAIT)
+		if (!(flags & __GFP_WAIT))
 			ctor_flags |= SLAB_CTOR_ATOMIC;
 
 		cachep->ctor(objp, cachep, ctor_flags);
Quoted 2 lines · William Lee Irwin III

Holy cow! This is major.
akpm, please expedite.

Already fixed in 2.5.63-bk sorry about the noise.

-- wli