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]
Date:   Thu, 19 May 2022 23:21:41 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Kent Overstreet <kent.overstreet@...il.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...r.kernel.org,
        pmladek@...e.com, rostedt@...dmis.org, senozhatsky@...omium.org,
        willy@...radead.org
Subject: Re: [PATCH v2 07/28] lib/printbuf: Unit specifiers

On Thu, May 19, 2022 at 01:24:00PM -0400, Kent Overstreet wrote:
> This adds options to printbuf for specifying whether units should be
> printed raw (default) or with human readable units, and for controlling
> whether human-readable units should be base 2 (default), or base 10.
> 
> This also adds new helpers that obey these options:
> 
>  - pr_human_readable_u64
>  - pr_human_readable_s64
> These obey printbuf->si_units
> 
>  - pr_units_u64
>  - pr_units_s64
> These obey both printbuf-human_readable_units and printbuf->si_units

...

> +void pr_human_readable_s64(struct printbuf *buf, s64 v)
> +{
> +	if (v < 0)
> +		pr_char(buf, '-');
> +	pr_human_readable_u64(buf, abs(v));

Wouldn't -v work?

> +}

...

> + * pr_human_readable_u64 - Print out a u64 according to printbuf unit options

Have you ever compile this? We have kernel doc validator running when compiling
the code...

> + * Units are either raw (default), or human reabable units (controlled via
> + * @buf->human_readable_units)
> + */
> +void pr_units_u64(struct printbuf *out, u64 v)
> +{
> +	if (out->human_readable_units)
> +		pr_human_readable_u64(out, v);
> +	else
> +		pr_buf(out, "%llu", v);
> +}
> +EXPORT_SYMBOL(pr_units_u64);
> +
> +/**
> + * pr_human_readable_s64 - Print out a s64 according to printbuf unit options

Ditto.

> + * Units are either raw (default), or human reabable units (controlled via
> + * @buf->human_readable_units)
> + */
> +void pr_units_s64(struct printbuf *out, s64 v)
> +{
> +	if (v < 0)
> +		pr_char(out, '-');
> +	pr_units_u64(out, v);

Please, start with test cases.

> +}

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ