From patchwork Sat Apr 1 13:32:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danil Antonov X-Patchwork-Id: 9657899 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 A53DD602BC for ; Sat, 1 Apr 2017 13:34:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90FE6285D2 for ; Sat, 1 Apr 2017 13:34:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8434F2860F; Sat, 1 Apr 2017 13:34:56 +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 2492F285D2 for ; Sat, 1 Apr 2017 13:34:56 +0000 (UTC) Received: from localhost ([::1]:51347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJB9-0002mw-Af for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Apr 2017 09:34:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJ8n-0001rX-Ac for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:32:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuJ8l-0006RQ-Tp for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:32:29 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:33928) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuJ8l-0006RI-N3 for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:32:27 -0400 Received: by mail-oi0-x242.google.com with SMTP id t11so13165329oib.1 for ; Sat, 01 Apr 2017 06:32:27 -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=Kg53PI4ngRMq5xqqAX7Zn22+E4WvDVN8Kw0yjnhK67o=; b=k4o7cBMV/kIQtorQ77cvwJSRKnuiC0ZtANt2kDx9+nUiW206VCsDNPqGOMpKBhP2i1 LvjtbBK7qWGgoV6onrNytlyVzdS8UZTyuo5CiE4Hsgk52DcOKIAFyYLqJm4URiz5lE/L Sf/l1lVwjBfAUWl8pDoK3wvKgI/fUH8xwOeAmOqlLTHe3VMtIN+2YFKSuKSygV4jMoKI 5bvvMHwGiTSIa9CgwPe8KgPEA5RLLO7GdvPjvAv2T0wuDheXuPjIncOfUvIRsEstK47G 0GzKpT3krlNNYfUD5adc6kacaC0wUizFYt8xFLNDBiYdXMELuxYoQbs6uU/c16f+fUkB 9a6g== 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=Kg53PI4ngRMq5xqqAX7Zn22+E4WvDVN8Kw0yjnhK67o=; b=tapZPnjKLwm3Pp35eeROtztajXRqhGenzdWVF9B5u8pZlqk09Qwnd19yYDT+ZDYwkh TYQ2TZ7xgBK9b8nADK7LZB40CT3U9zq6r2p4Gmz1mpSnB3L19NFKeTRDeyq0HuayuU61 4NwN6Kb3+QFwBnjIgLxyr/QY14B0sZc1Nj3hzs9rBZLDsOrN2abV68nmlsDk9LXvhe8y QQNyfN2Zqcih+6fOk/FY7Cj71vNb4MIe0WTd85DfHL0zJbe5N8yiCXFFrZnpfo68UZsV aUzs/ZrAtWBOr2JvspuEHurGzjz5IeudL07PcA6GCv5bfIXHxw10CdSC24Htgyw81S09 sRBw== X-Gm-Message-State: AFeK/H0zMp+vMZ09SdBE/cXVAmIFFv18PxKZ2GJwVT9ZRbvgMZJobMLIWD3Z4HkrsRJ2cRUp9Ih/35AQ7tVtWg== X-Received: by 10.202.237.65 with SMTP id l62mr4651419oih.38.1491053547003; Sat, 01 Apr 2017 06:32:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.32.234 with HTTP; Sat, 1 Apr 2017 06:32:26 -0700 (PDT) From: Danil Antonov Date: Sat, 1 Apr 2017 16:32:26 +0300 Message-ID: To: qemu-devel@nongnu.org, peter.maydell@linaro.org, balrogg@gmail.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 02/43] arm: 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 1671b92e5a4a59d5e38ce754d1d0dde2401c8236 Mon Sep 17 00:00:00 2001 From: Danil Antonov Date: Wed, 29 Mar 2017 02:09:33 +0300 Subject: [PATCH 02/43] arm: 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/arm/strongarm.c | 17 +++++++++++------ hw/arm/z2.c | 16 ++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c index 3311cc3..88368ac 100644 --- a/hw/arm/strongarm.c +++ b/hw/arm/strongarm.c @@ -59,11 +59,16 @@ - Enhance UART with modem signals */ -#ifdef DEBUG -# define DPRINTF(format, ...) printf(format , ## __VA_ARGS__) -#else -# define DPRINTF(format, ...) do { } while (0) -#endif +#ifndef DEBUG +#define DEBUG 0 +#endif + +#define DPRINTF(fmt, ...) \ + do { \ + if (DEBUG) { \ + fprintf(stderr, fmt, ## __VA_ARGS__); \ + } \ + } while (0) static struct { hwaddr io_base; @@ -1022,7 +1027,7 @@ static void strongarm_uart_update_parameters(StrongARMUARTState *s) s->char_transmit_time = (NANOSECONDS_PER_SECOND / speed) * frame_size; qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp); - DPRINTF(stderr, "%s speed=%d parity=%c data=%d stop=%d\n", s->chr->label, + DPRINTF("%s speed=%d parity=%c data=%d stop=%d\n", s->chr.chr->label, speed, parity, data_bits, stop_bits); } diff --git a/hw/arm/z2.c b/hw/arm/z2.c index 1607cbd..1ee8ed9 100644 --- a/hw/arm/z2.c +++ b/hw/arm/z2.c @@ -27,12 +27,16 @@ #include "exec/address-spaces.h" #include "sysemu/qtest.h" -#ifdef DEBUG_Z2 -#define DPRINTF(fmt, ...) \ - printf(fmt, ## __VA_ARGS__) -#else -#define DPRINTF(fmt, ...) -#endif +#ifndef DEBUG_Z2 +#define DEBUG_Z2 0 +#endif + +#define DPRINTF(fmt, ...) \ + do { \ + if (DEBUG_Z2) { \ + fprintf(stderr, "z2: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) static const struct keymap map[0x100] = { [0 ... 0xff] = { -1, -1 },