From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=45983 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OapQi-0004bP-HS for qemu-devel@nongnu.org; Mon, 19 Jul 2010 08:26:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OapQh-0002DF-0O for qemu-devel@nongnu.org; Mon, 19 Jul 2010 08:26:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16931) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OapQg-0002D3-Oi for qemu-devel@nongnu.org; Mon, 19 Jul 2010 08:26:42 -0400 Message-ID: <4C44447D.9020405@redhat.com> Date: Mon, 19 Jul 2010 14:26:37 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1279482150-19385-1-git-send-email-weil@mail.berlios.de> In-Reply-To: <1279482150-19385-1-git-send-email-weil@mail.berlios.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] block: Use error codes from lower levels for error message List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: QEMU Developers Am 18.07.2010 21:42, schrieb Stefan Weil: > "No such file or directory" is a misleading error message > when a user tries to open a file with wrong permissions. > > Cc: Kevin Wolf > Signed-off-by: Stefan Weil > --- > block.c | 12 ++++++++---- > 1 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/block.c b/block.c > index f837876..2f80540 100644 > --- a/block.c > +++ b/block.c > @@ -330,16 +330,20 @@ BlockDriver *bdrv_find_protocol(const char *filename) > return NULL; > } > > -static BlockDriver *find_image_format(const char *filename) > +static BlockDriver *find_image_format(const char *filename, int *error) Wouldn't it be a more natural interface to return an 0/-errno int and pass the BlockDriver* by reference? I think we already have some function that work this way in the block code, but I can't remember any that get an int *error. > { > int ret, score, score_max; > BlockDriver *drv1, *drv; > uint8_t buf[2048]; > BlockDriverState *bs; > > + *error = -ENOENT; Why -ENOENT is the default would be clearer if you moved it down next to the drv = NULL before the loop that searches for the driver. Apart from these minor nitpicks it looks good. Kevin