From mboxrd@z Thu Jan 1 00:00:00 1970 From: ralph@inputplus.co.uk (Ralph Corderoy) Date: Wed, 08 Nov 2017 18:14:20 +0000 Subject: [TUHS] C question for the historians In-Reply-To: References: Message-ID: <20171108181420.517711F949@orac.inputplus.co.uk> Hi art, > > if (flags & DLADM_OPT_PERSIST) { ... > > if ((flags & DLADM_OPT_PERSIST) == 0) { ... > To me, anything non-zero is "true" so the first is perfectly > acceptable. It's not what acceptable that matters, but what's idiomatic as that is instantly familiar to other readers and lets them read code without being jolted out of concentrating on the important stuff by wondering why the expression isn't idiomatic, was something else meant instead, and does it mean the author has dodgy practices. `if (w & MASK)' is idiomatic. > The original assertion in the discussion was that the following is not > "right" because of the mixing of bitwise and boolean. > > > if ((flags & DLADM_OPT_PERSIST) && (link_flags & DLMGMT_PERSIST)) { What's the alternative? As the Eskimo C FAQ points out, if you think if ((w & MASK) != FALSE) is better then why stop there? Why not if (((w & MASK) != FALSE) == TRUE) -- Cheers, Ralph. https://plus.google.com/+RalphCorderoy