From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755636AbbDGORJ (ORCPT ); Tue, 7 Apr 2015 10:17:09 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34774 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754690AbbDGORF (ORCPT ); Tue, 7 Apr 2015 10:17:05 -0400 Date: Tue, 7 Apr 2015 23:16:02 +0900 From: Namhyung Kim To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Andrew Morton , Arnaldo Carvalho de Melo , Masami Hiramatsu , Mathieu Desnoyers , Guilherme Cox , Tony Luck , Xie XiuQi Subject: Re: [PATCH 07/18 v3] tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values Message-ID: <20150407141602.GG15878@danjae.kornet> References: <20150403013802.220157513@goodmis.org> <20150403014123.997385206@goodmis.org> <20150406045433.GB15878@danjae.kornet> <20150406075237.6f1ffe2e@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150406075237.6f1ffe2e@gandalf.local.home> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steve, On Mon, Apr 06, 2015 at 07:52:37AM -0400, Steven Rostedt wrote: > On Mon, 6 Apr 2015 13:54:33 +0900 > Namhyung Kim 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. OK > > > > > > > > + } > > > + 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. OK. You can add my Acked-by if you like.. Thanks, Namhyung