Messages in this thread | | | Date | Mon, 6 Apr 2015 07:52:37 -0400 | From | Steven Rostedt <> | Subject | Re: [PATCH 07/18 v3] tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values |
| |
On Mon, 6 Apr 2015 13:54:33 +0900 Namhyung Kim <namhyung@kernel.org> wrote:
> > + if (isalpha(*ptr) || *ptr == '_') { > > + if (strncmp(map->enum_string, ptr, len) == 0 && > > + !isalnum(ptr[len]) && ptr[len] != '_') { > > + ptr = enum_replace(ptr, map, len); > > + /* Hmm, enum string smaller than value */ > > + if (WARN_ON_ONCE(!ptr)) > > + return; > > + /* > > + * No need to decrement here, as enum_replace() > > + * returns the pointer to the character passed > > + * the enum, and two enums can not be placed > > + * back to back without something in between. > > + * We can skip that something in between. > > + */ > > + continue; > > Maybe I'm becoming a bit paranoid, what I worried was like this: > > ENUM1\"ENUM2\" > > In this case, it skips the backslash and makes quotation effective..
The only time a backslash is OK is if it's in a quote, where we do not process enums there anyway.
The above isn't valid C outside of quotes, so I'm still not worried.
> > > > + } > > + skip_more: > > + do { > > + ptr++; > > + } while (isalnum(*ptr) || *ptr == '_'); > > + /* > > + * If what comes after this variable is a '.' or > > + * '->' then we can continue to ignore that string. > > + */ > > + if (*ptr == '.' || (ptr[0] == '-' && ptr[1] == '>')) { > > + ptr += *ptr == '.' ? 1 : 2; > > + goto skip_more; > > + } > > + /* > > + * Once again, we can skip the delimiter that came > > + * after the string. > > + */ > > + continue; > > + } > > + } > > +} > > + > > +void trace_event_enum_update(struct trace_enum_map **map, int len) > > +{ > > + struct ftrace_event_call *call, *p; > > + const char *last_system = NULL; > > + int last_i; > > + int i; > > + > > + down_write(&trace_event_sem); > > + list_for_each_entry_safe(call, p, &ftrace_events, list) { > > + /* events are usually grouped together with systems */ > > + if (!last_system || call->class->system != last_system) { > > I think simply checking "call->class->system != last_system" would work.
I think you are correct, but I'm not sure I want to change it. Mainly because it's more readable that way. The !last_system is basically the "this is first time". Leaving it out may cause people to think it's wrong.
But I may change my mind and remove it anyway ;-)
If there's other things wrong with this patch, I may update this too.
Thanks for reviewing.
-- Steve
| |