qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH v3 3/5] raw-posix: DPRINTF instead of DEBUG_BLOC


From: Eric Blake
Subject: Re: [Qemu-block] [PATCH v3 3/5] raw-posix: DPRINTF instead of DEBUG_BLOCK_PRINT
Date: Thu, 14 May 2015 08:05:19 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 05/14/2015 05:01 AM, Dimitris Aragiorgis wrote:
> Building the QEMU tools fails if we #define DEBUG_BLOCK inside
> block/raw-posix.c. Here instead of adding qemu-log.o in block-obj-y
> so that DEBUG_BLOCK_PRINT can be used, we substitute the latter with
> a simple DPRINTF() (that does not cause bit-rot).
> 
> Signed-off-by: Dimitris Aragiorgis <address@hidden>
> ---
>  block/raw-posix.c |   17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 

> +#define DPRINTF(fmt, ...) \
> +do { \
> +    if (DEBUG_BLOCK_PRINT) \
> +        printf(fmt, ## __VA_ARGS__); \
> +} while (0)

Still missing {} for the if statement.

[It might be nice to update scripts/checkpatch.pl to catch correct {}
inside macros, but that's a project for a different day.]

> @@ -1023,7 +1028,7 @@ static int xfs_write_zeroes(BDRVRawState *s, int64_t 
> offset, uint64_t bytes)
>      fl.l_len = bytes;
>  
>      if (xfsctl(NULL, s->fd, XFS_IOC_ZERO_RANGE, &fl) < 0) {
> -        DEBUG_BLOCK_PRINT("cannot write zero range (%s)\n", strerror(errno));
> +        DPRINTF("cannot write zero range (%s)\n", strerror(errno));
>          return -errno;
>      }

Pre-existing bug - strerror() and/or DPRINTF() can clobber errno, so
your return value may be destroyed.  You'll have to save errno into a
temporary variable prior to DPRINTF, and return that value.

>  
> @@ -1040,7 +1045,7 @@ static int xfs_discard(BDRVRawState *s, int64_t offset, 
> uint64_t bytes)
>      fl.l_len = bytes;
>  
>      if (xfsctl(NULL, s->fd, XFS_IOC_UNRESVSP64, &fl) < 0) {
> -        DEBUG_BLOCK_PRINT("cannot punch hole (%s)\n", strerror(errno));
> +        DPRINTF("cannot punch hole (%s)\n", strerror(errno));
>          return -errno;

Here too.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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