[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150402122511.058a27ce@gandalf.local.home>
Date: Thu, 2 Apr 2015 12:25:11 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Guilherme Cox <cox@...puter.org>,
Tony Luck <tony.luck@...il.com>,
Xie XiuQi <xiexiuqi@...wei.com>
Subject: Re: [RFC][PATCH 06/17 v3] tracing: Add TRACE_DEFINE_ENUM() macro to
map enums to their values
I updated the function to handle structures that were saved as well.
Just in case something like REC->my_enum does not get converted.
Also, I found that I never needed to decrement the pointer for those
locations that I did so.
Here's the new function:
static void update_event_printk(struct ftrace_event_call *call,
struct trace_enum_map *map)
{
char *ptr;
int quote = 0;
int len = strlen(map->enum_string);
for (ptr = call->print_fmt; *ptr; ptr++) {
if (*ptr == '\\') {
ptr++;
/* paranoid */
if (!*ptr)
break;
continue;
}
if (*ptr == '"') {
quote ^= 1;
continue;
}
if (quote)
continue;
if (isdigit(*ptr)) {
/* skip numbers */
do {
ptr++;
/* Check for alpha chars like ULL */
} while (isalnum(*ptr));
/*
* A number must have some kind of delimiter after
* it, and we can ignore that too.
*/
continue;
}
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;
}
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;
}
}
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists