Skip to contentSkip to conversation

Fix GCC warning: unused variable

PATCH In review Jesse Millan 2 participants 2 messages Jun 24, 2005 – Jun 28, 2005

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

PATCH 1/1 Fix GCC warning: unused variable

This function will return either 'eisacount', 'pcicount' or 0. Because of the control flow, one, or both the variables will be unused. Replacing them with one generic variable 'count' instead of the two is more efficient and eliminates the unused variable warning.

drivers/net/dgrs.c renamed from drivers/net/dgrs.c~ +7 -7
@@ -1549,7 +1549,7 @@ MODULE_PARM_DESC(nicmode, "Digi RightSwi
 static int __init dgrs_init_module (void)
 {
 	int	i;
-	int eisacount = 0, pcicount = 0;
+	int count = 0;
 
 	/*
 	 *	Command line variable overrides
@@ -1591,14 +1591,14 @@ static int __init dgrs_init_module (void
 	 *	Find and configure all the cards
 	 */
 #ifdef CONFIG_EISA
-	eisacount = eisa_driver_register(&dgrs_eisa_driver);
-	if (eisacount < 0)
-		return eisacount;
+	count = eisa_driver_register(&dgrs_eisa_driver);
+	if (count < 0)
+		return count;
 #endif
 #ifdef CONFIG_PCI
-	pcicount = pci_register_driver(&dgrs_pci_driver);
-	if (pcicount)
-		return pcicount;
+	count = pci_register_driver(&dgrs_pci_driver);
+	if (count)
+		return count;
 #endif
 	return 0;
 }

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw
Quoted 31 lines · Jesse Millan

This function will return either 'eisacount', 'pcicount' or 0. Because of the control flow, one, or both the variables will be unused. Replacing them with one generic variable 'count' instead of the two is more efficient and eliminates the unused variable warning.

drivers/net/dgrs.c renamed from drivers/net/dgrs.c~ +4 -4
@@ -1549,7 +1549,7 @@ MODULE_PARM_DESC(nicmode, "Digi RightSwi
 static int __init dgrs_init_module (void)
 {
 	int	i;
-	int eisacount = 0, pcicount = 0;
+	int count = 0;
 
 	/*
 	 *	Command line variable overrides
@@ -1591,14 +1591,14 @@ static int __init dgrs_init_module (void
 	 *	Find and configure all the cards
 	 */
 #ifdef CONFIG_EISA
-	eisacount = eisa_driver_register(&dgrs_eisa_driver);
-	if (eisacount < 0)
-		return eisacount;
+	count = eisa_driver_register(&dgrs_eisa_driver);
+	if (count < 0)
+		return count;
 #endif

drivers/net/dgrs.c static int __init dgrs_init_module (void · line 1604

Quoted 10 lines
drivers/net/dgrs.c renamed from drivers/net/dgrs.c~ +3 -3
 #ifdef CONFIG_PCI
-	pcicount = pci_register_driver(&dgrs_pci_driver);
-	if (pcicount)
-		return pcicount;
+	count = pci_register_driver(&dgrs_pci_driver);
+	if (count)
+		return count;
 #endif
 	return 0;
 }

'count' seems a bit misleading, it doesn't count anything. And I don't quite get the logic of this:
If we don't have EISA nor PCI support compiled in we succeed. If we have support for both, but only succeed to register one (i.e. because we don't have a pci bus), we fail.

CONFIG_PCI ifdef seems undeeded, there's a stub version in pci.h.

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors