From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqqea-0005kO-9X for qemu-devel@nongnu.org; Mon, 26 Oct 2015 18:54:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqqeZ-0001YZ-5e for qemu-devel@nongnu.org; Mon, 26 Oct 2015 18:54:12 -0400 References: <1445897165-4842-1-git-send-email-jsnow@redhat.com> <1445897165-4842-4-git-send-email-jsnow@redhat.com> From: Eric Blake Message-ID: <562EAF0C.2020604@redhat.com> Date: Mon, 26 Oct 2015 16:54:04 -0600 MIME-Version: 1.0 In-Reply-To: <1445897165-4842-4-git-send-email-jsnow@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xadRe2Vgt0lir8QvpT7EIG2pN57Lvhm6x" Subject: Re: [Qemu-devel] [PATCH 3/3] qemu-io: Correct error messages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xadRe2Vgt0lir8QvpT7EIG2pN57Lvhm6x Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/26/2015 04:06 PM, John Snow wrote: > Signed-off-by: John Snow > --- > qemu-io-cmds.c | 58 +++++++++++++++++++++++++++++++++++++-------------= -------- > 1 file changed, 37 insertions(+), 21 deletions(-) >=20 > diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c > index e2477fc..92c6b87 100644 > --- a/qemu-io-cmds.c > +++ b/qemu-io-cmds.c > @@ -146,6 +146,21 @@ static int64_t cvtnum(const char *s) > return ret; > } > =20 > +static void print_cvtnum_err(int64_t rc, const char *arg) > +{ > + switch (rc) { > + case -EINVAL: > + printf("Parsing error: non-numeric argument," > + " or extraneous/unrecognized suffix -- %s\n", arg); s/ --/:/ > + break; > + case -ERANGE: > + printf("Parsing error: argument too large -- %s\n", arg); > + break; > + default: > + printf("Parsing error -- %s\n", arg); Twice more. With that change, Reviewed-by: Eric Blake > @@ -2199,10 +2214,11 @@ static int sigraise_f(BlockBackend *blk, int ar= gc, char **argv) > { > int64_t sig =3D cvtnum(argv[1]); > if (sig < 0) { > - printf("non-numeric signal number argument -- %s\n", argv[1]);= > + print_cvtnum_err(sig, argv[1]); > return 0; > - } else if (sig > INT_MAX) { > - printf("signal argument '%s' is too large\n", argv[1]); > + } else if (sig > NSIG) { > + printf("signal argument '%s' is too large to be a valid signal= \n", > + argv[1]); Should the comparison against NSIG rather than INT_MAX be squashed into patch 1? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --xadRe2Vgt0lir8QvpT7EIG2pN57Lvhm6x Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWLq8MAAoJEKeha0olJ0NqRygIAK9Eh1VkHo/VIsV0Xaj33m/F zS/ubOj3hGoyeI/SrWFsdpVDHr/Vi62Mn5clkTyI//SCRzxuwg5fB1oaJH1vBd/4 mkPrsttKZ6BxDMWgqoLiKAbFWa1LmVKAyZLjHh/OI5UwFdywB38JpQzieysQw2RR OnZlYH1X1f9iZXY/o/vSZxHusVUd/QA2JcQpJvtadPDW65wZAAiCuHPz30NvGMht 1o9NR2xsG42otTx8qTURot7uocgHEe8U27UYt4Rcd76s3otOpD0FOq6IF/KACToY HsB2kBqhGivSNzm+0w9M37UK+4Guny+XRrvfggg7+j/GJ98MzvLHvu7K2mvjipo= =7y2v -----END PGP SIGNATURE----- --xadRe2Vgt0lir8QvpT7EIG2pN57Lvhm6x--