Received: from eggs.gnu.org ([208.118.235.92]:55062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjU59-0002ks-1u for qemu-devel@nongnu.org; Fri, 14 Dec 2012 07:09:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjU54-0007sM-6l for qemu-devel@nongnu.org; Fri, 14 Dec 2012 07:09:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54093) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjU53-0007sG-VF for qemu-devel@nongnu.org; Fri, 14 Dec 2012 07:09:30 -0500 From: Markus Armbruster References: <1355458116-5692-1-git-send-email-lig.fnst@cn.fujitsu.com> Date: Fri, 14 Dec 2012 13:09:17 +0100 In-Reply-To: <1355458116-5692-1-git-send-email-lig.fnst@cn.fujitsu.com> (liguang's message of "Fri, 14 Dec 2012 12:08:35 +0800") Message-ID: <87y5h0bzte.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 1/2] cutils:change strtosz_suffix_unit function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: liguang Cc: kwolf@redhat.com, imammedo@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com liguang writes: > if value to be translated is larger than INT64_MAX, > this function will not be convenient for caller to > be aware of it, so change a little for this. > > Signed-off-by: liguang > --- > cutils.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/cutils.c b/cutils.c > index 4f0692f..da05c9e 100644 > --- a/cutils.c > +++ b/cutils.c /* * Convert string to bytes, allowing either B/b for bytes, K/k for KB, * M/m for MB, G/g for GB or T/t for TB. End pointer will be returned * in *end, if not NULL. Return -1 on error. */ > @@ -219,7 +219,7 @@ static int64_t suffix_mul(char suffix, int64_t unit) > int64_t strtosz_suffix_unit(const char *nptr, char **end, > const char default_suffix, int64_t unit) > { > - int64_t retval = -1; > + int64_t retval = EINVAL; > char *endptr; > unsigned char c; > int mul_required = 0; > @@ -246,6 +246,7 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end, > goto fail; > } > if ((val * mul >= INT64_MAX) || val < 0) { > + retval = ERANGE; > goto fail; > } > retval = val * mul; Your error codes aren't negative, and you failed to update the function comment!