Re: [PATCH v2] x86/platform/uv: Rework NMI "action" modparam handling
From: Hans de Goede
Date: Sat Sep 16 2023 - 08:58:57 EST
Hi,
On 9/14/23 10:42, Andy Shevchenko wrote:
> On Wed, Sep 13, 2023 at 9:01 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>>
>> Rework NMI "action" modparam handling:
>>
>> 1. Replace the uv_nmi_action string with an enum; and
>> 2. Use sysfs_match_string() for string parsing in param_set_action()
>
> ...
>
> Don't you need to include string.h?
Yes (pre-existing problem really, but still). Will fix for v3.
>
> ...
>
>> +enum action_t {
>> + nmi_act_kdump,
>> + nmi_act_dump,
>> + nmi_act_ips,
>> + nmi_act_kdb,
>> + nmi_act_kgdb,
>> + nmi_act_health,
>> };
>
>> +
>> +static_assert(ARRAY_SIZE(actions) == ARRAY_SIZE(actions_desc));
>
> I believe with enum in place you don't need this, just add a terminator to it
>
> enum action_t {
> ...
> nmi_act_max
> };
>
> and use as an array size both arrays.
>
> ...
>
>> - int i;
>> - int n = ARRAY_SIZE(valid_acts);
>
>> + int i, n = ARRAY_SIZE(actions);
>
> Since you are changing them, why not make them unsigned?
i is used to store the result of sysfs_match_string() which
returns a negative errno.
>
> ...
>
>> - pr_err("UV: Invalid NMI action:%s, valid actions are:\n", arg);
>> + pr_err("UV: Invalid NMI action:%s, valid actions are:\n", val);
>
> As mentioned previously the val may or may not have a new line in it.
> I dunno about comma removal, but a new line presence can be easily checked.
>
> Either way it's not so critical, hence removing comma. or replacing it
> by '-' (dash) may be enough.
I'll fix this for v3 by not printing the wrong val at all as suggested
by Steve Wahl.
Regards,
Hans