lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vc=hSTWzSDToijXJGWxiHA1JOA2e8R0YYmETQ+tTfVhYw@mail.gmail.com>
Date:   Sat, 7 Sep 2019 23:23:53 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Joe Perches <joe@...ches.com>
Cc:     Jonathan Corbet <corbet@....net>,
        Linux Documentation List <linux-doc@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Louis Taylor <louis@...gniz.eu>
Subject: Re: [PATCH] docs: printk-formats: Stop encouraging use of unnecessary
 %h[xudi] and %hh[xudi]

On Sat, Sep 7, 2019 at 9:15 PM Joe Perches <joe@...ches.com> 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.

> -               char                    %hhd or %hhx
> -               short int               %hd or %hx
> +               char                    %d or %x
> +               short int               %d or %x

> +               s8                      %d or %x
> +               s16                     %d or %x

This is incorrect. Integral promotions promotes also sign, which will
produce too many f:s.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ