[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGsJ_4zGVykhHgpxL5HZVsM453NUMBJRE9CfsfayXWV68whHwA@mail.gmail.com>
Date: Thu, 30 Sep 2021 23:46:44 +1300
From: Barry Song <21cnbao@...il.com>
To: Antti Kervinen <antti.kervinen@...el.com>
Cc: Tobias Klauser <tklauser@...tanz.ch>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
LKML <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Barry Song <song.bao.hua@...ilicon.com>,
Tian Tao <tiantao6@...ilicon.com>,
Yury Norov <yury.norov@...il.com>
Subject: Re: [PATCH] cpumask: Omit terminating null byte in cpumap_print_{list,bitmask}_to_buf
On Thu, Sep 30, 2021 at 11:31 PM Antti Kervinen
<antti.kervinen@...el.com> wrote:
>
>
> An original function, bitmap_print_to_pagebuf() in lib/bitmap.c,
> returns the number of printed characters, excluding terminating null.
>
a patch has been in
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c86a2d9058c5a4a05d20ef89e699b7a6b2c89da6
I guess it is on the way to linus' tree.
> Commit 1fae5629, a cause of this regression, introduced new functions
> to lib/bitmap.c:
>
> - bitmap_print_to_buf()
> (return value doc missing)
>
> - bitmap_print_bitmask_to_buf()
> (return value doc not explicit about terminating null, but
> can be considered misleading)
>
> - bitmap_print_list_to_buf()
> (the same as above)
>
> Unlike the original function, the return value of new functions
> include the terminating null.
>
> As this behavior is clearly opposite to the original function, and
> functions that print to buffers in general, I would suggest fixing
> this problem by alignign these new functions with the original one:
> excluding the terminating null. And documenting this behavior
> unambiguously.
>
> The suggested change to cpumask_print_{bitmask,list}_to_buf()
> functions decrements possible errors (like -ENOMEM) returned by
> bitmap_print_to_buf(). This must not happen.
Thanks
barry
Powered by blists - more mailing lists