Skip to contentSkip to conversation

drivers/atm/solos-pci.c: fix warning/bug, clean up code

PATCH Applied [email protected] 3 participants 3 messages Nov 17, 2009 – Nov 18, 2009

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

PATCH 1/1 drivers/atm/solos-pci.c: fix warning/bug, clean up code

From: Andrew Morton <[email protected]>

drivers/atm/solos-pci.c: In function 'flash_upgrade':
drivers/atm/solos-pci.c:528: warning: 'fw_name' may be used uninitialized in this function

Cc Chas Williams <[email protected]>
Cc David Woodhouse <[email protected]>
Cc Nathan Williams <[email protected]>
Cc David S. Miller <[email protected]>

---

 drivers/atm/solos-pci.c |   29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/atm/solos-pci.c renamed from drivers/atm/solos-pci.c~drivers-atm-solos-pcic-fix-warning-bug-clean-up-code +16 -13
diff -puN drivers/atm/solos-pci.c~drivers-atm-solos-pcic-fix-warning-bug-clean-up-code drivers/atm/solos-pci.c
@@ -531,34 +531,37 @@ static int flash_upgrade(struct solos_ca
 	int numblocks = 0;
 	int offset;
 
-	if (chip == 0) {
+	switch (chip) {
+	case 0:
 		fw_name = "solos-FPGA.bin";
 		blocksize = FPGA_BLOCK;
-	} 
-	
-	if (chip == 1) {
+		break;
+	case 1:
 		fw_name = "solos-Firmware.bin";
 		blocksize = SOLOS_BLOCK;
-	}
-	
-	if (chip == 2){
+		break;
+	case 2:
 		if (card->fpga_version > LEGACY_BUFFERS){
 			fw_name = "solos-db-FPGA.bin";
 			blocksize = FPGA_BLOCK;
 		} else {
-			dev_info(&card->dev->dev, "FPGA version doesn't support daughter board upgrades\n");
+			dev_info(&card->dev->dev, "FPGA version doesn't support"
+					" daughter board upgrades\n");
 			return -EPERM;
 		}
-	}
-	
-	if (chip == 3){
+		break;
+	case 3:
 		if (card->fpga_version > LEGACY_BUFFERS){
 			fw_name = "solos-Firmware.bin";
 			blocksize = SOLOS_BLOCK;
 		} else {
-		dev_info(&card->dev->dev, "FPGA version doesn't support daughter board upgrades\n");
-		return -EPERM;
+			dev_info(&card->dev->dev, "FPGA version doesn't support"
+					" daughter board upgrades\n");
+			return -EPERM;
 		}
+		break;
+	default:
+		return -ENODEV;
 	}
 
 	if (request_firmware(&fw, fw_name, &card->dev->dev))

_

Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Tue, 2009-11-17 at 14:46 -0800, [email protected] wrote:

From: Andrew Morton <[email protected]>

drivers/atm/solos-pci.c: In function 'flash_upgrade':
drivers/atm/solos-pci.c:528: warning: 'fw_name' may be used uninitialized in this function

Cc Chas Williams <[email protected]>
Cc Nathan Williams <[email protected]>
Cc David S. Miller <[email protected]>
Quoted 60 lines

---

 drivers/atm/solos-pci.c |   29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff -puN drivers/atm/solos-pci.c~drivers-atm-solos-pcic-fix-warning-bug-clean-up-code drivers/atm/solos-pci.c

drivers/atm/solos-pci.c renamed from drivers/atm/solos-pci.c~drivers-atm-solos-pcic-fix-warning-bug-clean-up-code +16 -13
@@ -531,34 +531,37 @@ static int flash_upgrade(struct solos_ca
 	int numblocks = 0;
 	int offset;
 
-	if (chip == 0) {
+	switch (chip) {
+	case 0:
 		fw_name = "solos-FPGA.bin";
 		blocksize = FPGA_BLOCK;
-	} 
-	
-	if (chip == 1) {
+		break;
+	case 1:
 		fw_name = "solos-Firmware.bin";
 		blocksize = SOLOS_BLOCK;
-	}
-	
-	if (chip == 2){
+		break;
+	case 2:
 		if (card->fpga_version > LEGACY_BUFFERS){
 			fw_name = "solos-db-FPGA.bin";
 			blocksize = FPGA_BLOCK;
 		} else {
-			dev_info(&card->dev->dev, "FPGA version doesn't support daughter board upgrades\n");
+			dev_info(&card->dev->dev, "FPGA version doesn't support"
+					" daughter board upgrades\n");
 			return -EPERM;
 		}
-	}
-	
-	if (chip == 3){
+		break;
+	case 3:
 		if (card->fpga_version > LEGACY_BUFFERS){
 			fw_name = "solos-Firmware.bin";
 			blocksize = SOLOS_BLOCK;
 		} else {
-		dev_info(&card->dev->dev, "FPGA version doesn't support daughter board upgrades\n");
-		return -EPERM;
+			dev_info(&card->dev->dev, "FPGA version doesn't support"
+					" daughter board upgrades\n");
+			return -EPERM;
 		}
+		break;
+	default:
+		return -ENODEV;
 	}
 
 	if (request_firmware(&fw, fw_name, &card->dev->dev))

_

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
maintainer Applied
#2 lore raw

From: David Woodhouse <[email protected]>
Date: Tue, 17 Nov 2009 22:55:55 +0000

Quoted 6 lines · On Tue, 2009-11-17 at 14:46 -0800, [email protected] wrote:
Quoted 5 lines

From: Andrew Morton <[email protected]>

drivers/atm/solos-pci.c: In function 'flash_upgrade':
drivers/atm/solos-pci.c:528: warning: 'fw_name' may be used uninitialized in this function

Quoted 6 lines
Quoted 4 lines
Cc Chas Williams <[email protected]>
Cc Nathan Williams <[email protected]>
Cc David S. Miller <[email protected]>

Applied to net-next-2.6