Re: [PATCH 3/3] media: atomisp: Use max() macros
From: Andy Shevchenko
Date: Fri Sep 27 2024 - 05:54:22 EST
On Fri, Sep 27, 2024 at 09:42:15AM +0000, Ricardo Ribalda wrote:
> The max() macro produce nicer code and also fixes the following cocci
> errors:
>
> drivers/staging/media/atomisp/pci/sh_css_frac.h:40:17-18: WARNING opportunity for max()
> drivers/staging/media/atomisp/pci/sh_css_frac.h:50:17-18: WARNING opportunity for max()
In some (rare) cases it's a bad advice.
NAK.
...
> - v >>= fit_shift > 0 ? fit_shift : 0;
> + v >>= max(fit_shift, 0);
max() with 0 is a bit unusual, esp. taking into account that the operator here
is a right shift. So, what we check here is the signedness of the value to
avoid not only potentially wrong calculations, but also UB. The original code
is clearer for all this.
--
With Best Regards,
Andy Shevchenko