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

richard -rw- weinberger <[email protected]> Sat, 25 Dec 2010 21:50:56 +0100
Newsgroups gmane.linux.network,gmane.linux.drivers.vortex.devel,gmane.linux.kernel
Message-ID <[email protected]>
On Sat, Dec 25, 2010 at 9:30 PM, Jesper Juhl <[email protected]> wrote:
> Hi,
>
> In drivers/net/3c59x.c::vortex_probe1() we have this code:
>
> =A0 =A0 =A0 =A0if (gendev) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if ((pdev =3D DEVICE_PCI(gendev))) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0print_name =3D pci_nam=
e(pdev);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if ((edev =3D DEVICE_EISA(gendev))) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0print_name =3D dev_nam=
e(&edev->dev);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0}
>
> 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 =3D DEVICE_PCI(gendev);
if(pdev)
  print_name =3D pci_name(pdev);


>
> Signed-off-by: Jesper Juhl <[email protected]>
> ---
> =A03c59x.c | =A0 =A04 ++--
> =A01 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 dev=
ice *gendev,
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0if (gendev) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((pdev =3D DEVICE_PCI(gendev))) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((pdev =3D=3D DEVICE_PCI(gendev))) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0print_name =3D pci_nam=
e(pdev);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
>
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((edev =3D DEVICE_EISA(gendev))) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((edev =3D=3D DEVICE_EISA(gendev))) =
{
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0print_name =3D dev_nam=
e(&edev->dev);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0}
>
>
> --
> Jesper Juhl <[email protected]> =A0 =A0 =A0 =A0 =A0 =A0http://www.chao=
sbits.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-kerne=
l" in
> the body of a message to [email protected]
> More majordomo info at =A0http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at =A0http://www.tux.org/lkml/
>

--=20
Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html