From patchwork Sat Apr 1 13:51:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danil Antonov X-Patchwork-Id: 745983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vwKYZ2gltz9ryv for ; Sun, 2 Apr 2017 00:52:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FiUsk3LU"; dkim-atps=neutral Received: from localhost ([::1]:51410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJRv-0002zz-Vt for incoming@patchwork.ozlabs.org; Sat, 01 Apr 2017 09:52:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJRZ-0002yX-NP for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:51:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuJRX-00022J-Gl for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:51:53 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:33398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuJRX-00021p-9O for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:51:51 -0400 Received: by mail-oi0-x242.google.com with SMTP id f193so13214170oib.0 for ; Sat, 01 Apr 2017 06:51:51 -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=IThDWQP/yF/CxE4AIXUyn2L3we04p6v7ZDG6xXR6rno=; b=FiUsk3LUUbSn2tBrN8lVjIXE+bzguTAPSAdHEeafFzBbYl0JW9SfKPX4K6wAPXPdQ6 1UyOFckhumkrBgh6hwNCtJ3igjpJQvTBYmn2XQDUy6Vm3KBUbpQUG7HIvBHnV6eiLUL9 GSgtjQfVNYEHO6zE0HAUT6jl2d7hITZveqAMhy9ReAyUojVfMAftubesP6tJ+yVZwpnd rwk/f/A69ydcNvQN36iNGUTfeTG7RZ5uFxkt6hmWtW2YjniCFh6AQBpC9kQ/rxXa7zME ZHGkLdZs8LKKzoM/Vajvb8RsA7tUhcTqdp8PjMiHm3JBK2NLYr73q+TlrrYQ92NGKJ+C zx7g== 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=IThDWQP/yF/CxE4AIXUyn2L3we04p6v7ZDG6xXR6rno=; b=Uxt5W4KO4379iI1uxobInjc8WEnZVWGLRfr0Ymw1yUJY60k7IWal83JC4l8wyihVxG LSwj4orgtSEbUN1lI4DAJeuRgYo6hMgJ52ndJi2nciDeAsIycppnL/zl+HwoSZI6i6SU FuCxZx6mT3+H85czq0tSPEPcKn1pURP6PXYXZva/bW0JnJLkTtinn1CmT0raj6D7xQ2r D5sJeyW1mgBbW6fvNakuL8Dlm4RLfuZ5TxH+Gb0n0QhWCbsZBEDdIf6EJrvM8EpaD6+l cAr2SSvX8YNAmQqy0LhkpS9V6RUo1/edNpHROn3EJyolCerVEg71XsYYDdjFcivPPr1N /KoA== X-Gm-Message-State: AFeK/H1uwOhWCPWU9ZBg0F+VMquoOv4cDDDtYVQTMwoiJI5j4wVubXrXeuk7Si1CmPXNG9lPnnms9wV2ClE1jQ== X-Received: by 10.202.207.19 with SMTP id f19mr4763752oig.115.1491054710546; Sat, 01 Apr 2017 06:51:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.32.234 with HTTP; Sat, 1 Apr 2017 06:51:50 -0700 (PDT) From: Danil Antonov Date: Sat, 1 Apr 2017 16:51:50 +0300 Message-ID: To: qemu-devel@nongnu.org, peter.maydell@linaro.org, i.mitsyanko@gmail.com, agraf@suse.de, mst@redhat.com, pbonzini@redhat.com, gxt@mprc.pku.edu.cn 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 16/43] intc: 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From 3985e3226a996f019649b6b7a4d6e3e64f81ea8d Mon Sep 17 00:00:00 2001 From: Danil Antonov Date: Wed, 29 Mar 2017 12:30:06 +0300 Subject: [PATCH 16/43] intc: 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/intc/arm_gicv3_kvm.c | 16 +++++++++------- hw/intc/exynos4210_combiner.c | 18 +++++++++--------- hw/intc/heathrow_pic.c | 17 ++++++++++------- hw/intc/i8259.c | 16 +++++++++------- hw/intc/ioapic.c | 16 +++++++++------- hw/intc/puv3_intc.c | 4 ++-- 6 files changed, 48 insertions(+), 39 deletions(-) @@ -76,7 +76,7 @@ static void puv3_intc_write(void *opaque, hwaddr offset, { PUV3INTCState *s = opaque; - DPRINTF("offset 0x%x, value 0x%x\n", offset, value); + DPRINTF("offset 0x%lx, value 0x%lx\n", offset, value); switch (offset) { case 0x00: /* INTC_ICLR */ case 0x14: /* INTC_ICCR */ diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 81f0403..32e75c0 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -30,13 +30,15 @@ #include "vgic_common.h" #include "migration/migration.h" -#ifdef DEBUG_GICV3_KVM -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, "kvm_gicv3: " fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif +#ifndef DEBUG_GICV3_KVM +#define DEBUG_GICV3_KVM 0 +#endif + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_GICV3_KVM) { \ + fprintf(stderr, "kvm_gicv3: " fmt , ## __VA_ARGS__); \ + } \ +} while (0); #define TYPE_KVM_ARM_GICV3 "kvm-arm-gicv3" #define KVM_ARM_GICV3(obj) \ diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c index f19a706..512fda6 100644 --- a/hw/intc/exynos4210_combiner.c +++ b/hw/intc/exynos4210_combiner.c @@ -32,15 +32,15 @@ #include "hw/arm/exynos4210.h" -//#define DEBUG_COMBINER - -#ifdef DEBUG_COMBINER -#define DPRINTF(fmt, ...) \ - do { fprintf(stdout, "COMBINER: [%s:%d] " fmt, __func__ , __LINE__, \ - ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) do {} while (0) -#endif +#ifndef DEBUG_COMBINER +#define DEBUG_COMBINER 0 +#endif + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_COMBINER) { \ + fprintf(stdout, "COMBINER: [%s:%d] " fmt, __func__ , __LINE__, ## __VA_ARGS__); \ + } \ +} while (0); #define IIC_NGRP 64 /* Internal Interrupt Combiner Groups number */ diff --git a/hw/intc/heathrow_pic.c b/hw/intc/heathrow_pic.c index 171f5ed..b9593f7 100644 --- a/hw/intc/heathrow_pic.c +++ b/hw/intc/heathrow_pic.c @@ -29,12 +29,15 @@ /* debug PIC */ //#define DEBUG_PIC -#ifdef DEBUG_PIC -#define PIC_DPRINTF(fmt, ...) \ - do { printf("PIC: " fmt , ## __VA_ARGS__); } while (0) -#else -#define PIC_DPRINTF(fmt, ...) -#endif +#ifndef DEBUG_PIC +#define DEBUG_PIC 0 +#endif + +#define PIC_DPRINTF(fmt, ...) do { \ + if (DEBUG_PIC) { \ + fprintf(stderr, "PIC: " fmt , ## __VA_ARGS__); \ + } \ +} while (0); typedef struct HeathrowPIC { uint32_t events; @@ -72,7 +75,7 @@ static void pic_write(void *opaque, hwaddr addr, unsigned int n; n = ((addr & 0xfff) - 0x10) >> 4; - PIC_DPRINTF("writel: " TARGET_FMT_plx " %u: %08x\n", addr, n, value); + PIC_DPRINTF("writel: " TARGET_FMT_plx " %u: %08x\n", addr, n, (int) value); if (n >= 2) return; pic = &s->pics[n]; diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index fe9ecd6..43a20ce 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -32,14 +32,16 @@ #include "hw/intc/intc.h" /* debug PIC */ -//#define DEBUG_PIC -#ifdef DEBUG_PIC -#define DPRINTF(fmt, ...) \ - do { printf("pic: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) -#endif +#ifndef DEBUG_PIC +#define DEBUG_PIC 0 +#endif + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_PIC) { \ + fprintf(stderr, "pic: " fmt , ## __VA_ARGS__); \ + } \ +} while (0); //#define DEBUG_IRQ_LATENCY //#define DEBUG_IRQ_COUNT diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index 37c4386..684401a 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -35,14 +35,16 @@ #include "hw/i386/x86-iommu.h" #include "trace.h" -//#define DEBUG_IOAPIC -#ifdef DEBUG_IOAPIC -#define DPRINTF(fmt, ...) \ - do { printf("ioapic: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) -#endif +#ifndef DEBUG_IOAPIC +#define DEBUG_IOAPIC 0 +#endif + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_IOAPIC) { \ + fprintf(stderr, "ioapic: " fmt , ## __VA_ARGS__); \ + } \ +} while (0); #define APIC_DELIVERY_MODE_SHIFT 8 #define APIC_POLARITY_SHIFT 14 diff --git a/hw/intc/puv3_intc.c b/hw/intc/puv3_intc.c index ef8488a..80934f2 100644 --- a/hw/intc/puv3_intc.c +++ b/hw/intc/puv3_intc.c @@ -67,7 +67,7 @@ static uint64_t puv3_intc_read(void *opaque, hwaddr offset, default: DPRINTF("Bad offset %x\n", (int)offset); } - DPRINTF("offset 0x%x, value 0x%x\n", offset, ret); + DPRINTF("offset 0x%lx, value 0x%x\n", offset, ret); return ret; }