From: "Darrick J. Wong" <djwong@kernel.org>
To: Yang Xu <xuyang2018.jy@fujitsu.com>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH] src/ext4_resize.c: set errno to 0 before the strtoull call
Date: Mon, 17 Jan 2022 09:07:58 -0800 [thread overview]
Message-ID: <20220117170758.GA13514@magnolia> (raw)
In-Reply-To: <1642405014-3287-1-git-send-email-xuyang2018.jy@fujitsu.com>
On Mon, Jan 17, 2022 at 03:36:54PM +0800, Yang Xu wrote:
> On my test machine, ext4/033 fails even use the non-overflow size.
> It reports invalid new size when using strtoull because errno is 1.
>
> As man-pages said "Since strtoul() can legitimately return 0 or ULONG_MAX
> (ULLONG_MAX for strtoull()) on both success and failure, the calling program
> should set errno to 0 before the call, and then determine if an error occurred
> by checking whether errno has a nonzero value after the call".
>
> So add a step to set errno to 0 before strtoull call.
>
> Fixes: 92b9c0dedace ("ext4/033: test EXT4_IOC_RESIZE_FS by calling the ioctl directly")
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Looks good,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> src/ext4_resize.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/src/ext4_resize.c b/src/ext4_resize.c
> index 1ac51e6f..39e16529 100644
> --- a/src/ext4_resize.c
> +++ b/src/ext4_resize.c
> @@ -35,6 +35,7 @@ int main(int argc, char **argv)
> return 1;
> }
>
> + errno = 0;
> new_size = strtoull(argv[2], &tmp, 10);
> if ((errno) || (*tmp != '\0')) {
> fprintf(stderr, "%s: invalid new size\n", argv[0]);
> --
> 2.23.0
>
next prev parent reply other threads:[~2022-01-17 17:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 7:36 [PATCH] src/ext4_resize.c: set errno to 0 before the strtoull call Yang Xu
2022-01-17 17:07 ` Darrick J. Wong [this message]
2022-01-18 2:32 ` Theodore Ts'o
2022-01-18 2:43 ` xuyang2018.jy
2022-01-18 3:56 ` Theodore Ts'o
2022-01-18 5:27 ` xuyang2018.jy
2022-01-18 11:23 ` Adhemerval Zanella
2022-01-18 11:26 ` Florian Weimer
2022-01-18 11:49 ` Adhemerval Zanella
2022-01-18 12:00 ` Florian Weimer
2022-01-18 12:04 ` Andreas Schwab
2022-01-18 12:26 ` Adhemerval Zanella
2022-01-18 14:02 ` Florian Weimer
[not found] ` <61E7AC82.8080801@fujitsu.com>
2022-01-19 7:19 ` xuyang2018.jy
2022-01-19 13:57 ` Cristian Rodríguez
2022-01-19 14:07 ` Cristian Rodríguez
2022-01-19 14:50 ` Andrew G. Morgan
2022-01-19 20:13 ` Theodore Ts'o
2022-01-18 14:22 ` Andreas Schwab
2022-01-18 14:29 ` H.J. Lu
2022-01-19 2:07 ` xuyang2018.jy
2022-01-19 8:23 ` Andreas Schwab
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=20220117170758.GA13514@magnolia \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=xuyang2018.jy@fujitsu.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;
as well as URLs for NNTP newsgroup(s).