mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Su Hui <suhui@nfschina.com>
To: David Howells <dhowells@redhat.com>
Cc: marc.dionne@auristor.com, linux-afs@lists.infradead.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] afs: Replace simple_strtoul with kstrtoul in afs_parse_address
Date: Fri, 30 May 2025 18:42:40 +0800	[thread overview]
Message-ID: <49b686e0-6fa3-4e60-a007-51c1fa675f2d@nfschina.com> (raw)
In-Reply-To: <685978.1748597572@warthog.procyon.org.uk>


On 5/30/25 5:32 PM, David Howells wrote:
> Su Hui <suhui@nfschina.com> wrote:
>
>> kstrtoul() is better because simple_strtoul() ignores overflow which
>> may lead to unexpected results.
> Overflow in what sense?  Are we talking about a mathematical overflow or not
> checking the text beyond the end of the number?

IMO, It's meaning that  the number represented by the string exceeds the 
type range. Like this code:

const char str[] = "0xffffffffffffffff0000000000000001";
unsigned long res;
res = simple_strtoul(str, &p, 0); //overflow happends and  res = 0x1
err = kstrtoul(str, 0, &res); // overflow happends and res = 0x1,  err = 
-ERANGE

Su Hui


      reply	other threads:[~2025-05-30 10:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-27  8:49 Su Hui
2025-05-29 23:35 ` Jeffrey E Altman
2025-05-30 10:29   ` Su Hui
2025-05-30 12:43     ` Jeffrey E Altman
2025-05-30 23:17       ` Su Hui
2025-05-30  9:32 ` David Howells
2025-05-30 10:42   ` Su Hui [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=49b686e0-6fa3-4e60-a007-51c1fa675f2d@nfschina.com \
    --to=suhui@nfschina.com \
    --cc=dhowells@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.dionne@auristor.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

all inboxes | Powered by JetHome®