Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1237351

[for-next][PATCH 18/25] tracing: Add build bug if we have more trace_flags than bits

From Steven Rostedt <rostedt@goodmis.org>
Newsgroups linux.kernel
Subject [for-next][PATCH 18/25] tracing: Add build bug if we have more trace_flags than bits
Date 2015-10-01 14:10 +0200
Message-ID <qeKQs-3yE-63@gated-at.bofh.it> (permalink)
References <qeKGK-383-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Add a enum that denotes the last bit of the trace_flags and have a
BUILD_BUG_ON(last_bit > 32).

If we add more bits than we have in trace_flags, the kernel wont build.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 6 ++++++
 kernel/trace/trace.h | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7446d4238f87..991bab9b79d2 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7046,6 +7046,12 @@ __init static int tracer_alloc_buffers(void)
 	int ring_buf_size;
 	int ret = -ENOMEM;
 
+	/*
+	 * Make sure we don't accidently add more trace options
+	 * than we have bits for.
+	 */
+	BUILD_BUG_ON(TRACE_ITER_LAST_BIT > 32);
+
 	if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
 		goto out;
 
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 8ed97872b65b..07155652254d 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -966,7 +966,11 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
 #undef C
 #define C(a, b) TRACE_ITER_##a##_BIT
 
-enum trace_iterator_bits { TRACE_FLAGS };
+enum trace_iterator_bits {
+	TRACE_FLAGS
+	/* Make sure we don't go more than we have bits for */
+	TRACE_ITER_LAST_BIT
+};
 
 /*
  * By redefining C, we can make TRACE_FLAGS a list of masks that
-- 
2.5.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[for-next][PATCH 00/25] tracing: Have instances have their own options + clean ups Steven Rostedt <rostedt@goodmis.org> - 2015-10-01 14:10 +0200
  [for-next][PATCH 03/25] tracing: Remove ftrace_trace_stack_regs() Steven Rostedt <rostedt@goodmis.org> - 2015-10-01 14:10 +0200
  [for-next][PATCH 18/25] tracing: Add build bug if we have more trace_flags than bits Steven Rostedt <rostedt@goodmis.org> - 2015-10-01 14:10 +0200
  [for-next][PATCH 24/25] tracing: Add trace options for core options to instances Steven Rostedt <rostedt@goodmis.org> - 2015-10-01 14:10 +0200
  [for-next][PATCH 04/25] tracing: Remove unused function trace_current_buffer_lock_reserve() Steven Rostedt <rostedt@goodmis.org> - 2015-10-01 14:10 +0200
  [for-next][PATCH 02/25] tracing: Move non perf code out of perf.h Steven Rostedt <rostedt@goodmis.org> - 2015-10-01 14:10 +0200
  [for-next][PATCH 17/25] tracing: Always show all tracer options in the options directory Steven Rostedt <rostedt@goodmis.org> - 2015-10-01 14:10 +0200

csiph-web