[PATCH] ALSA/ASoC: replace ternary operator with min()
Mark Brown
broonie at kernel.org
Wed Oct 26 14:25:40 CEST 2022
On Wed, Oct 26, 2022 at 07:28:26AM +0200, Takashi Iwai wrote:
> Mark Brown wrote:
> > On Tue, Oct 25, 2022 at 10:56:11PM +0800, wangkailong at jari.cn wrote:
> > > sound/soc/soc-ops.c:817: WARNING opportunity for min()
> > > kfree(uctl);
> > > - return err < 0 ? err : 0;
> > > + return min(err, 0);
> > I don't think this is a good warning, while I'm no big fan of the
> > ternery operator the new code is less clear about the intent than the
> > old code.
> Agreed. That use of ternery is a standard idiom.
> If we have to eliminate the use of ternery inevitably, it'd be better
> to introduce a new macro for clarity instead.
It looks like it's more about identifying a pattern that could be min()
but not being able to detect the semantics of why we're comparing
numbers.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20221026/9bb76ff2/attachment.sig>
More information about the Alsa-devel
mailing list