lkml.org 
[lkml]   [2019]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]
    On Fri, Sep 06, 2019 at 02:11:51PM -0700, Joe Perches wrote:
    > Standard integer promotion is already done and %hx and %hhx is useless
    > so do not encourage the use of %hh[xudi] or %h[xudi].
    >
    > As Linus said in:
    > Link: https://lore.kernel.org/lkml/CAHk-=wgoxnmsj8GEVFJSvTwdnWm8wVJthefNk2n6+4TC=20e0Q@mail.gmail.com/
    >
    > It's a pointless warning, making for more complex code, and
    > making people remember esoteric printf format details that have no
    > reason for existing.
    >
    > The "h" and "hh" things should never be used. The only reason for them
    > being used if 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).
    >
    > So if what you have a "char" (or unsigned char) you should always just
    > print it out as an "int", knowing that the compiler already did the
    > proper type conversion.

    Yeah, makes sense. Sorry for adding these in the first place.

    Reviewed-by: Louis Taylor <louis@kragniz.eu>

    \
     
     \ /
      Last update: 2019-09-06 23:34    [W:2.331 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site