From patchwork Wed Apr 6 03:35:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8757901 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9778DC0553 for ; Wed, 6 Apr 2016 03:36:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0B7B2035B for ; Wed, 6 Apr 2016 03:36:46 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 5636E20351 for ; Wed, 6 Apr 2016 03:36:46 +0000 (UTC) Received: from localhost ([::1]:40624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aneGr-0005ja-Pr for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Apr 2016 23:36:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aneFU-0003cZ-6v for qemu-devel@nongnu.org; Tue, 05 Apr 2016 23:35:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aneFP-0002Nn-F8 for qemu-devel@nongnu.org; Tue, 05 Apr 2016 23:35:20 -0400 Received: from resqmta-po-11v.sys.comcast.net ([2001:558:fe16:19:96:114:154:170]:57466 helo=resqmta-ch2-11v.sys.comcast.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aneFP-0002Mu-AH for qemu-devel@nongnu.org; Tue, 05 Apr 2016 23:35:15 -0400 Received: from resomta-po-17v.sys.comcast.net ([96.114.154.241]) by comcast with SMTP id neFOaaotqvJlgneFOa0VBu; Wed, 06 Apr 2016 03:35:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1459913714; bh=BrB4Qvt6HGoeed6WMqoDyi1IFu2UFwLBTFFErZuEgaM=; h=Received:Received:From:To:Subject:Date:Message-Id; b=N6DDmPgc3PgPdFjtJniaiCncJkLgP9ZEpcnuP+6ZPHVwp0y0lXbS7jVEZWaRTrgZa c5gHv5JKGKMzXMDGq02Zgj1vKPojGQi6Pz5h+4LrQVvQzsySPcXGckgfQcGaHQVq+E svTUOXl7n+B4pgEcOy+gfuJbNabHUTvNC9mvThy0gKm9qVy9H8HV6drwPEnX5uwEyj 0IJXEJHPC2KJoew8WlT2J8seL/9z56POJ35XatyOs5J7c0Hd4I5qIKy/ZoQGbSVrpT 46Wqh7u8iG097CfSC6QFP8ZiaBtepIR9MntC+4XKxpdmEpM0v3k6MON8gsk5MD37wE iLUovJmoVWgRQ== Received: from red.redhat.com ([24.10.254.122]) by resomta-po-17v.sys.comcast.net with comcast id erb51s0052fD5rL01rbE7W; Wed, 06 Apr 2016 03:35:14 +0000 From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 5 Apr 2016 21:35:03 -0600 Message-Id: <1459913704-19949-3-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459913704-19949-1-git-send-email-eblake@redhat.com> References: <1459913704-19949-1-git-send-email-eblake@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:558:fe16:19:96:114:154:170 Cc: pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 2/3] nbd: Avoid bitrot in TRACE() usage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The compiler is smart enough to optimize out 'if (0)', but won't type-check our printfs if they are hidden behind #if. Signed-off-by: Eric Blake --- nbd/nbd-internal.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h index 127c48d..f4dce06 100644 --- a/nbd/nbd-internal.h +++ b/nbd/nbd-internal.h @@ -33,18 +33,21 @@ #define DEBUG_NBD #ifdef DEBUG_NBD -#define TRACE(msg, ...) do { \ - LOG(msg, ## __VA_ARGS__); \ -} while(0) +#define DEBUG_NBD_PRINT 1 #else -#define TRACE(msg, ...) \ - do { } while (0) +#define DEBUG_NBD_PRINT 0 #endif +#define TRACE(msg, ...) do { \ + if (DEBUG_NBD_PRINT) { \ + LOG(msg, ## __VA_ARGS__); \ + } \ +} while (0) + #define LOG(msg, ...) do { \ fprintf(stderr, "%s:%s():L%d: " msg "\n", \ __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \ -} while(0) +} while (0) /* This is all part of the "official" NBD API. *