From patchwork Sat Apr 1 13:55:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danil Antonov X-Patchwork-Id: 9657955 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 0AEC660349 for ; Sat, 1 Apr 2017 13:56:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 016A2285C2 for ; Sat, 1 Apr 2017 13:56:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA78628610; Sat, 1 Apr 2017 13:56:14 +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 3C104285F8 for ; Sat, 1 Apr 2017 13:56:14 +0000 (UTC) Received: from localhost ([::1]:51423 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJVl-000587-E2 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Apr 2017 09:56:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJVD-00057o-ON for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:55:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuJVC-0003fk-9M for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:55:39 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:36493) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuJVC-0003fb-3B for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:55:38 -0400 Received: by mail-oi0-x242.google.com with SMTP id b187so13211824oif.3 for ; Sat, 01 Apr 2017 06:55:37 -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=u4Y4JMltDMDHLvtJaXxEr7r+qGxDUoR4KWNB0iLJpe0=; b=pFEKuhRCGSgRR9hOA/6p+oqiJ/StzIhYrjFqjKyfd7iuA0BHpPWj2X1TTNJACi5kBt QrNQbtpAxow93QdyFRis0Aj+JBtMU+nBvsXohm6AxLdTbs2o/hCQbhNGhoKY1zuUlq5O OiHhsSx6h/YS64dmYTx1mNpmINoEiG+Tl1jz0ijIgG/3d3lAlpVcNoHXh/LHPO89J6n8 wr7bGYJ89HTCXafVwJmCqd1IBX/n7/PVH12UC1mR/UVCyt8sIYK0t1Aj3z7a2AidgHJJ tK/ZwuzeyMvMzPz462AaRz3siqmbegbxGcVAinI8bp8qkzmrhVtI6NaZM5wrGp1r7Qmb p3rg== 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=u4Y4JMltDMDHLvtJaXxEr7r+qGxDUoR4KWNB0iLJpe0=; b=Wq25C9yaQOIyIPaDnPbna2oioxl5CSh2b2bnD7PSpU5fRQl6RZfew4m77sXFanZO2o BA1mf0/UjlDBh9zXouKOlgy48Ms9Rd5YKa9iGOfXyrhSvncfZaV/chEKkMBQLc5yErNl VA3y8tzWcs/kP0hmgXl27oqhL3OFxHg+APAqJmYQS32daXhP49m4EVJjv74P2xwPbcrE iPwvw3ZNwKPAbMudb8Iju6tKnqGdnsATcdhwI8+zoD88jxlB86J+LZlDfiXJ8vXaOSKE dSAbsIawg3HUwQBv69QyKixkD/xYM1JBVwYN55li80sUqOKcDPurS09K+xLYDUse1XCP /ALQ== X-Gm-Message-State: AFeK/H2IgaQdBw77cCA5ZC/QwSjM5wsCtI6aN+CqIRiAG07NHL6d9iVWW8WlQ35gT+HnpSa3+ymPpUI18vfipw== X-Received: by 10.202.84.134 with SMTP id i128mr4884311oib.73.1491054937311; Sat, 01 Apr 2017 06:55:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.32.234 with HTTP; Sat, 1 Apr 2017 06:55:36 -0700 (PDT) From: Danil Antonov Date: Sat, 1 Apr 2017 16:55:36 +0300 Message-ID: To: qemu-devel@nongnu.org, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::242 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] [PATCH 20/43] i386: 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 a132733828991a950855138982d4a60858e92b04 Mon Sep 17 00:00:00 2001 From: Danil Antonov Date: Wed, 29 Mar 2017 12:32:16 +0300 Subject: [PATCH 20/43] i386: 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 --- hw/i386/acpi-build.c | 17 +++++++++++------ hw/i386/intel_iommu.c | 18 +++++++++--------- hw/i386/pc.c | 16 ++++++++++------ hw/i386/xen/xen_platform.c | 17 ++++++++++------- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 2073108..53b3aaf 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -75,12 +75,17 @@ #define ACPI_BUILD_TABLE_SIZE 0x20000 /* #define DEBUG_ACPI_BUILD */ -#ifdef DEBUG_ACPI_BUILD -#define ACPI_BUILD_DPRINTF(fmt, ...) \ - do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0) -#else -#define ACPI_BUILD_DPRINTF(fmt, ...) -#endif + +#ifndef DEBUG_ACPI_BUILD +#define DEBUG_ACPI_BUILD 0 +#endif + +#define ACPI_BUILD_DPRINTF(fmt, ...) \ + do { \ + if (DEBUG_ACPI_BUILD) { \ + fprintf(stderr, "ACPI_BUILD: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) /* Default IOAPIC ID */ #define ACPI_BUILD_IOAPIC_ID 0x0 diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 22d8226..562588b 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -37,8 +37,10 @@ #include "kvm_i386.h" #include "trace.h" -/*#define DEBUG_INTEL_IOMMU*/ -#ifdef DEBUG_INTEL_IOMMU +#ifndef DEBUG_INTEL_IOMMU +#define DEBUG_INTEL_IOMMU 0 +#endif + enum { DEBUG_GENERAL, DEBUG_CSR, DEBUG_INV, DEBUG_MMU, DEBUG_FLOG, DEBUG_CACHE, DEBUG_IR, @@ -46,14 +48,12 @@ enum { #define VTD_DBGBIT(x) (1 << DEBUG_##x) static int vtd_dbgflags = VTD_DBGBIT(GENERAL) | VTD_DBGBIT(CSR); -#define VTD_DPRINTF(what, fmt, ...) do { \ - if (vtd_dbgflags & VTD_DBGBIT(what)) { \ - fprintf(stderr, "(vtd)%s: " fmt "\n", __func__, \ - ## __VA_ARGS__); } \ +#define VTD_DPRINTF(what, fmt, ...) \ + do { \ + if (DEBUG_INTEL_IOMMU && vtd_dbgflags & VTD_DBGBIT(what)) { \ + fprintf(stderr, "(vtd)%s: " fmt "\n", __func__, ## __VA_ARGS__); \ + } \ } while (0) -#else -#define VTD_DPRINTF(what, fmt, ...) do {} while (0) -#endif static void vtd_define_quad(IntelIOMMUState *s, hwaddr addr, uint64_t val, uint64_t wmask, uint64_t w1cmask) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index d24388e..87b4312 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -73,12 +73,16 @@ /* debug PC/ISA interrupts */ //#define DEBUG_IRQ -#ifdef DEBUG_IRQ -#define DPRINTF(fmt, ...) \ - do { printf("CPUIRQ: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) -#endif +#ifndef DEBUG_IRQ +#define DEBUG_IRQ 0 +#endif + +#define DPRINTF(fmt, ...) \ + do { \ + if (DEBUG_IRQ) { \ + fprintf(stderr, "CPUIRQ: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) #define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0) #define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1) diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c index 6010f35..218bc2f 100644 --- a/hw/i386/xen/xen_platform.c +++ b/hw/i386/xen/xen_platform.c @@ -41,13 +41,16 @@ //#define DEBUG_PLATFORM -#ifdef DEBUG_PLATFORM -#define DPRINTF(fmt, ...) do { \ - fprintf(stderr, "xen_platform: " fmt, ## __VA_ARGS__); \ -} while (0) -#else -#define DPRINTF(fmt, ...) do { } while (0) -#endif +#ifndef DEBUG_PLATFORM +#define DEBUG_PLATFORM 0 +#endif + +#define DPRINTF(fmt, ...) \ + do { \ + if (DEBUG_PLATFORM) { \ + fprintf(stderr, "xen_platform: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) #define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */