Re: [PATCH v2] cgroup: Preserve sign for fractional input

From: Tejun Heo

Date: Sun Nov 29 2026 - 11:59:02 EST


Hello, Zhiqi.

On Sun, Nov 29, 2026 at 11:01:17PM +0800, Zhiqi Zhang wrote:
> + /* The whole part does not retain the sign of "-0". */
> + if (*skip_spaces(input) == '-')
> + frac = -frac;
> +
> *v = whole * power_of_ten(dec_shift) + frac;

Maybe read the sign once at the top and let the whole and fraction parsing
deal only with unsigned numbers, e.g. by switching the whole part to %llu,
and negate the composed result at the end?

While at it, can you also add an overflow check? A large whole part wraps
and gets accepted, e.g. "-18446744073709551615" written to cpu.uclamp.min
reads back as 1.00.

Thanks.

--
tejun