From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwGOV-00074U-W7 for qemu-devel@nongnu.org; Fri, 18 Jan 2013 13:10:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TwGOJ-0006in-NH for qemu-devel@nongnu.org; Fri, 18 Jan 2013 13:10:21 -0500 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:50861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwGOJ-0006i3-H6 for qemu-devel@nongnu.org; Fri, 18 Jan 2013 13:10:11 -0500 Message-ID: <50F98FFE.5090502@weilnetz.de> Date: Fri, 18 Jan 2013 19:10:06 +0100 From: Stefan Weil MIME-Version: 1.0 References: <1358455528-29813-1-git-send-email-sw@weilnetz.de> <1358455528-29813-3-git-send-email-sw@weilnetz.de> <871udizxb5.fsf@blackfin.pond.sub.org> In-Reply-To: <871udizxb5.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/5] block: Use error code EMEDIUMTYPE for wrong format in some block drivers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi Am 18.01.2013 09:53, schrieb Markus Armbruster: > Stefan Weil writes: >> This improves error reports for bochs, cow, qcow, qcow2, qed and vmdk >> when a file with the wrong format is selected. >> >> Signed-off-by: Stefan Weil >> --- >> block/bochs.c | 2 +- >> block/cow.c | 2 +- >> block/qcow.c | 2 +- >> block/qcow2.c | 2 +- >> block/qed.c | 2 +- >> block/vmdk.c | 4 ++-- >> 6 files changed, 7 insertions(+), 7 deletions(-) >> >> diff --git a/block/bochs.c b/block/bochs.c >> index 1b1d9cd..3737583 100644 >> --- a/block/bochs.c >> +++ b/block/bochs.c >> @@ -126,7 +126,7 @@ static int bochs_open(BlockDriverState *bs, int flags) >> strcmp(bochs.subtype, GROWING_TYPE) || >> ((le32_to_cpu(bochs.version) != HEADER_VERSION) && >> (le32_to_cpu(bochs.version) != HEADER_V1))) { >> - goto fail; >> + return -EMEDIUMTYPE; >> } >> >> if (le32_to_cpu(bochs.version) == HEADER_V1) { > You make the function return either 0, -1 or -EMEDIUMTYPE. Please make > it return either 0 or a negative errno code, like this (untested): Hi Markus, returning 0, -1 is like before, only returning -EMEDIUMTYPE is new. You are right, a return value of -1 should be replaced by a negative error value. I fixed this for block/vdi.c in a separate patch as suggested by Kevin, see http://patchwork.ozlabs.org/patch/213375/. The same kind of improvement should be done for other block drivers which currently use -1, but that can be done after my patch series was applied. The primary purpose of my patch series was fixing open bugreports. For vdi I did more because I feel responsible for that part of the code. Regards, StefanW.