From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4WIR-0001H3-43 for qemu-devel@nongnu.org; Thu, 03 Dec 2015 10:59:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4WIM-0001Ce-5A for qemu-devel@nongnu.org; Thu, 03 Dec 2015 10:59:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4WIL-0001CX-Ti for qemu-devel@nongnu.org; Thu, 03 Dec 2015 10:59:46 -0500 References: <1449119286-57280-1-git-send-email-yanmiaobest@gmail.com> From: Eric Blake Message-ID: <566066EB.50101@redhat.com> Date: Thu, 3 Dec 2015 08:59:39 -0700 MIME-Version: 1.0 In-Reply-To: <1449119286-57280-1-git-send-email-yanmiaobest@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1oqAnBNws1li88kDrxCsxuLhtpAoCuATT" Subject: Re: [Qemu-devel] [PATCH] net/vmxnet3.c: fix a build error when enabling debug output List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Miao Yan , jasowang@redhat.com, dmitry@daynix.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1oqAnBNws1li88kDrxCsxuLhtpAoCuATT Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/02/2015 10:08 PM, Miao Yan wrote: > Macro MAC_FMT and MAC_ARG are not defined, but used in vmxnet3_net_init= (). > This will cause build error when debug level is raised in > vmxnet3_debug.h (enable all VMXNET3_DEBUG_xxx). >=20 > Use VMXNET_MF and VXMNET_MA instead. >=20 > Signed-off-by: Miao Yan > --- > hw/net/vmxnet3.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c > index 5e3a233..ea3d9b7 100644 > --- a/hw/net/vmxnet3.c > +++ b/hw/net/vmxnet3.c > @@ -2044,7 +2044,7 @@ static void vmxnet3_net_init(VMXNET3State *s) > =20 > s->link_status_and_speed =3D VMXNET3_LINK_SPEED | VMXNET3_LINK_STA= TUS_UP; > =20 > - VMW_CFPRN("Permanent MAC: " MAC_FMT, MAC_ARG(s->perm_mac.a)); > + VMW_CFPRN("Permanent MAC: " VMXNET_MF, VMXNET_MA(s->perm_mac.a)); This is a classic example of why dead code debug statements are evil. You should consider also providing a patch to hw/net/vmxnet_debug.h to fix ALL of the broken debug macros in that file to instead use a sane pattern, so that the format string is ALWAYS compiled and just optimized out when debugging is disabled. Here's a conversion of one of the macros for an example of what to do: Instead of: > #ifdef VMXNET_DEBUG_CONFIG > #define VMW_CFPRN(fmt, ...) = \ > do { = \ > printf("[%s][CF][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,= \ > ## __VA_ARGS__); = \ > } while (0) > #else > #define VMW_CFPRN(fmt, ...) do {} while (0) > #endif you should do: #ifdef VMXNET_DEBUG_CONFIG # define VMXNET_DEBUG_CONFIG_FLAG 1 #else # define VMXNET_DEBUG_CONFIG_FLAG 0 #endif #define VMW_CFPRN(fmt, ...) \ do { \ if (VMXNET_DEBUG_CONFIG_FLAG) { \ printf("[%s][CF][%s]: " fmt "\n", VMXNET_DEVICE_NAME, \ __func__, ## __VA_ARGS__); \ } \ } while (0); With that pattern, VMW_CFPRN() will now always check that its arguments can compile, even though it has no impact to the code size when VMXNET_DEBUG_CONFIG is not defined. Note that once you repair all of the broken macros (I count 8 in that file), you may have some fallout of other broken dead code that needs to be fixed. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --1oqAnBNws1li88kDrxCsxuLhtpAoCuATT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWYGbsAAoJEKeha0olJ0NqFF8H/iZkcTvcCdl84ttBwU0bA/WD 9/hFs6Vnaz/eZR/BlMLDA1r70wDDmz3290Qs+9fKhbenDsEDysCwCxMld8QFCJo8 D+YxYtosPaqmqnNwImKOQxlMk1W4tzp9F5VIbdyKsngSE64qoeu49uHe3gceXZ65 rV0bdOt1o/VSQj/x3CP0b8mM2DYZUJmRYuBXUeTfS2vcOwi5LWohoFAkruPMQDat Kk6letwAQ7uKPJBgx/Pn3Kk+pMgww1Qg9Gr36ECdx47erVYkbPR431VZLzTRGE/B NgZ8+Nn1rW/45kW0rTuEiXCG9Qk5qd5wMDu4H6DbqqRqv7FzPcNUrzT/NY8Ksn8= =o7M3 -----END PGP SIGNATURE----- --1oqAnBNws1li88kDrxCsxuLhtpAoCuATT--