From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Blake Subject: Re: [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs Date: Tue, 13 May 2014 08:38:26 -0600 Message-ID: <53722E62.8000304@redhat.com> References: <1399964572-5376-1-git-send-email-marc.mari.barcelo@gmail.com> <1399964572-5376-2-git-send-email-marc.mari.barcelo@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2681534032201332200==" Cc: Stefan Hajnoczi , Peter Crosthwaite , X86 , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , X86 To: =?UTF-8?B?TWFyYyBNYXLDrQ==?= , qemu-devel@nongnu.org Return-path: In-Reply-To: <1399964572-5376-2-git-send-email-marc.mari.barcelo@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org List-Id: kvm.vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============2681534032201332200== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GiDa5mPcVT8tmtWsX4Qh6kS1thBxgdgEH" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GiDa5mPcVT8tmtWsX4Qh6kS1thBxgdgEH Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/13/2014 01:02 AM, Marc Mar=C3=AD wrote: > Modify debug macros to have the same format through the codebase and us= e regular > ifs instead of ifdef. >=20 > As the debug printf is always put in code, some casting had to be added= to avoid > warnings treated as errors at compile time. Umm, where in this patch did you add casting? Don't add bogus lines to the commit message (I was assuming that it might be a case where the code has type mismatches, and where something like PRId32 would be better than adding a cast - but couldn't find where that was. Maybe other patches in the series are affected?) >=20 > Signed-off-by: Marc Mar=C3=AD > --- > -#define DEBUG(fmt, ...) \ > - do { \ > - fprintf(stderr, "%s: " fmt, __func__ , __VA_ARGS__); \ > - } while (0) The old code was line-wrapped to fit in 80 columns... > +#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 1 > #else > -#define DEBUG(fmt, ...) > +#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 0 > #endif > =20 > +#define DEBUG(fmt, ...) QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, = "pci_assign", fmt, ## __VA_ARGS__) the new code should probably try to do similar: #define DEBUG(fmt, ...) \ QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, \ "pci_assign", fmt, ## __VA_ARGS__) Although __VA_ARGS__ is required by C99, the use of ##__VA_ARGS__ is a gcc extension; are you sure that all other supported compilers handle it? (I guess that's just clang) If you want something portable to C99, just use one fewer macro argument, so that you are guaranteed that __VA_ARGS__ will be non-empty (that is, subsume fmt into the ...): #define DEBUG(...) \ QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, \ "pci_assign", __VA_ARGS__) > =20 > +#define mb_debug(a...) QEMU_DPRINTF(DEBUG_MULTIBOOT_ENABLED, "i386 mul= tiboot", a) Use of 'a...' as a named var-arg parameter is a gcc extension, not portable to C99. Again, will this compile on non-gcc? Unnamed ... coupled with __VA_ARGS__ is the only fully portable way to do var-args. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --GiDa5mPcVT8tmtWsX4Qh6kS1thBxgdgEH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTci5iAAoJEKeha0olJ0NqOP8H/iz0BZ4gk+IxK8p/VKUseV0m kyZ/CsxfNTrzIv3qZlubxgcACF6k37vevwtzsxvtaG9h3DnKFlq9JxItmwDrZo5e Il3jpup7o4Lsfv4jjKADx3Au9ftLSpRpMYOS06MloVHvIHDuYH/mlNd5EKUI2nDE SZvI5OMr7FUDWIjCD6YGr2asSD4ekTRV/HLLDptcMZdiZlIGZLSS9uGEbPhDFvgf Gz+c76MhNZx2KHefx5+h3oKElE5j2/24JJvFNyQib6JnyUN4Bz6XR+hPdX+MztP+ fkYCSj+2kvLk1vt9KyOa7vymmaklPBFfKMTkCV8h/6ZbdbfUHZy6lT3XQzHQaEg= =tyeV -----END PGP SIGNATURE----- --GiDa5mPcVT8tmtWsX4Qh6kS1thBxgdgEH-- --===============2681534032201332200== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============2681534032201332200==--