Message ID | 20220513133255.58600-1-guozhengkui@vivo.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: platform: replace ternary operator with max() | expand |
Hi Guo Zhengkui, Please mention the driver in the subject line! Saying 'media: platform:' suggests changes throughout many media/platform drivers, but this is just for a single driver. Regards, Hans On 5/13/22 15:32, Guo Zhengkui wrote: > Fix the following coccicheck warning: > > drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c:1712:24-25: > WARNING opportunity for max() > > max() macro is defined in include/linux/minmax.h. It avoids multiple > evaluations of the arguments when non-constant and performs strict > type-checking. > > Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com> > --- > drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c > index 456287186ad8..55814041b8d8 100644 > --- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c > +++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c > @@ -1709,7 +1709,7 @@ static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx, > w_ratio = ctx->out_q.w / r->width; > h_ratio = ctx->out_q.h / r->height; > > - scale_factor = w_ratio > h_ratio ? w_ratio : h_ratio; > + scale_factor = max(w_ratio, h_ratio); > scale_factor = clamp_val(scale_factor, 1, 8); > > /* Align scale ratio to the nearest power of 2 */
diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c index 456287186ad8..55814041b8d8 100644 --- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c @@ -1709,7 +1709,7 @@ static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx, w_ratio = ctx->out_q.w / r->width; h_ratio = ctx->out_q.h / r->height; - scale_factor = w_ratio > h_ratio ? w_ratio : h_ratio; + scale_factor = max(w_ratio, h_ratio); scale_factor = clamp_val(scale_factor, 1, 8); /* Align scale ratio to the nearest power of 2 */
Fix the following coccicheck warning: drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c:1712:24-25: WARNING opportunity for max() max() macro is defined in include/linux/minmax.h. It avoids multiple evaluations of the arguments when non-constant and performs strict type-checking. Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com> --- drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)