netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 3c59x: Don't assign when a comparison is intended
@ 2010-12-25 20:30 Jesper Juhl
  2010-12-25 20:50 ` richard -rw- weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2010-12-25 20:30 UTC (permalink / raw)
  To: netdev; +Cc: vortex, becker, Steffen Klassert, linux-kernel

Hi,

In drivers/net/3c59x.c::vortex_probe1() we have this code:

        if (gendev) {
                if ((pdev = DEVICE_PCI(gendev))) {
                        print_name = pci_name(pdev);
                }

                if ((edev = DEVICE_EISA(gendev))) {
                        print_name = dev_name(&edev->dev);
                }
        }

I believe these assignments were intended to be comparisons.
If I'm correct, then here's a patch to fix that up.


Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 3c59x.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 0a92436f..db8a80e 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -1110,11 +1110,11 @@ static int __devinit vortex_probe1(struct device *gendev,
 	}
 
 	if (gendev) {
-		if ((pdev = DEVICE_PCI(gendev))) {
+		if ((pdev == DEVICE_PCI(gendev))) {
 			print_name = pci_name(pdev);
 		}
 
-		if ((edev = DEVICE_EISA(gendev))) {
+		if ((edev == DEVICE_EISA(gendev))) {
 			print_name = dev_name(&edev->dev);
 		}
 	}


-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] 3c59x: Don't assign when a comparison is intended
  2010-12-25 20:50 ` richard -rw- weinberger
@ 2010-12-25 20:45   ` Jesper Juhl
  2010-12-25 21:00     ` richard -rw- weinberger
  2010-12-25 22:17   ` Wolfram Sang
  1 sibling, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2010-12-25 20:45 UTC (permalink / raw)
  To: richard -rw- weinberger; +Cc: netdev, Steffen Klassert, linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1093 bytes --]

On Sat, 25 Dec 2010, richard -rw- weinberger wrote:

> On Sat, Dec 25, 2010 at 9:30 PM, Jesper Juhl <jj@chaosbits.net> wrote:
> > Hi,
> >
> > In drivers/net/3c59x.c::vortex_probe1() we have this code:
> >
> >        if (gendev) {
> >                if ((pdev = DEVICE_PCI(gendev))) {
> >                        print_name = pci_name(pdev);
> >                }
> >
> >                if ((edev = DEVICE_EISA(gendev))) {
> >                        print_name = dev_name(&edev->dev);
> >                }
> >        }
> >
> > I believe these assignments were intended to be comparisons.
> > If I'm correct, then here's a patch to fix that up.
> 
> I don't think so. Look at the extra brackets.
> 
> The code can also written as:
> 
> pdev = DEVICE_PCI(gendev);
> if(pdev)
>   print_name = pci_name(pdev);
> 

Arrgh, I completely missed that - damn.
You are correct I think and my patch is wrong.
Thanks for taking a look.


-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.

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

* Re: [PATCH] 3c59x: Don't assign when a comparison is intended
  2010-12-25 20:30 [PATCH] 3c59x: Don't assign when a comparison is intended Jesper Juhl
@ 2010-12-25 20:50 ` richard -rw- weinberger
  2010-12-25 20:45   ` Jesper Juhl
  2010-12-25 22:17   ` Wolfram Sang
  0 siblings, 2 replies; 5+ messages in thread
From: richard -rw- weinberger @ 2010-12-25 20:50 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: netdev, vortex, becker, Steffen Klassert, linux-kernel

On Sat, Dec 25, 2010 at 9:30 PM, Jesper Juhl <jj@chaosbits.net> wrote:
> Hi,
>
> In drivers/net/3c59x.c::vortex_probe1() we have this code:
>
>        if (gendev) {
>                if ((pdev = DEVICE_PCI(gendev))) {
>                        print_name = pci_name(pdev);
>                }
>
>                if ((edev = DEVICE_EISA(gendev))) {
>                        print_name = dev_name(&edev->dev);
>                }
>        }
>
> I believe these assignments were intended to be comparisons.
> If I'm correct, then here's a patch to fix that up.

I don't think so. Look at the extra brackets.

The code can also written as:

pdev = DEVICE_PCI(gendev);
if(pdev)
  print_name = pci_name(pdev);


>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  3c59x.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
> index 0a92436f..db8a80e 100644
> --- a/drivers/net/3c59x.c
> +++ b/drivers/net/3c59x.c
> @@ -1110,11 +1110,11 @@ static int __devinit vortex_probe1(struct device *gendev,
>        }
>
>        if (gendev) {
> -               if ((pdev = DEVICE_PCI(gendev))) {
> +               if ((pdev == DEVICE_PCI(gendev))) {
>                        print_name = pci_name(pdev);
>                }
>
> -               if ((edev = DEVICE_EISA(gendev))) {
> +               if ((edev == DEVICE_EISA(gendev))) {
>                        print_name = dev_name(&edev->dev);
>                }
>        }
>
>
> --
> Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
> Plain text mails only, please.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

-- 
Thanks,
//richard

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

* Re: [PATCH] 3c59x: Don't assign when a comparison is intended
  2010-12-25 20:45   ` Jesper Juhl
@ 2010-12-25 21:00     ` richard -rw- weinberger
  0 siblings, 0 replies; 5+ messages in thread
From: richard -rw- weinberger @ 2010-12-25 21:00 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: netdev, Steffen Klassert, linux-kernel

On Sat, Dec 25, 2010 at 9:45 PM, Jesper Juhl <jj@chaosbits.net> wrote:
> On Sat, 25 Dec 2010, richard -rw- weinberger wrote:
>
>> On Sat, Dec 25, 2010 at 9:30 PM, Jesper Juhl <jj@chaosbits.net> wrote:
>> > Hi,
>> >
>> > In drivers/net/3c59x.c::vortex_probe1() we have this code:
>> >
>> >        if (gendev) {
>> >                if ((pdev = DEVICE_PCI(gendev))) {
>> >                        print_name = pci_name(pdev);
>> >                }
>> >
>> >                if ((edev = DEVICE_EISA(gendev))) {
>> >                        print_name = dev_name(&edev->dev);
>> >                }
>> >        }
>> >
>> > I believe these assignments were intended to be comparisons.
>> > If I'm correct, then here's a patch to fix that up.
>>
>> I don't think so. Look at the extra brackets.
>>
>> The code can also written as:
>>
>> pdev = DEVICE_PCI(gendev);
>> if(pdev)
>>   print_name = pci_name(pdev);
>>
>
> Arrgh, I completely missed that - damn.
> You are correct I think and my patch is wrong.
> Thanks for taking a look.

BTW: gcc is smart enough to catch such typos.

if(x = 3){
 ...
}

...would trigger a warning like this one:
"warning: suggest parentheses around assignment used as truth value"

>
> --
> Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
> Plain text mails only, please.
>

-- 
Thanks,
//richard

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

* Re: [PATCH] 3c59x: Don't assign when a comparison is intended
  2010-12-25 20:50 ` richard -rw- weinberger
  2010-12-25 20:45   ` Jesper Juhl
@ 2010-12-25 22:17   ` Wolfram Sang
  1 sibling, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2010-12-25 22:17 UTC (permalink / raw)
  To: richard -rw- weinberger
  Cc: Jesper Juhl, netdev, vortex, becker, Steffen Klassert,
	linux-kernel

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

On Sat, Dec 25, 2010 at 09:50:56PM +0100, richard -rw- weinberger wrote:
> On Sat, Dec 25, 2010 at 9:30 PM, Jesper Juhl <jj@chaosbits.net> wrote:
> > Hi,
> >
> > In drivers/net/3c59x.c::vortex_probe1() we have this code:
> >
> >        if (gendev) {
> >                if ((pdev = DEVICE_PCI(gendev))) {
> >                        print_name = pci_name(pdev);
> >                }
> >
> >                if ((edev = DEVICE_EISA(gendev))) {
> >                        print_name = dev_name(&edev->dev);
> >                }
> >        }
> >
> > I believe these assignments were intended to be comparisons.
> > If I'm correct, then here's a patch to fix that up.
> 
> I don't think so. Look at the extra brackets.
> 
> The code can also written as:
> 
> pdev = DEVICE_PCI(gendev);
> if(pdev)
>   print_name = pci_name(pdev);

... which looks much better and could be worth a patch as well.

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

end of thread, other threads:[~2010-12-25 22:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-25 20:30 [PATCH] 3c59x: Don't assign when a comparison is intended Jesper Juhl
2010-12-25 20:50 ` richard -rw- weinberger
2010-12-25 20:45   ` Jesper Juhl
2010-12-25 21:00     ` richard -rw- weinberger
2010-12-25 22:17   ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).