Re: [PATCH] net: Replace the ternary conditional operator with min()

From: Russell King (Oracle)
Date: Tue May 30 2023 - 05:09:35 EST


On Tue, May 30, 2023 at 04:45:30PM +0800, Lu Hongfei wrote:
> It would be better to replace the traditional ternary conditional
> operator with min()

I don't think this is any "better". It's not really a "let's return the
minimum of two values" even though that is what it ends up functionally
being.

Semantically, it's "Is there an error? Yes, then return the error.
Otherwise return success" where an error in the kernel is defined as a
negative integer and success as generally zero, or sometimes a small
positive integer.

Replacing these with "min()" makes the code _less_ readable.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!