diff mbox

btrfs-progs: Fix warning_trace compile error if backtrace is disabled

Message ID 20161006084719.9540-1-quwenruo@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Qu Wenruo Oct. 6, 2016, 8:47 a.m. UTC
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 <quwenruo@cn.fujitsu.com>
---
 kerncompat.h | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

Comments

David Sterba Oct. 6, 2016, 3:34 p.m. UTC | #1
On Thu, Oct 06, 2016 at 04:47:19PM +0800, Qu Wenruo wrote:
> 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.

But now this breaks with backtrace, eg:

kerncompat.h: In function ‘warning_trace’:
kerncompat.h:91:3: warning: implicit declaration of function ‘print_trace’ [-Wimplicit-function-declaration]
   print_trace();
   ^~~~~~~~~~~
kerncompat.h: At top level:
kerncompat.h:97:20: warning: conflicting types for ‘print_trace’
 static inline void print_trace(void)
                    ^~~~~~~~~~~
kerncompat.h:97:20: error: static declaration of ‘print_trace’ follows non-static declaration
kerncompat.h:91:3: note: previous implicit declaration of ‘print_trace’ was here
   print_trace();

I've fixed it and will add a script to cycle through common build
configuration so we can automate that a bit.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)