Skip to contentSkip to conversation

arm64: cpufeatures: use min and max

PATCH Applied Julia Lawall 3 participants 5 messages Apr 29, 2021 – Apr 30, 2021 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: cpufeatures: use min and max

From: kernel test robot <[email protected]>

Use min and max to make the effect more clear.

Generated by: scripts/coccinelle/misc/minmax.cocci

Fixes 8636e3295ce3 ("coccinelle: misc: add minmax script")
CC Denis Efremov <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git for-5.12
head:   44e793b89bcfe586730f4c6ce3c66174dc07cb37
commit: 8636e3295ce33515c50ef728f0ff3800d97f9f44 [1/5] coccinelle: misc: add minmax script

:::::: branch date: 6 days ago
:::::: commit date: 6 weeks ago

 cpufeature.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/cpufeature.c +2 -2
@@ -695,14 +695,14 @@ static s64 arm64_ftr_safe_value(const st
 		ret = ftrp->safe_val;
 		break;
 	case FTR_LOWER_SAFE:
-		ret = new < cur ? new : cur;
+		ret = min(new, cur);
 		break;
 	case FTR_HIGHER_OR_ZERO_SAFE:
 		if (!cur || !new)
 			break;
 		fallthrough;
 	case FTR_HIGHER_SAFE:
-		ret = new > cur ? new : cur;
+		ret = max(new, cur);
 		break;
 	default:
 		BUG();
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Julia Lawall

From: kernel test robot <[email protected]>

Use min and max to make the effect more clear.

Generated by: scripts/coccinelle/misc/minmax.cocci

Fixes 8636e3295ce3 ("coccinelle: misc: add minmax script")
CC Denis Efremov <[email protected]>

This looks like a nice cleanup, but it's not clear to me what the intended inclusion path for this is, and to avoid fragility I think we must include <linux/minmax.h> explicitly.

With that:

Thanks,
Mark.

Quoted 30 lines

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git for-5.12
head:   44e793b89bcfe586730f4c6ce3c66174dc07cb37
commit: 8636e3295ce33515c50ef728f0ff3800d97f9f44 [1/5] coccinelle: misc: add minmax script

:::::: branch date: 6 days ago
:::::: commit date: 6 weeks ago

 cpufeature.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/cpufeature.c +2 -2
@@ -695,14 +695,14 @@ static s64 arm64_ftr_safe_value(const st
 		ret = ftrp->safe_val;
 		break;
 	case FTR_LOWER_SAFE:
-		ret = new < cur ? new : cur;
+		ret = min(new, cur);
 		break;
 	case FTR_HIGHER_OR_ZERO_SAFE:
 		if (!cur || !new)
 			break;
 		fallthrough;
 	case FTR_HIGHER_SAFE:
-		ret = new > cur ? new : cur;
+		ret = max(new, cur);
 		break;
 	default:
 		BUG();
maintainer
#2 lore raw
In reply to Julia Lawall

Hi Julia,

Quoted 7 lines · Julia Lawall

From: kernel test robot <[email protected]>

Use min and max to make the effect more clear.

Generated by: scripts/coccinelle/misc/minmax.cocci

Fixes 8636e3295ce3 ("coccinelle: misc: add minmax script")

What's with this Fixes tag? I can't find it anywhere and I don't think it warrants such a tag anyway, it's not a bug.

I'll apply it without the tag and include minmax.h as per Mark's comment.

Thanks.

Signature · 1 line
Catalin
#3 lore raw
Quoted 9 lines · Catalin Marinas

Hi Julia,

Quoted 6 lines · Julia Lawall

From: kernel test robot <[email protected]>

Use min and max to make the effect more clear.

Generated by: scripts/coccinelle/misc/minmax.cocci

Quoted 7 lines
Quoted 1 line
Fixes 8636e3295ce3 ("coccinelle: misc: add minmax script")

What's with this Fixes tag? I can't find it anywhere and I don't think it warrants such a tag anyway, it's not a bug.

I'll apply it without the tag and include minmax.h as per Mark's comment.

Oops, sorry about that. It's something that 0-day adds, but I think it is always incorrect for new semantic patches. Please remove it.

thanks,
julia