Re: [PATCH v4 6/6] x86/microcode/intel: Print when early microcode loading fails

From: Dave Hansen
Date: Tue Jan 17 2023 - 11:36:04 EST


On 1/9/23 07:35, Ashok Raj wrote:
> -static void print_ucode(int old_rev, int new_rev, int date)
> +static void print_ucode(bool failed, int old_rev, int new_rev, int date)
...
> if (rev != mc->hdr.rev)
> - return -1;
> + retval = -1;
>
> uci->cpu_sig.rev = rev;
>
> if (early)
> - print_ucode(old_rev, uci->cpu_sig.rev, mc->hdr.date);
> + print_ucode(retval, old_rev, mc->hdr.rev, mc->hdr.date);
> else
> - print_ucode_info(old_rev, uci->cpu_sig.rev, mc->hdr.date);
> + print_ucode_info(retval, old_rev, uci->cpu_sig.rev, mc->hdr.date);
>
> - return 0;
> + return retval;
> }

I'm generally not a _huge_ fan of having an 'int' implicitly cast to a
bool. The:

print_ucode_info(retval, ...

Line could be right or wrong based on what the retval is logically.
This, on the other hand:

bool failed = false;
...
if (rev != mc->hdr.rev) {
retval = -1;
failed = true;
}
...
print_ucode_info(failed, old_rev, uci->cpu_sig.rev, ...

*Clearly* and unambiguously matches up with:

static void print_ucode(bool failed, int old_rev, ...