public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Harvey Harrison <harvey.harrison@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Joe Perches <joe@perches.com>
Subject: Re: [patch] clean hex output of ftrace
Date: Wed, 08 Oct 2008 17:44:55 -0700	[thread overview]
Message-ID: <1223513095.8195.113.camel@brick> (raw)
In-Reply-To: <Pine.LNX.4.30.0810081715520.2487-100000@perches.com>

On Wed, 2008-10-08 at 17:16 -0700, Joe Perches wrote:
> On Wed, 8 Oct 2008, Harvey Harrison wrote:
> > From: Harvey Harrison <harvey.harrison@gmail.com>
> > Subject: [PATCH] ftrace: Fix inversion of hex output and use common routines
> 
> You're quick...
> 
> >  	BUG_ON(len >= HEX_CHARS);
> 
> I think the BUG_ON is senseless.
> 

Agreed, it probably meant to say BUG_ON(len * 2 > HEX_CHARS -1)

But as this is only called from within a helper macro, it could be
changed to a build-time check instead of a runtime:

From: Harvey Harrison <harvey.harrison@gmail.com>
Subject: [PATCH] trace: add build-time check to avoid overrunning hex buffer

Remove the runtime BUG_ON and change to a compile-time check in
the macro that calls the hex format routine

[Noticed by Joe Perches]
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 kernel/trace/trace.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 763f763..1ffbc24 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -395,7 +395,8 @@ trace_seq_putmem(struct trace_seq *s, void *mem, size_t len)
 	return len;
 }
 
-#define HEX_CHARS 17
+#define MAX_MEMHEX_BYTES	(8)
+#define HEX_CHARS		((MAX_MEMHEX_BYTES * 2) + 1)
 
 static int
 trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len)
@@ -404,8 +405,6 @@ trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len)
 	unsigned char *data = mem;
 	int i, j;
 
-	BUG_ON(len >= HEX_CHARS);
-
 #ifdef __BIG_ENDIAN
 	for (i = 0, j = 0; i < len; i++) {
 #else
@@ -1706,6 +1705,7 @@ do {							\
 
 #define SEQ_PUT_HEX_FIELD_RET(s, x)			\
 do {							\
+	BUILD_BUG_ON(sizeof(x) > MAX_MEMHEX_BYTES);	\
 	if (!trace_seq_putmem_hex(s, &(x), sizeof(x)))	\
 		return 0;				\
 } while (0)
-- 
1.6.0.2.471.g47a76




       reply	other threads:[~2008-10-09  0:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.30.0810081715520.2487-100000@perches.com>
2008-10-09  0:44 ` Harvey Harrison [this message]
2008-10-09 12:31   ` [patch] clean hex output of ftrace Ingo Molnar
2008-10-09 23:53     ` Harvey Harrison
2008-10-08 22:04 trem
2008-10-08 22:22 ` Joe Perches
2008-10-08 23:51   ` Harvey Harrison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1223513095.8195.113.camel@brick \
    --to=harvey.harrison@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox