[PATCH 2/2] ubi: build: replace simple_strtoul with kstrtoul in bytes_str_to_int()
Richard Weinberger
richard at nod.at
Thu May 7 00:30:56 PDT 2026
----- Ursprüngliche Mail -----
> Von: "haoyu.lu" <hechushiguitu666 at gmail.com>
> An: "Miquel Raynal" <miquel.raynal at bootlin.com>, "richard" <richard at nod.at>, "Vignesh Raghavendra" <vigneshr at ti.com>
> CC: "chengzhihao1" <chengzhihao1 at huawei.com>, "linux-mtd" <linux-mtd at lists.infradead.org>, "linux-kernel"
> <linux-kernel at vger.kernel.org>, "Haoyu Lu" <hechushiguitu666 at gmail.com>
> Gesendet: Donnerstag, 7. Mai 2026 05:23:08
> Betreff: [PATCH 2/2] ubi: build: replace simple_strtoul with kstrtoul in bytes_str_to_int()
> From: Haoyu Lu <hechushiguitu666 at gmail.com>
>
> Replace the deprecated simple_strtoul() with kstrtoul() in the
>
> bytes_str_to_int() helper function. Since kstrtoul() rejects trailing
> non-numeric characters (such as the G/M/K suffixes), the numeric prefix
> is first extracted with strspn() and then parsed separately before
> handling the suffix.
>
> This provides proper error handling through the kstrto* family while
> preserving the existing suffix semantics for byte count parameters.
>
> Note: the original simple_strtoul() with base=0 accepted hexadecimal
> (0x prefix) and octal (0 prefix) formats, while kstrtoul() with base=10
> only supports decimal. This is not a practical concern since MTD byte
> count parameters are always specified as decimal values in boot
> parameters.
>
> Signed-off-by: Haoyu Lu <hechushiguitu666 at gmail.com>
> ---
> drivers/mtd/ubi/build.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
Your patch does not explain why this change is needed.
>From what I can tell, it just makes the existing code more complex and
fixes no real issues.
Is simple_strtoul() really deprecated? If so, where?
AFAICT, the documentation just mentions:
"This function has caveats. Please use kstrtol instead."
Do these these caveats hurt the current code?
Thanks,
//richard
More information about the linux-mtd
mailing list