From: Tejun Heo <tj@kernel.org>
To: Zhiqi Zhang <zhiqizhangg@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Michal Koutny <mkoutny@suse.com>, Shuah Khan <shuah@kernel.org>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2] cgroup: Preserve sign for fractional input
Date: Sun, 29 Nov 2026 06:58:53 -1000 [thread overview]
Message-ID: <b25a6257953b776dddb7b02ba6083a38@kernel.org> (raw)
In-Reply-To: <20261129150117.67061-1-zhiqizhangg@gmail.com>
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
prev parent reply other threads:[~2026-11-29 16:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 6:59 [PATCH] cgroup: Preserve sign for fractional input Zhiqi Zhang
2026-11-27 14:49 ` Tejun Heo
2026-11-29 15:01 ` [PATCH v2] " Zhiqi Zhang
2026-11-29 16:58 ` Tejun Heo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b25a6257953b776dddb7b02ba6083a38@kernel.org \
--to=tj@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=shuah@kernel.org \
--cc=zhiqizhangg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox