NetBSD Problem Report #50949
From www@NetBSD.org Fri Mar 11 17:18:24 2016
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id C89ED7AC07
for <gnats-bugs@gnats.NetBSD.org>; Fri, 11 Mar 2016 17:18:24 +0000 (UTC)
Message-Id: <20160311171823.F38CB7ACA6@mollari.NetBSD.org>
Date: Fri, 11 Mar 2016 17:18:23 +0000 (UTC)
From: dcb314@hotmail.com
Reply-To: dcb314@hotmail.com
To: gnats-bugs@NetBSD.org
Subject: src/sys/dev/pcmcia/if_malo_pcmcia.c:637]: (style) Suspicious condition
X-Send-Pr-Version: www-1.0
>Number: 50949
>Category: kern
>Synopsis: src/sys/dev/pcmcia/if_malo_pcmcia.c:637]: (style) Suspicious condition
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Mar 11 17:20:00 +0000 2016
>Closed-Date: Sat Mar 12 01:49:01 +0000 2016
>Last-Modified: Sat Mar 12 01:49:01 +0000 2016
>Originator: David Binderman
>Release: cvs dated 20160311
>Organization:
>Environment:
>Description:
src/sys/dev/pcmcia/if_malo_pcmcia.c:637]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
Source code is
if ((error = ieee80211_media_change(ifp) != ENETRESET))
Maybe better code
if ((error = ieee80211_media_change(ifp)) != ENETRESET)
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: <Paul_Koning@Dell.com>
To: <gnats-bugs@NetBSD.org>, <dcb314@hotmail.com>
Cc: <kern-bug-people@netbsd.org>, <gnats-admin@netbsd.org>,
<netbsd-bugs@netbsd.org>
Subject: Re: kern/50949: src/sys/dev/pcmcia/if_malo_pcmcia.c:637]: (style)
Suspicious condition
Date: Fri, 11 Mar 2016 17:25:26 +0000
> On Mar 11, 2016, at 12:20 PM, <dcb314@hotmail.com> <dcb314@hotmail.com> w=
rote:
>=20
> src/sys/dev/pcmcia/if_malo_pcmcia.c:637]: (style) Suspicious condition (a=
ssignment + comparison); Clarify expression with parentheses.
>=20
>=20
> Source code is
>=20
> if ((error =3D ieee80211_media_change(ifp) !=3D ENETRESET))
>=20
>=20
> Maybe better code
>=20
> if ((error =3D ieee80211_media_change(ifp)) !=3D ENETRESET)
It's a matter of preference, I'll admit. But I would much rather see such =
constructs written as two statements:
error =3D ieee80211_media_change(ifp);
if (error !=3D ENETRESET) ....
Admittedly that doesn't work as well in "while" statements, for those the a=
ssign and test constructs are arguably helpful -- the alternative is a whil=
e (1) with a conditional break, which is definitely a bit more clutter. Bu=
t for "if" statements I'd rather see the two aspects broken out into two se=
parate lines.
paul
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50949 CVS commit: src/sys/dev/pcmcia
Date: Fri, 11 Mar 2016 13:34:15 -0500
Module Name: src
Committed By: christos
Date: Fri Mar 11 18:34:15 UTC 2016
Modified Files:
src/sys/dev/pcmcia: if_malo_pcmcia.c
Log Message:
PR/50949: David Binderman: Fix misplaced parens.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pcmcia/if_malo_pcmcia.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/50949: src/sys/dev/pcmcia/if_malo_pcmcia.c:637]: (style)
Suspicious condition
Date: Sat, 12 Mar 2016 01:42:53 +0000
On Fri, Mar 11, 2016 at 05:25:26PM +0000, Paul_Koning@Dell.com wrote:
> It's a matter of preference, I'll admit. But I would much rather
> see such constructs written as two statements:
>
> error = ieee80211_media_change(ifp);
> if (error != ENETRESET) ....
Me too, for what it's worth. Vertical space doesn't seem as valuable
in the days of 80-line editor windows as it once did.
--
David A. Holland
dholland@netbsd.org
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 12 Mar 2016 01:49:01 +0000
State-Changed-Why:
christos committed it
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.