Thread (5 messages) 5 messages, 3 authors, 2010-12-25

Re: [PATCH] 3c59x: Don't assign when a comparison is intended

From: richard -rw- weinberger <hidden>
Date: 2010-12-25 21:00:51
Also in: lkml

On Sat, Dec 25, 2010 at 9:45 PM, Jesper Juhl [off-list ref] wrote:
On Sat, 25 Dec 2010, richard -rw- weinberger wrote:
quoted
On Sat, Dec 25, 2010 at 9:30 PM, Jesper Juhl [off-list ref] wrote:
quoted
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 [off-list ref]            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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help