Message ID | 20240927-cocci-6-12-v1-0-a318d4e6a19d@chromium.org |
---|---|
Headers | show |
Series | media: static-analyzers: Fix 6.12-rc1 cocci warnings | expand |
On 27/09/2024 11:42, 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() > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/staging/media/atomisp/pci/sh_css_frac.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/media/atomisp/pci/sh_css_frac.h b/drivers/staging/media/atomisp/pci/sh_css_frac.h > index 8ba65161f7a9..9642506d2388 100644 > --- a/drivers/staging/media/atomisp/pci/sh_css_frac.h > +++ b/drivers/staging/media/atomisp/pci/sh_css_frac.h > @@ -37,7 +37,7 @@ static inline int sDIGIT_FITTING(int v, int a, int b) > int fit_shift = sFRACTION_BITS_FITTING(a) - b; > > v >>= sSHIFT; > - v >>= fit_shift > 0 ? fit_shift : 0; > + v >>= max(fit_shift, 0); Does the warning go away if you change this to: if (fit_shift > 0) v >>= fit_shift; Using 'max' for a shift is a bit weird in my opinion. Also this change was done to reduce the min/max calls, so introducing a new max call feels odd (although it should be fine). Note that I think those cocci warnings should perhaps be ignored or dropped. In part because of the huge macro expansion of min and max, but also I often find the code that is not using min or max at least as readable, if not more. Regards, Hans > > return clamp_t(int, v, sISP_VAL_MIN, sISP_VAL_MAX); > } > @@ -47,7 +47,7 @@ static inline unsigned int uDIGIT_FITTING(unsigned int v, int a, int b) > int fit_shift = uFRACTION_BITS_FITTING(a) - b; > > v >>= uSHIFT; > - v >>= fit_shift > 0 ? fit_shift : 0; > + v >>= max(fit_shift, 0); > > return clamp_t(unsigned int, v, uISP_VAL_MIN, uISP_VAL_MAX); > } >
This patchset introduces fixes for all the new warnings introduced in Linux 6.12-rc1 Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- Ricardo Ribalda (3): media: ti: cal: Use str_up_down() staging: media: ipu3:Use str_down_up() media: atomisp: Use max() macros drivers/media/platform/ti/cal/cal-camerarx.c | 2 +- drivers/staging/media/atomisp/pci/sh_css_frac.h | 4 ++-- drivers/staging/media/ipu3/ipu3-css.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) --- base-commit: 075dbe9f6e3c21596c5245826a4ee1f1c1676eb8 change-id: 20240927-cocci-6-12-4c571bc8e9dd Best regards,