RE: [PATCH] [v2] platform/surface: aggregator: avoid clang -Wconstant-conversion warning
From: David Laight
Date: Mon May 17 2021 - 04:31:22 EST
From: Nathan Chancellor
> Sent: 14 May 2021 22:23
> >
> > Clang complains about the assignment of SSAM_ANY_IID to
> > ssam_device_uid->instance:
Has this been raised with clang?
...
> > - .target = ((tid) != SSAM_ANY_TID) ? (tid) : 0, \
> > - .instance = ((iid) != SSAM_ANY_IID) ? (iid) : 0, \
> > - .function = ((fun) != SSAM_ANY_FUN) ? (fun) : 0 \
> > + .target = __builtin_choose_expr((tid) != SSAM_ANY_TID, (tid), 0), \
> > + .instance = __builtin_choose_expr((iid) != SSAM_ANY_IID, (iid), 0), \
> > + .function = __builtin_choose_expr((fun) != SSAM_ANY_FUN, (fun), 0)
A simpler alternative:
= fun * (fun != SSAM_ANY_FUN)
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)