Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Nov 2002 23:16:23 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        grog@FreeBSD.org
Cc:        bde@zeta.org.au, julian@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sbin/fsck_ffs pass5.c
Message-ID:  <20021125.231623.131888344.imp@bsdimp.com>
In-Reply-To: <20021126002007.GZ41068@wantadilla.lemis.com>
References:  <200211242141.gAOLfgKf007413@repoman.freebsd.org> <20021125165825.R55700-100000@gamplex.bde.org> <20021126002007.GZ41068@wantadilla.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20021126002007.GZ41068@wantadilla.lemis.com>
            "Greg 'groggy' Lehey" <grog@FreeBSD.org> writes:
: On Monday, 25 November 2002 at 17:00:03 +1100, Bruce Evans wrote:
: > On Sun, 24 Nov 2002, Julian Elischer wrote:
: >
: >> julian      2002/11/24 13:41:42 PST
: >>
: >>   Modified files:
: >>     sbin/fsck_ffs        pass5.c
: >>   Log:
: >>   Fsck needs to check each CG's rotor values to ensure thay are not -ve.
: >>   It seems a common corruption to have them -ve (I've seen it several times)
: >>   and if fsck doesn't fix it, it leads to a kernel pagefault.
: >>
: >>   Reviewd by: kirk
: >>   Submitted by: Eric Jacobs <eaja@erols.com> and me independently.
: >>   MFC in: 2 days
: >
: > Please fix the style bugs (excessive parentheses) in this before merging.
: 
: I thought there was consensus that additional parentheses were not
: necessarily a Bad Thing if they served to demonstrate operator
: precedence, as here.

Not when it is this simple:

+               if ((cg->cg_rotor >= 0) && (cg->cg_rotor < newcg->cg_ndblk))

Anybody that has half a 'C' clue know that those aren't needed.  The
times they are needed is when they are more complex.  That was also
part of the consensus.

Eg, The above should be written like:
+               if (cg->cg_rotor >= 0 && cg->cg_rotor < newcg->cg_ndblk)
which is clearer, but something like

	if (a == x && b == y || c == z)

should be written as

	if (a == x && (b == y || c == z))

since that is clearer and likely what was intended.

That was the consensus.  When it is needed for clarity.  Many people
that learned pascal originally keep the extra parens because they are
needed there.  However, there's a huge body of code that writes the
above code in the second way I sighted, not the first.

Warner

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021125.231623.131888344.imp>