From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvoAT-00016r-N6 for qemu-devel@nongnu.org; Thu, 17 Jan 2013 07:02:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvoAN-0003jM-6g for qemu-devel@nongnu.org; Thu, 17 Jan 2013 07:02:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvoAM-0003j1-Vn for qemu-devel@nongnu.org; Thu, 17 Jan 2013 07:01:55 -0500 Message-ID: <50F7E82D.7080404@redhat.com> Date: Thu, 17 Jan 2013 13:01:49 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1355580573-19323-1-git-send-email-sw@weilnetz.de> <1355580573-19323-2-git-send-email-sw@weilnetz.de> In-Reply-To: <1355580573-19323-2-git-send-email-sw@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/4] block: Add special error code for wrong format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: qemu-devel@nongnu.org, Stefan Hajnoczi Am 15.12.2012 15:09, schrieb Stefan Weil: > The block drivers normally return -errno for typical errors. > There is no appropriate error code for "wrong format", so > use a special error code which does not conflict with system > error codes. > > Signed-off-by: Stefan Weil > --- > block.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/block.h b/block.h > index 893448a..829e18b 100644 > --- a/block.h > +++ b/block.h > @@ -90,6 +90,13 @@ typedef struct BlockDevOps { > #define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS) > #define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1) > > +/* The block drivers normally return -errno for typical errors. > + * There is no appropriate error code for "wrong format", so > + * use a special error code which does not conflict with system > + * error codes. > + */ > +#define BDRV_WRONG_FORMAT INT_MIN I think it would be better to use the E* format and a positive number so that it's obvious that it's meant to be used in -errno returns. Also, I would consider moving it to qemu-common.h where other errno values are defined that may be missing on some systems, so that everything stays in one place and we won't define overlapping codes: #if !defined(ENOTSUP) #define ENOTSUP 4096 #endif #if !defined(ECANCELED) #define ECANCELED 4097 #endif This sounds like a good addition in the same place would be: #define EBDRV_WRONG_FORMAT 4098 Or just use EINVAL or ENOTTY like Stefan suggested. Kevin