[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <160f2a29-e935-143a-cdae-7b3e1f2797f9@xen0n.name>
Date: Thu, 11 May 2023 18:07:29 +0800
From: WANG Xuerui <kernel@...0n.name>
To: Peter Zijlstra <peterz@...radead.org>,
Youling Tang <tangyouling@...ngson.cn>
Cc: Huacai Chen <chenhuacai@...nel.org>,
Jonathan Corbet <corbet@....net>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Jason Baron <jbaron@...mai.com>,
Zhangjin Wu <falcon@...ylab.org>, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, loongarch@...ts.linux.dev
Subject: Re: [PATCH v2] LoongArch: Add jump-label implementation
On 2023/5/11 15:43, Peter Zijlstra wrote:
> On Thu, May 11, 2023 at 09:33:37AM +0800, Youling Tang wrote:
>
>>>> +void arch_jump_label_transform(struct jump_entry *entry,
>>>> + enum jump_label_type type)
>>>> +{
>>>> + void *addr = (void *)jump_entry_code(entry);
>>>> + u32 insn;
>>>> +
>>>> + if (type == JUMP_LABEL_JMP)
>>>
>>> Please use a switch for dealing with enum-typed values.
>>
>> Because the current type only has JUMP_LABEL_NOP and JUMP_LABEL_JMP,
>> using if may be simpler than switch.
>
> IIRC we used an enum with descriptive names instead of a boolean because
> true/false just doesn't tell you much.
>
> The whole thing fundamentally is a boolean descision though, either
> you write a JMP or a NOP, jump-labels don't have more options.
Ah thanks for the background. My previous suggestion is just kinda
generally applicable software engineering best practice, so if the
actual enum is unlikely to get >2 variants then it should be fine to
keep using "if". Youling, feel free to ignore the piece of comment, and
sorry for not doing my archaeology beforehand. :)
--
WANG "xen0n" Xuerui
Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
Powered by blists - more mailing lists