lkml.org 
[lkml]   [2018]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 12/18] tracing: Add accessing direct address from function based events
On Tue, 13 Feb 2018 00:47:50 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> > > if (WARN_ON(!fevent->last_arg))
> > > break;
> > > - ret = kstrtoul(token, 0, &val);
> > > - if (ret < 0)
> > > - break;
> > > + if (isalpha(token[0]) || token[0] != '_') {
> >
> > I guess you wanted the token[0] being '_'. Maybe it'd be better adding
> >
> > #define isident0(x) (isalpha(x) || (x) == '_')
>
> If this '$' is only for the symbol or direct address(with 0x prefix),
> you just need to check by !isdigit(token[0]), isn't it?
> (and if it is insane get_symbol just fails)

I modified a lot of this code for the next version (which I'm still
tweaking).

I have this for next_token() (which I may add for the
trace_events_filter.c code as Al Viro has recently pointed out issues
with its parsing):

static char *next_token(char **ptr, char *last)
{
char *arg;
char *str;

if (!*ptr)
return NULL;

arg = *ptr;

if (*last)
*arg = *last;

if (!*arg)
return NULL;

for (str = arg; *str; str++) {
if (!isalnum(*str) && *str != '_')
break;
}
if (*str) {
if (str == arg)
str++;
*last = *str;
*str = 0;
*ptr = str;
return arg;
}

*last = 0;
*ptr = NULL;
return arg;
}


And this:

static bool valid_name(const char *token)
{
return isalpha(token[0]) || token[0] == '_';
}

As all tokens will now be either entirely alphanumeric with '_' or a
single character.

-- Steve

\
 
 \ /
  Last update: 2018-02-12 17:47    [W:0.090 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site