Message ID | 20241113051852.4806-1-hardevsinh.palaniya@siliconsignals.io (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2] arm64: Refactor conditional logic | expand |
On Wed, Nov 13, 2024 at 10:48:18AM +0530, Hardevsinh Palaniya wrote: > Unnecessarily checks ftr_ovr == tmp in an extra else if, which is not > needed because that condition would already be true by default if the > previous conditions are not satisfied. Specifically the first one, if you revise it'd be good to be specific about the logic here. > Additionally, all branches set the variable str, making the subsequent > "if (str)" check redundant Reviewed-by: Mark Brown <broonie@kernel.org>
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 718728a85430..728709483fb7 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -989,17 +989,16 @@ static void init_cpu_ftr_reg(u32 sys_reg, u64 new) /* Override was valid */ ftr_new = tmp; str = "forced"; - } else if (ftr_ovr == tmp) { + } else { /* Override was the safe value */ str = "already set"; } - if (str) - pr_warn("%s[%d:%d]: %s to %llx\n", - reg->name, - ftrp->shift + ftrp->width - 1, - ftrp->shift, str, - tmp & (BIT(ftrp->width) - 1)); + pr_warn("%s[%d:%d]: %s to %llx\n", + reg->name, + ftrp->shift + ftrp->width - 1, + ftrp->shift, str, + tmp & (BIT(ftrp->width) - 1)); } else if ((ftr_mask & reg->override->val) == ftr_mask) { reg->override->val &= ~ftr_mask; pr_warn("%s[%d:%d]: impossible override, ignored\n",
Unnecessarily checks ftr_ovr == tmp in an extra else if, which is not needed because that condition would already be true by default if the previous conditions are not satisfied. Additionally, all branches set the variable str, making the subsequent "if (str)" check redundant Signed-off-by: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io> --- Changelog in V2: - remove str check --- arch/arm64/kernel/cpufeature.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)