From patchwork Sat Apr 1 14:06:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danil Antonov X-Patchwork-Id: 9658029 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 94FAE60349 for ; Sat, 1 Apr 2017 14:07:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D47C22B27 for ; Sat, 1 Apr 2017 14:07:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 810D827F54; Sat, 1 Apr 2017 14:07:22 +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 239CC22B27 for ; Sat, 1 Apr 2017 14:07:22 +0000 (UTC) Received: from localhost ([::1]:51553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJgX-0004s0-66 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Apr 2017 10:07:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJfj-0004qA-Hj for qemu-devel@nongnu.org; Sat, 01 Apr 2017 10:06:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuJfi-0001Jg-3n for qemu-devel@nongnu.org; Sat, 01 Apr 2017 10:06:31 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:36290) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuJfh-0001JD-TX for qemu-devel@nongnu.org; Sat, 01 Apr 2017 10:06:30 -0400 Received: by mail-oi0-x243.google.com with SMTP id b187so13240185oif.3 for ; Sat, 01 Apr 2017 07:06:29 -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=0JMyO+Ox/KzCOsJf2IoKZhfRNOpChfvcYOvkKS2tM5s=; b=NyGnmYSr2/VkPP2RQ4gxQs9kbIPLACLOD9q9Ty+L7CnnB/7L17ZNRRqeTvMC1Hieq4 pzf85YtMK1ZzL4E3L9Koq0YfQmpMMKQiQOTelVlrd6SdcFdkFlUw3m45HmHGMLUoxvTm R6C0WW4+IHTq8iAbCbq2uzd6E099MObw86M6uQMDFMT1g6oR438JKzjvz6Zan7c0nXi5 kUqtFVoUOUJkIcET8prxSiB7Lzoa4Si84SVh5AjHBBwNxP+m/F4ITZvBNo+uBKFg7Y0u jFgwLGFKA0J0Qfi8ZMoyHJHoUH5X6WV5fTp0h7a3kI1LoC2wUJpJSfjfYl7S1fJPZjKT UMtQ== 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=0JMyO+Ox/KzCOsJf2IoKZhfRNOpChfvcYOvkKS2tM5s=; b=Ok9NMHKR135r5fKSHfkmdhhDbdw+PJ65n40OU15qrqQB/DNMhkfXl0/c6zCYyYposi Uv7tB0HZ5zNpQWx6KsFaFpRhdqZLH8Uc1ZhyA11xiz/dKKlgGKjV3UJzAt24B4Y0cJdn aJoNhW4mIIFXpttBwTA8ypN3m5fpr3AiuDWH9qC6Bpv/WMW5nYEZ2NP10qnAKO0Wmear g8GTBnqUFnihMd0D5cpHCzbEeZYyd3xKmTfmDKneAuylQLpFXrAvPBKD1JHe4/w/t4mM 2/HZDPBd2In3KzV9XL7vxM/7XmkG+7Ng/Hvgs3k+I197X6gbu+wUTJmo66iB8IQxguua vZJA== X-Gm-Message-State: AFeK/H3Dzj2jFuu40XZKaTo75HW+NLq7act0+48HqFuuQboXwnbPsJ+33M6oVkjq8UiXf2aYF5rcxztp1xznBQ== X-Received: by 10.157.32.129 with SMTP id x1mr4466780ota.185.1491055589042; Sat, 01 Apr 2017 07:06:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.32.234 with HTTP; Sat, 1 Apr 2017 07:06:28 -0700 (PDT) From: Danil Antonov Date: Sat, 1 Apr 2017 17:06:28 +0300 Message-ID: To: qemu-devel@nongnu.org, peter.maydell@linaro.org, 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::243 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] [PATCH 36/43] gpi: 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 adb8f4b937b80629881ea23310a8d75ac4671b2a Mon Sep 17 00:00:00 2001 From: Danil Antonov Date: Wed, 29 Mar 2017 12:41:38 +0300 Subject: [PATCH 36/43] gpi: 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/gpio/pl061.c | 28 ++++++++++++++++------------ hw/gpio/puv3_gpio.c | 8 ++++---- 2 files changed, 20 insertions(+), 16 deletions(-) } @@ -58,7 +58,7 @@ static void puv3_gpio_write(void *opaque, hwaddr offset, { PUV3GPIOState *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 0x04: s->reg_GPDR = value; @@ -85,7 +85,7 @@ static void puv3_gpio_write(void *opaque, hwaddr offset, s->reg_GPIR = value; break; default: - DPRINTF("Bad offset 0x%x\n", offset); + DPRINTF("Bad offset 0x%lx\n", offset); } } diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c index 4ae2aa1..af0de24 100644 --- a/hw/gpio/pl061.c +++ b/hw/gpio/pl061.c @@ -12,18 +12,22 @@ #include "hw/sysbus.h" #include "qemu/log.h" -//#define DEBUG_PL061 1 - -#ifdef DEBUG_PL061 -#define DPRINTF(fmt, ...) \ -do { printf("pl061: " fmt , ## __VA_ARGS__); } while (0) -#define BADF(fmt, ...) \ -do { fprintf(stderr, "pl061: error: " fmt , ## __VA_ARGS__); exit(1);} while (0) -#else -#define DPRINTF(fmt, ...) do {} while(0) -#define BADF(fmt, ...) \ -do { fprintf(stderr, "pl061: error: " fmt , ## __VA_ARGS__);} while (0) -#endif +#ifndef DEBUG_PL061 +#define DEBUG_PL061 0 +#endif + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_PL061) { \ + fprintf(stderr, "pl061: " fmt , ## __VA_ARGS__); \ + } \ +} while (0); + +#define BADF(fmt, ...) do { \ + fprintf(stderr, "pl061: error: " fmt , ## __VA_ARGS__); \ + if (DEBUG_PL061) { \ + exit(1); \ + } \ +} while (0); static const uint8_t pl061_id[12] = { 0x00, 0x00, 0x00, 0x00, 0x61, 0x10, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; diff --git a/hw/gpio/puv3_gpio.c b/hw/gpio/puv3_gpio.c index 445afcc..48a8a4b 100644 --- a/hw/gpio/puv3_gpio.c +++ b/hw/gpio/puv3_gpio.c @@ -46,9 +46,9 @@ static uint64_t puv3_gpio_read(void *opaque, hwaddr offset, ret = s->reg_GPIR; break; default: - DPRINTF("Bad offset 0x%x\n", offset); + DPRINTF("Bad offset 0x%lx\n", offset); } - DPRINTF("offset 0x%x, value 0x%x\n", offset, ret); + DPRINTF("offset 0x%lx, value 0x%x\n", offset, ret); return ret;