linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: media: meson: vdec: use min() for comparison and assignment
@ 2022-11-07 19:11 Deepak R Varma
  2022-11-08  8:00 ` Neil Armstrong
  0 siblings, 1 reply; 2+ messages in thread
From: Deepak R Varma @ 2022-11-07 19:11 UTC (permalink / raw)
  To: Neil Armstrong, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, linux-media,
	linux-amlogic, linux-staging, linux-arm-kernel, linux-kernel

Use of standard min() helper macro is preferred over using ternary
operator for logical evaluation and value assignment. This issue is
identified by coccicheck using the minmax.cocci file.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
 drivers/staging/media/meson/vdec/codec_vp9.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/meson/vdec/codec_vp9.c b/drivers/staging/media/meson/vdec/codec_vp9.c
index 897f5d7a6aad..da7265c8de37 100644
--- a/drivers/staging/media/meson/vdec/codec_vp9.c
+++ b/drivers/staging/media/meson/vdec/codec_vp9.c
@@ -1459,7 +1459,7 @@ static void vp9_tree_merge_probs(unsigned int *prev_prob,
 	if (den == 0) {
 		new_prob = pre_prob;
 	} else {
-		m_count = den < MODE_MV_COUNT_SAT ? den : MODE_MV_COUNT_SAT;
+		m_count = min(den, MODE_MV_COUNT_SAT);
 		get_prob =
 			clip_prob(div_r32(((int64_t)tree_left * 256 +
 					   (den >> 1)),
@@ -1513,7 +1513,7 @@ static void adapt_coef_probs_cxt(unsigned int *prev_prob,
 			/* get binary prob */
 			num = branch_ct[node][0];
 			den = branch_ct[node][0] + branch_ct[node][1];
-			m_count = den < count_sat ? den : count_sat;
+			m_count = min(den, count_sat);

 			get_prob = (den == 0) ?
 					128u :
@@ -1664,8 +1664,7 @@ static void adapt_coef_probs(int prev_kf, int cur_kf, int pre_fc,
 			if (den == 0) {
 				new_prob = pre_prob;
 			} else {
-				m_count = den < MODE_MV_COUNT_SAT ?
-						den : MODE_MV_COUNT_SAT;
+				m_count = min(den, MODE_MV_COUNT_SAT);
 				get_prob =
 				clip_prob(div_r32(((int64_t)
 					count[coef_count_node_start] * 256 +
--
2.34.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: media: meson: vdec: use min() for comparison and assignment
  2022-11-07 19:11 [PATCH] staging: media: meson: vdec: use min() for comparison and assignment Deepak R Varma
@ 2022-11-08  8:00 ` Neil Armstrong
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Armstrong @ 2022-11-08  8:00 UTC (permalink / raw)
  To: Deepak R Varma, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, linux-media,
	linux-amlogic, linux-staging, linux-arm-kernel, linux-kernel

On 07/11/2022 20:11, Deepak R Varma wrote:
> Use of standard min() helper macro is preferred over using ternary
> operator for logical evaluation and value assignment. This issue is
> identified by coccicheck using the minmax.cocci file.
> 
> Signed-off-by: Deepak R Varma <drv@mailo.com>
> ---
>   drivers/staging/media/meson/vdec/codec_vp9.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)

<snip>

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-08  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07 19:11 [PATCH] staging: media: meson: vdec: use min() for comparison and assignment Deepak R Varma
2022-11-08  8:00 ` Neil Armstrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).