From patchwork Thu Oct 6 08:47:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9364379 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 7663B607D3 for ; Thu, 6 Oct 2016 09:29:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6868328E85 for ; Thu, 6 Oct 2016 09:29:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D5CB28E87; Thu, 6 Oct 2016 09:29:21 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3CDB28E85 for ; Thu, 6 Oct 2016 09:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965387AbcJFIrg (ORCPT ); Thu, 6 Oct 2016 04:47:36 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:32528 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S964983AbcJFIrd (ORCPT ); Thu, 6 Oct 2016 04:47:33 -0400 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="882165" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 06 Oct 2016 16:47:20 +0800 Received: from adam-work.localdomain (unknown [10.167.226.34]) by cn.fujitsu.com (Postfix) with ESMTP id C3E5B41B4BC2; Thu, 6 Oct 2016 16:47:20 +0800 (CST) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH] btrfs-progs: Fix warning_trace compile error if backtrace is disabled Date: Thu, 6 Oct 2016 16:47:19 +0800 Message-Id: <20161006084719.9540-1-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.10.0 MIME-Version: 1.0 X-yoursite-MailScanner-ID: C3E5B41B4BC2.AE829 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we disable backtrace, btrfs-progs can't be compiled since we don't have warning_trace defined. Fix by move it out of #ifndef BTRFS_DISABLE_BACKTRACE block. Signed-off-by: Qu Wenruo --- kerncompat.h | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/kerncompat.h b/kerncompat.h index ea04ef3..fba0bc1 100644 --- a/kerncompat.h +++ b/kerncompat.h @@ -72,6 +72,26 @@ #define ___token_glue(a,b,c) a ## b ## c #define BUILD_ASSERT(x) extern int __token_glue(compile_time_assert_,__LINE__,__COUNTER__)[1-2*!(x)] __attribute__((unused)) +static inline void warning_trace(const char *assertion, const char *filename, + const char *func, unsigned line, int val, + int trace) +{ + if (val) + return; + if (assertion) + fprintf(stderr, + "%s:%d: %s: Warning: assertion `%s` failed, value %d\n", + filename, line, func, assertion, val); + else + fprintf(stderr, + "%s:%d: %s: Warning: assertion failed, value %d.\n", + filename, line, func, val); +#ifndef BTRFS_DISABLE_BACKTRACE + if (trace) + print_trace(); +#endif +} + #ifndef BTRFS_DISABLE_BACKTRACE #define MAX_BACKTRACE 16 static inline void print_trace(void) @@ -99,24 +119,6 @@ static inline void assert_trace(const char *assertion, const char *filename, exit(1); } -static inline void warning_trace(const char *assertion, const char *filename, - const char *func, unsigned line, int val, - int trace) -{ - if (val) - return; - if (assertion) - fprintf(stderr, - "%s:%d: %s: Warning: assertion `%s` failed, value %d\n", - filename, line, func, assertion, val); - else - fprintf(stderr, - "%s:%d: %s: Warning: assertion failed, value %d.\n", - filename, line, func, val); - if (trace) - print_trace(); -} - #define BUG() assert_trace(NULL, __FILE__, __func__, __LINE__, 0) #else #define BUG() assert(0)