From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMNBm-0004UY-It for qemu-devel@nongnu.org; Tue, 26 Aug 2014 16:18:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMNBg-00074M-D8 for qemu-devel@nongnu.org; Tue, 26 Aug 2014 16:17:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMNBg-000744-5M for qemu-devel@nongnu.org; Tue, 26 Aug 2014 16:17:52 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7QKHoxH003039 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 26 Aug 2014 16:17:50 -0400 Message-ID: <53FCEB6A.9000401@redhat.com> Date: Tue, 26 Aug 2014 16:17:46 -0400 From: John Snow MIME-Version: 1.0 References: <1409077076-29855-1-git-send-email-stefanha@redhat.com> <1409077076-29855-2-git-send-email-stefanha@redhat.com> <53FCE07E.8020308@redhat.com> In-Reply-To: <53FCE07E.8020308@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/3] qemu-img: fix img_commit() error return value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Kevin Wolf , Jeff Cody , Markus Armbruster On 08/26/2014 03:31 PM, Eric Blake wrote: > On 08/26/2014 12:17 PM, Stefan Hajnoczi wrote: >> The img_commit() return value is a process exit code. Use 1 for failu= re >> instead of -1. The other failure paths in this function already use 1. >> >> Signed-off-by: Stefan Hajnoczi >> --- >> qemu-img.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/qemu-img.c b/qemu-img.c >> index c843420..dc3adb5 100644 >> --- a/qemu-img.c >> +++ b/qemu-img.c >> @@ -771,7 +771,7 @@ static int img_commit(int argc, char **argv) >> ret =3D bdrv_parse_cache_flags(cache, &flags); >> if (ret < 0) { >> error_report("Invalid cache option: %s", cache); >> - return -1; >> + return 1; > > Nothing against this patch (you're consistent with the surrounding code= , > and most of qemu for that matter), but it highlights why I'm a fan of > 'return EXIT_FAILURE' instead of 'return 1' in functions that return an > exit status, because that makes it a lot more obvious _why_ I'm > returning a non-negative number to represent failure. > "Hey, good point." jsnow@local ~/s/qemu> git grep 'return 1;' | wc -l 842 "oh." This patch is probably fine -- is there some larger scheme we want to=20 cook up within the style guide for advocating things like return code=20 and error reporting standards? It seems to me like the preferred style for errors and returns has=20 changed several times and there's not a good concrete rule (written) at=20 the moment. It might be worth touching the CODING_GUIDE and/or HACKING=20 files with recommendations, if we can agree on some consistent set of=20 rules, like getting rid of error_set(...) and not using positive,=20 un-named integers to represent errors. --=20 =E2=80=94js