From: Eric Sandeen <sandeen@sandeen.net>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs-oss <xfs@oss.sgi.com>
Subject: [PATCH V2] libxcmd: return error from cvtnum() on overflow
Date: Mon, 28 Feb 2011 15:26:58 -0600 [thread overview]
Message-ID: <4D6C1322.10102@sandeen.net> (raw)
In-Reply-To: <4D6C075F.1010509@redhat.com>
Test 071 was failing in weird ways, partly because it was trying
to pass in offsets larger than strtoll() could accept, which then
silently returned LLONG_MAX instead. For DIO tests, this was
unaligned, so we got unexpected (to me, anyay) alignment errors.
At least printing out the perror() makes this more obvious,
but unfortunately we then get the somewhat odd output:
# xfs_io -f -d -c "pwrite 9223373136366403584 4096" /mnt/test/grrr
cvtnum: Numerical result out of range
non-numeric offset argument -- 9223373136366403584
Test 071 still fails, but at least it's a bit more obvious as to why.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
V2: zero errno first so we don't pick up a stale errno.
Note:
... should I change all callsites from "non-numeric" to "invalid" perhaps?
diff --git a/libxcmd/input.c b/libxcmd/input.c
index d7f29c1..c2bc4a0 100644
--- a/libxcmd/input.c
+++ b/libxcmd/input.c
@@ -152,7 +152,12 @@ cvtnum(
char *sp;
int c;
+ errno = 0;
i = strtoll(s, &sp, 0);
+ if (errno == ERANGE) {
+ perror("cvtnum");
+ return -1LL;
+ }
if (i == 0 && sp == s)
return -1LL;
if (*sp == '\0')
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2011-02-28 21:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-28 20:36 [PATCH] libxcmd: return error from cvtnum() on overflow Eric Sandeen
2011-02-28 21:26 ` Eric Sandeen [this message]
2011-03-01 21:00 ` [PATCH V2] " Alex Elder
2011-03-01 21:27 ` Eric Sandeen
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=4D6C1322.10102@sandeen.net \
--to=sandeen@sandeen.net \
--cc=sandeen@redhat.com \
--cc=xfs@oss.sgi.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