Re: [PATCH] cpumask: Preserve short reads in cpumap printing helpers

From: Tobias Klauser

Date: Wed Oct 21 2026 - 10:47:25 EST


On 2026-10-20 at 19:01:26 +0200, Hungyu Lin <dennylin0707@xxxxxxxxx> wrote:
> The cpumap printing helpers unconditionally subtract one from the bitmap
> helper's return value to exclude a terminating NUL. A partial read may
> not reach that NUL, so this also subtracts a data byte from the returned
> length. A one-byte read therefore returns zero even when data remains.
> For example, this command prints nothing despite the file being nonempty:
>
> head -c 1 /sys/devices/system/cpu/cpu0/topology/core_cpus_list
>
> Subtract one only when the copied range actually ends in NUL. This
> preserves short reads, EOF and negative error returns while continuing
> to exclude the terminator from complete sysfs reads.
>
> Fixes: c86a2d9058c5 ("cpumask: Omit terminating null byte in cpumap_print_{list,bitmask}_to_buf")
> Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>

Reviewed-by: Tobias Klauser <tklauser@xxxxxxxxxx>

Thanks