lkml.org 
[lkml]   [2017]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 1/2] at24: support eeproms that do not auto-rollover reads.
On Thu, Dec 07, 2017 at 10:33:51PM +0100, Bartosz Golaszewski wrote:
> 2017-12-07 20:02 GMT+01:00 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> > Hello,
> >
> > On Thu, Dec 07, 2017 at 05:26:50PM +0100, Bartosz Golaszewski wrote:
> >> > + if (at24->chip.flags & AT24_FLAG_NO_RDROL) {
> >> > + bits = (at24->chip.flags & AT24_FLAG_ADDR16) ? 16 : 8;
> >>
> >> There's no need for braces around the ternary operator's condition.
> >
> > Even if not required, I'd keep them for clearity.
> >
>
> I don't want to start bikeshedding, so I'll take it as it is, but I
> prefer to avoid braces wherever it's not necessary.

For me the reasoning is: Most people (me included) don't know off-hand
if the semantic of

a & b ? c : d

is
(a & b) ? c : d

or

a & (b ? c : d)

In some situations (e.g. a & b == c) gcc even warns when you don't add
syntactically needless parentheses. The case under discussion isn't such
an example though.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |

\
 
 \ /
  Last update: 2017-12-07 22:58    [W:0.047 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site