The patch titled Subject: lib/bitmap.c: simplify bitmap_print_to_pagebuf() has been added to the -mm tree. Its filename is lib-bitmapc-simplify-bitmap_print_to_pagebuf.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/lib-bitmapc-simplify-bitmap_print_to_pagebuf.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/lib-bitmapc-simplify-bitmap_print_to_pagebuf.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> Subject: lib/bitmap.c: simplify bitmap_print_to_pagebuf() len is guaranteed to lie in [1, PAGE_SIZE]. If scnprintf is called with a buffer size of 1, it is guaranteed to return 0. So in the extremely unlikely case of having just one byte remaining in the page, let's just call scnprintf anyway. The only difference is that this will write a '\0' to that final byte in the page, but that's an improvement: We now guarantee that after the call, buf is a properly terminated C string of length exactly the return value. Link: http://lkml.kernel.org/r/20180818131623.8755-8-linux@xxxxxxxxxxxxxxxxxx Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx> Cc: Yury Norov <ynorov@xxxxxxxxxxxxxxxxxx> Cc: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> Cc: Sudeep Holla <sudeep.holla@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/bitmap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/lib/bitmap.c~lib-bitmapc-simplify-bitmap_print_to_pagebuf +++ a/lib/bitmap.c @@ -470,12 +470,9 @@ int bitmap_print_to_pagebuf(bool list, c int nmaskbits) { ptrdiff_t len = PAGE_SIZE - offset_in_page(buf); - int n = 0; - if (len > 1) - n = list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) : - scnprintf(buf, len, "%*pb\n", nmaskbits, maskp); - return n; + return list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) : + scnprintf(buf, len, "%*pb\n", nmaskbits, maskp); } EXPORT_SYMBOL(bitmap_print_to_pagebuf); _ Patches currently in -mm which might be from linux@xxxxxxxxxxxxxxxxxx are lib-bitmapc-remove-wrong-documentation.patch linux-bitmaph-handle-constant-zero-size-bitmaps-correctly.patch linux-bitmaph-remove-redundant-uses-of-small_const_nbits.patch linux-bitmaph-fix-type-of-nbits-in-bitmap_shift_right.patch linux-bitmaph-relax-comment-on-compile-time-constant-nbits.patch lib-bitmapc-fix-remaining-space-computation-in-bitmap_print_to_pagebuf.patch lib-bitmapc-simplify-bitmap_print_to_pagebuf.patch