qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/4] block: Add special error code for wrong for


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH 1/4] block: Add special error code for wrong format
Date: Thu, 17 Jan 2013 13:01:49 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

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 <address@hidden>
> ---
>  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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]