[Linux-kernel-mentees] [PATCH RFC] checkpatch: add warning for unnecessary use of %h[xudi] and %hh[xudi]
dwaipayanray1 at gmail.com
Thu Nov 26 07:20:45 UTC 2020
On Thu, Nov 26, 2020 at 1:04 AM Lukas Bulwahn <lukas.bulwahn at gmail.com> wrote:
> On Mi., 25. Nov. 2020 at 20:05, Dwaipayan Ray <dwaipayanray1 at gmail.com> wrote:
>> Modifiers %h and %hh should never be used.
>> Commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use
>> of unnecessary %h[xudi] and %hh[xudi]") specifies that:
>> "Standard integer promotion is already done and %hx and %hhx is useless
>> so do not encourage the use of %hh[xudi] or %h[xudi]."
>> "The "h" and "hh" things should never be used. The only reason for them
>> being used if you have an "int", but you want to print it out as a
>> "char" (and honestly, that is a really bad reason, you'd be better off
>> just using a proper cast to make the code more obvious)."
>> Add a new check to emit a warning on finding an unneeded use of %h or
>> %hh modifier.
> Looks good. You might want to add the link to the original email discussion on lore.kernel.org in the commit message with Link:
Thanks, I will do that and send it off then.
More information about the Linux-kernel-mentees