From patchwork Sat Apr 1 14:00:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danil Antonov X-Patchwork-Id: 9658009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C630F60349 for ; Sat, 1 Apr 2017 14:02:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCB7B2860C for ; Sat, 1 Apr 2017 14:02:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE81428613; Sat, 1 Apr 2017 14:02:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 648A72860C for ; Sat, 1 Apr 2017 14:02:31 +0000 (UTC) Received: from localhost ([::1]:51467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJbq-0000u2-EZ for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Apr 2017 10:02:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJa9-0000Is-SQ for qemu-devel@nongnu.org; Sat, 01 Apr 2017 10:00:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuJa8-000631-QV for qemu-devel@nongnu.org; Sat, 01 Apr 2017 10:00:45 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:35199) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuJa8-00062c-KM for qemu-devel@nongnu.org; Sat, 01 Apr 2017 10:00:44 -0400 Received: by mail-oi0-x241.google.com with SMTP id d2so5883781oig.2 for ; Sat, 01 Apr 2017 07:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=pOndzvymRwB6kCacARg3PMSOHRPYYJoL4M09dv3pezI=; b=jIKNiTVCSWzh3Kr/Jip5lPEpCDLqCSgGapDrcKpF9YI9bP/Goe8N6i3Um1IJEmjP0p wphlL3xF4CoxYPcjEYXyhaGJPVivICt0xvpysEqbYIwVIjBxSRA9P59zvo9QQn2Oz6ii 2GTLh9VOLVQEainLCb7qhF4SIia54/TPn76G+xCYYiuOytclzkLA7EIUZxp9vxbsyyJR /wN07bI7acuSJL7JKtkzjtYS4fl7ZUY+6VjPdV8kS8HY09jKGruuaHt5B9qh0KPCP4vm OwJ+MvjPn7O8n7/JGX40eRXGqxDLE01ywYgU+lImbJEEd74ypeBS+vjQzeen3Vc3/QRt c6ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=pOndzvymRwB6kCacARg3PMSOHRPYYJoL4M09dv3pezI=; b=OsT/acyw87wZvdaAWcbyz/WQwz8QHI4qun2R1uaKWqav8mzoK+MzC9xXRbN6ie6B07 GYMAJBCkQbyADgi/jr8RpwIIQ+n1I+nHC4529KLvRhVjZXxfgEBJQg/oWBZAOMJaW+rj MpTH/74sz7BVOAZw/VDEGrisk1GBQtjAX8duqD0h1mfibO+b3O1yVrAv5RrmCy6cbLls 1W2yySMZkNHUkRllJEtGb45Hw1WBT9NnBIrWuTMxgsP3ubfh3P00yNfdDDzTnx8SPjdG FWasmawb947fLXRvid9WsV2I5E5KcdXCNxpmGBywoAD8A++y/u7EgZvBsubACbF3aD2l sDHA== X-Gm-Message-State: AFeK/H3ximv55pYyBj6GGujxsO2SpIM6vgzWlMaC0vc7B2x0RyAPCog4qNpVWhYI+2RuNqDEKPKMGnNZy4x2IQ== X-Received: by 10.202.7.193 with SMTP id 184mr4912524oih.132.1491055243837; Sat, 01 Apr 2017 07:00:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.32.234 with HTTP; Sat, 1 Apr 2017 07:00:43 -0700 (PDT) From: Danil Antonov Date: Sat, 1 Apr 2017 17:00:43 +0300 Message-ID: To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::241 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] [PATCH 27/43] vfio: made printf always compile in debug output X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From c986c5a54a394feadfd885d41848f28d11fec40f Mon Sep 17 00:00:00 2001 From: Danil Antonov Date: Wed, 29 Mar 2017 12:37:26 +0300 Subject: [PATCH 27/43] vfio: made printf always compile in debug output Wrapped printf calls inside debug macros (DPRINTF) in `if` statement. This will ensure that printf function will always compile even if debug output is turned off and, in turn, will prevent bitrot of the format strings. Signed-off-by: Danil Antonov --- include/hw/vfio/vfio-common.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index c582de1..3d3cc89 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -33,14 +33,15 @@ #define ERR_PREFIX "vfio error: %s: " #define WARN_PREFIX "vfio warning: %s: " -/*#define DEBUG_VFIO*/ -#ifdef DEBUG_VFIO -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, "vfio: " fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif +#ifndef DEBUG_VFIO +#define DEBUG_VFIO 0 +#endif + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_VFIO) { \ + fprintf(stderr, "vfio: " fmt, ## __VA_ARGS__); \ + } \ +} while (0); enum { VFIO_DEVICE_TYPE_PCI = 0,