On Mon, Feb 12, 2024 at 01:38:47PM -0800, Suren Baghdasaryan wrote:
> -     string_get_size(size, 1, STRING_UNITS_2, buf, sizeof(buf));
> +     string_get_size(size, 1, STRING_SIZE_BASE2, buf, sizeof(buf));

This patch could be a whole lot smaller if ...

> +++ b/include/linux/string_helpers.h
> @@ -17,14 +17,13 @@ static inline bool string_is_terminated(const char *s, 
> int len)
>       return memchr(s, '\0', len) ? true : false;
>  }
>  
> -/* Descriptions of the types of units to
> - * print in */
> -enum string_size_units {
> -     STRING_UNITS_10,        /* use powers of 10^3 (standard SI) */
> -     STRING_UNITS_2,         /* use binary powers of 2^10 */
> +enum string_size_flags {
> +     STRING_SIZE_BASE2       = (1 << 0),
> +     STRING_SIZE_NOSPACE     = (1 << 1),
> +     STRING_SIZE_NOBYTES     = (1 << 2),

you just added:

#define STRING_UNITS_10         0
#define STRING_UNITS_2          STRING_SIZE_BASE2

and you wouldn't need to change any of the callers.


Reply via email to