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 <dim...@arrikto.com> > --- > 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
signature.asc
Description: OpenPGP digital signature