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=unavailable 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 963B3C56202 for ; Wed, 28 Oct 2020 22:28:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60EBA20714 for ; Wed, 28 Oct 2020 22:28:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733253AbgJ1W1X (ORCPT ); Wed, 28 Oct 2020 18:27:23 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6571 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733244AbgJ1W1W (ORCPT ); Wed, 28 Oct 2020 18:27:22 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CLfrj26YyzhcnD; Wed, 28 Oct 2020 15:11:49 +0800 (CST) Received: from [10.174.187.138] (10.174.187.138) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Wed, 28 Oct 2020 15:11:37 +0800 Message-ID: <5F9919A9.5070606@huawei.com> Date: Wed, 28 Oct 2020 15:11:37 +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 3/4] kvm: make printf always compile in debug output References: <5F97FD61.4060804@huawei.com> <5F991331.4020604@huawei.com> <5F9914EE.8050209@huawei.com> In-Reply-To: <5F9914EE.8050209@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 --- accel/kvm/kvm-all.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index fc6d99a731..854b352346 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -60,14 +60,12 @@ */ #define PAGE_SIZE qemu_real_host_page_size +#ifndef CONFIG_DEBUG_KVM +#define CONFIG_DEBUG_KVM 0 +#endif -#ifdef CONFIG_DEBUG_KVM -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) -#else #define DPRINTF(fmt, ...) \ - do { } while (0) -#endif + do { if (CONFIG_DEBUG_KVM) { fprintf(stderr, fmt, ## __VA_ARGS__); } } while (0) #define KVM_MSI_HASHTAB_SIZE 256 -- 2.19.1