All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] [PATCH] Fix GCC warning: unused variable
@ 2005-06-24 19:39 Jesse Millan
  2005-06-28 13:55 ` Domen Puncer
  0 siblings, 1 reply; 2+ messages in thread
From: Jesse Millan @ 2005-06-24 19:39 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 267 bytes --]


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.


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 950 bytes --]

Signed-off-by: Jesse Millan <jessem@cs.pdx.edu>

--- linux-2.6.12-rc6.kj/drivers/net/dgrs.c~	2005-06-24 12:05:17.748053320 -0700
+++ linux-2.6.12-rc6.kj/drivers/net/dgrs.c	2005-06-24 12:20:34.474689688 -0700
@@ -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;
 }


[-- Attachment #3: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [KJ] [PATCH] Fix GCC warning: unused variable
  2005-06-24 19:39 [KJ] [PATCH] Fix GCC warning: unused variable Jesse Millan
@ 2005-06-28 13:55 ` Domen Puncer
  0 siblings, 0 replies; 2+ messages in thread
From: Domen Puncer @ 2005-06-28 13:55 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1689 bytes --]

On 24/06/05 12:39 -0700, Jesse Millan wrote:
> 
> 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.
> 

> Signed-off-by: Jesse Millan <jessem@cs.pdx.edu>
> 
> --- linux-2.6.12-rc6.kj/drivers/net/dgrs.c~	2005-06-24 12:05:17.748053320 -0700
> +++ linux-2.6.12-rc6.kj/drivers/net/dgrs.c	2005-06-24 12:20:34.474689688 -0700
> @@ -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;
>  }

'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.

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-06-28 13:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-24 19:39 [KJ] [PATCH] Fix GCC warning: unused variable Jesse Millan
2005-06-28 13:55 ` Domen Puncer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.