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 <s...@weilnetz.de>
> ---
>  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