Re: [patch] trace: find the correct ftrace event

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 20, 2010 at 10:07:16AM -0400, Steven Rostedt wrote:
> On Sat, 2010-03-20 at 16:56 +0300, Dan Carpenter wrote:
> 
> > > > diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
> > > > index 4615f62..6070c70 100644
> > > > --- a/kernel/trace/trace_events_filter.c
> > > > +++ b/kernel/trace/trace_events_filter.c
> > > > @@ -1388,16 +1388,19 @@ int ftrace_profile_set_filter(struct perf_event *event, int event_id,
> > > >  	struct event_filter *filter;
> > > >  	struct filter_parse_state *ps;
> > > >  	struct ftrace_event_call *call = NULL;
> > > > +	int found = 0;
> > > >  
> > > >  	mutex_lock(&event_mutex);
> > > >  
> > > >  	list_for_each_entry(call, &ftrace_events, list) {
> > > > -		if (call->id == event_id)
> > > > +		if (call->id == event_id) {
> > > > +			found = 1;
> > > >  			break;
> > > > +		}
> > > >  	}
> > > >  
> > > >  	err = -EINVAL;
> > > > -	if (!call)
> > > 
> > > 	if (call == &ftrace_events)
> > > 
> > 
> > Man...  That makes my head hurt.  It only works because ->list is the 
> > first element in the struct.
> > 
> > We'd need a cast.
> 
> Oops, I missed the fact that it was list_*_entry(). That should be:
> 
> 	if (call->list != &ftrace_events)
> 
> No cast needed.
> 

Hm...  "list" is a struct not a pointer to a struct.

So it would have to be:

        if (&call->list == &ftrace_events)
                goto out_unlock;

That's how the list_for_each_entry() determines the end of the list as
well.

I'll send a patch to do that.

regards,
dan carpenter

> > 
> > Is that really cleaner?
> 
> Perhaps not, but I think it is more elegant ;-)
> 
> -- Steve
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux