Skip to contentSkip to conversation

staging: media: meson: vdec: use min() for comparison and assignment

PATCH In review Deepak R Varma 2 participants 2 messages Nov 7, 2022 – Nov 8, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: media: meson: vdec: use min() for comparison and assignment

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.

---
 drivers/staging/media/meson/vdec/codec_vp9.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/media/meson/vdec/codec_vp9.c +3 -4
index 897f5d7a6aad..da7265c8de37 100644
@@ -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

maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Deepak R Varma

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.

---
  drivers/staging/media/meson/vdec/codec_vp9.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)

<snip>