From: Borislav Petkov <bp@alien8.de>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Zefan <lizefan@huawei.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] tracing: Shrink the size of struct ftrace_event_field
Date: Sat, 27 Jul 2013 10:45:28 +0200 [thread overview]
Message-ID: <20130727084528.GA6923@pd.tnic> (raw)
In-Reply-To: <1374896842.6580.44.camel@gandalf.local.home>
On Fri, Jul 26, 2013 at 11:47:22PM -0400, Steven Rostedt wrote:
> On Sat, 2013-07-27 at 11:32 +0800, Li Zefan wrote:
>
> > struct event_filter {
> > diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> > index 7d85429..d72694d 100644
> > --- a/kernel/trace/trace_events.c
> > +++ b/kernel/trace/trace_events.c
> > @@ -106,6 +106,9 @@ trace_find_event_field(struct ftrace_event_call *call, char *name)
> > return __find_event_field(head, name);
> > }
> >
> > +/* detect bit-field overflow */
> > +#define VERIFY_SIZE(type) WARN_ON(type > field->type)
> > +
>
> One small nit. Move this macro definition into the function itself,
> right above the macro usage. That way it will be much easier to review
> in the future, as people don't need to go search for VERIFY_SIZE(). It
> will be right there with the usage. The aesthetics may be a bit off, but
> at least the code will be obvious at first glance at what is happening,
> and I think that's more important than the "look" of the code.
>
> Also, it will be obvious that the variable name must match the field
> name.
>
> Thanks,
>
> -- Steve
>
> > static int __trace_define_field(struct list_head *head, const char *type,
> > const char *name, int offset, int size,
> > int is_signed, int filter_type)
> > @@ -120,13 +123,16 @@ static int __trace_define_field(struct list_head *head, const char *type,
> > field->type = type;
> >
> > if (filter_type == FILTER_OTHER)
> > - field->filter_type = filter_assign_type(type);
> > - else
> > - field->filter_type = filter_type;
> > + filter_type = filter_assign_type(type);
> >
> > + field->filter_type = filter_type;
> > field->offset = offset;
> > field->size = size;
> > - field->is_signed = is_signed;
> > + field->is_signed = !!is_signed;
> > +
> > + VERIFY_SIZE(filter_type);
> > + VERIFY_SIZE(offset);
> > + VERIFY_SIZE(size);
Isn't this wrap-a-macro-with-another-more-obscure-macro not a bit too
much?
I mean,
WARN_ON(filter_type > field->filter_type)
is much more readable than VERIFY_SIZE IMO.
Thanks.
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
next prev parent reply other threads:[~2013-07-27 8:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 2:27 [PATCH 1/2][RESEND] tracing/syscalls: Annotate raw_init function with __init Li Zefan
2013-07-25 2:28 ` [PATCH 2/2][RESEND] tracing: Shrink the size of struct ftrace_event_field Li Zefan
2013-07-26 15:09 ` Steven Rostedt
2013-07-27 3:13 ` Li Zefan
2013-07-27 3:32 ` [PATCH v2 2/2] " Li Zefan
2013-07-27 3:47 ` Steven Rostedt
2013-07-27 8:45 ` Borislav Petkov [this message]
2013-07-27 11:35 ` Steven Rostedt
2013-07-27 16:19 ` Borislav Petkov
2013-07-29 2:14 ` [PATCH v3 " Li Zefan
2013-07-29 2:10 ` [PATCH v2 " Li Zefan
2013-07-26 14:23 ` [PATCH 1/2][RESEND] tracing/syscalls: Annotate raw_init function with __init Steven Rostedt
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=20130727084528.GA6923@pd.tnic \
--to=bp@alien8.de \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.