From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0091C5DF9E for ; Wed, 28 Oct 2020 22:27:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9875E206F4 for ; Wed, 28 Oct 2020 22:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733217AbgJ1W1O (ORCPT ); Wed, 28 Oct 2020 18:27:14 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7082 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733218AbgJ1W1N (ORCPT ); Wed, 28 Oct 2020 18:27:13 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CLfrr5jxGzLqcG; Wed, 28 Oct 2020 15:11:56 +0800 (CST) Received: from [10.174.187.138] (10.174.187.138) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Wed, 28 Oct 2020 15:11:47 +0800 Message-ID: <5F9919B3.9070605@huawei.com> Date: Wed, 28 Oct 2020 15:11:47 +0800 From: AlexChen User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: , , , , , CC: , , , , Subject: [PATCH 4/4] i386/kvm: make printf always compile in debug output References: <5F97FD61.4060804@huawei.com> <5F991331.4020604@huawei.com> <5F9914EE.8050209@huawei.com> <5F991641.4050606@huawei.com> In-Reply-To: <5F991641.4050606@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.138] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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: AlexChen --- target/i386/kvm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 3e9344aed5..64492cb851 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -50,14 +50,13 @@ #include "exec/memattrs.h" #include "trace.h" -#ifdef CONFIG_DEBUG_KVM -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) +#ifndef CONFIG_DEBUG_KVM +#define CONFIG_DEBUG_KVM 0 #endif +#define DPRINTF(fmt, ...) \ + do { if (CONFIG_DEBUG_KVM) { fprintf(stderr, fmt, ## __VA_ARGS__); } } while (0) + /* From arch/x86/kvm/lapic.h */ #define KVM_APIC_BUS_CYCLE_NS 1 #define KVM_APIC_BUS_FREQUENCY (1000000000ULL / KVM_APIC_BUS_CYCLE_NS) -- 2.19.1