Skip to contentSkip to conversation

sound: remove redundant tests on unsigned

PATCH In review Roel Kluin 2 participants 2 messages Jun 22, 2009

Subsystems (3)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 sound: remove redundant tests on unsigned

reg and channel_id are unsigned. When negative they are wrapped and caught by the other test.

---
 sound/pci/ca0106/ca0106_proc.c |    2 +-
 sound/pci/emu10k1/emu10k1x.c   |    3 +--
 sound/pci/emu10k1/emuproc.c    |    2 +-
 sound/soc/codecs/tlv320aic23.c |    2 +-
 4 files changed, 4 insertions(+), 5 deletions(-)
sound/pci/ca0106/ca0106_proc.c +1 -1
index c62b7d1..2deac54 100644
@@ -304,7 +304,7 @@ static void snd_ca0106_proc_reg_write32(struct snd_info_entry *entry,
         while (!snd_info_get_line(buffer, line, sizeof(line))) {
                 if (sscanf(line, "%x %x", &reg, &val) != 2)
                         continue;
-                if ((reg < 0x40) && (reg >=0) && (val <= 0xffffffff) ) {
+		if ((reg < 0x40) && (val <= 0xffffffff)) {
 			spin_lock_irqsave(&emu->emu_lock, flags);
 			outl(val, emu->port + (reg & 0xfffffffc));
 			spin_unlock_irqrestore(&emu->emu_lock, flags);
sound/pci/emu10k1/emu10k1x.c +1 -2
index 4d3ad79..957b130 100644
@@ -1040,8 +1040,7 @@ static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry,
 		if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
 			continue;
 
-		if ((reg < 0x49) && (reg >= 0) && (val <= 0xffffffff) 
-		    && (channel_id >= 0) && (channel_id <= 2) )
+		if ((reg < 0x49) && (val <= 0xffffffff) && (channel_id <= 2))
 			snd_emu10k1x_ptr_write(emu, reg, channel_id, val);
 	}
 }
sound/pci/emu10k1/emuproc.c +1 -1
index 216f974..6ad3825 100644
@@ -527,7 +527,7 @@ static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
 	while (!snd_info_get_line(buffer, line, sizeof(line))) {
 		if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
 			continue;
-		if ((reg < 0xa0) && (reg >= 0) && (val <= 0xffffffff) && (channel_id >= 0) && (channel_id <= 3) )
+		if ((reg < 0xa0) && (val <= 0xffffffff) && (channel_id <= 3))
 			snd_ptr_write(emu, iobase, reg, channel_id, val);
 	}
 }
sound/soc/codecs/tlv320aic23.c +1 -1
index 0b8dcb5..6f8cd8d 100644
@@ -85,7 +85,7 @@ static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg,
 	 * of data into val
 	 */
 
-	if ((reg < 0 || reg > 9) && (reg != 15)) {
+	if ((reg > 9) && (reg != 15)) {
 		printk(KERN_WARNING "%s Invalid register R%u\n", __func__, reg);
 		return -1;
 	}
#1 lore raw

At Mon, 22 Jun 2009 17:58:27 +0200,

Quoted 5 lines · Roel Kluin

reg and channel_id are unsigned. When negative they are wrapped and caught by the other test.

This seems unable to apply to the latest tree.
Could you rebase?

thanks,

Takashi

Quoted 61 lines
---
 sound/pci/ca0106/ca0106_proc.c |    2 +-
 sound/pci/emu10k1/emu10k1x.c   |    3 +--
 sound/pci/emu10k1/emuproc.c    |    2 +-
 sound/soc/codecs/tlv320aic23.c |    2 +-
 4 files changed, 4 insertions(+), 5 deletions(-)
sound/pci/ca0106/ca0106_proc.c +1 -1
index c62b7d1..2deac54 100644
@@ -304,7 +304,7 @@ static void snd_ca0106_proc_reg_write32(struct snd_info_entry *entry,
         while (!snd_info_get_line(buffer, line, sizeof(line))) {
                 if (sscanf(line, "%x %x", &reg, &val) != 2)
                         continue;
-                if ((reg < 0x40) && (reg >=0) && (val <= 0xffffffff) ) {
+		if ((reg < 0x40) && (val <= 0xffffffff)) {
 			spin_lock_irqsave(&emu->emu_lock, flags);
 			outl(val, emu->port + (reg & 0xfffffffc));
 			spin_unlock_irqrestore(&emu->emu_lock, flags);
sound/pci/emu10k1/emu10k1x.c +1 -2
index 4d3ad79..957b130 100644
@@ -1040,8 +1040,7 @@ static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry,
 		if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
 			continue;
 
-		if ((reg < 0x49) && (reg >= 0) && (val <= 0xffffffff) 
-		    && (channel_id >= 0) && (channel_id <= 2) )
+		if ((reg < 0x49) && (val <= 0xffffffff) && (channel_id <= 2))
 			snd_emu10k1x_ptr_write(emu, reg, channel_id, val);
 	}
 }
sound/pci/emu10k1/emuproc.c +1 -1
index 216f974..6ad3825 100644
@@ -527,7 +527,7 @@ static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
 	while (!snd_info_get_line(buffer, line, sizeof(line))) {
 		if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
 			continue;
-		if ((reg < 0xa0) && (reg >= 0) && (val <= 0xffffffff) && (channel_id >= 0) && (channel_id <= 3) )
+		if ((reg < 0xa0) && (val <= 0xffffffff) && (channel_id <= 3))
 			snd_ptr_write(emu, iobase, reg, channel_id, val);
 	}
 }
sound/soc/codecs/tlv320aic23.c +1 -1
index 0b8dcb5..6f8cd8d 100644
@@ -85,7 +85,7 @@ static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg,
 	 * of data into val
 	 */
 
-	if ((reg < 0 || reg > 9) && (reg != 15)) {
+	if ((reg > 9) && (reg != 15)) {
 		printk(KERN_WARNING "%s Invalid register R%u\n", __func__, reg);
 		return -1;
 	}