On Mon, Nov 11, 2024 at 07:51:45PM +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.
> @@ -989,7 +989,7 @@ 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";
> }
Your changelog wasn't very clear on this but the tests in this if/else
tree are
if (ftr_ovr != tmp) {
} else if (ftr_new != tmp) {
} else if (ftr_ovr == tmp) {
}
so your analysis is accurate, the first and last tests are the inverse
of each other so onr must be true. This should be clear from your
commit log. Also all of those branches set "str" and we then
immediately test
if (str)
before logging a diagnostic. If we're looking to reduce unneeded tests
then either that one is redundant too or there's another bug in the
logic (I think from a quick scan just the former).