lkml.org 
[lkml]   [2012]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 3/3] tools lib traceevent: Introduce pevent_strerror
Date
Steven Rostedt <rostedt@goodmis.org> writes:
> On Sat, 2012-06-16 at 07:25 +0900, Namhyung Kim wrote:
>> Steven Rostedt <rostedt@goodmis.org> writes:
>> > Here's a little macro trick to keep the strings and enums always in
>> > sync:
>> >
>> > #define __PEVENT_ERRNO_CODES \
>> > _C(PEVENT_ERRNO__MEM_ALLOC_FAILED, "failed to allocate memory"), \
>> > _C(PEVENT_ERRNO__PARSE_EVENT_FAILED, "failed to parse event"), \
>> > _C(PEVENT_ERRNO__READ_ID_FAILED, "failed to read event id"), \
>> > _C(PEVENT_ERRNO__READ_FORMAT_FAILED, "failed to read event format"), \
>> > _C(PEVENT_ERRNO__READ_PRINT_FAILED, "failed to read event print fmt"),\
>> > _C(PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace"),
>> >
>> > #undef _C
>> > #define _C(a,b) b
>> > static const char * const pevent_error_str[] = { __PEVENT_ERROR_CODES };
>> >
>>
>> Cool. Maybe even shorter:
>>
>> #define __PEVENT_ERRNO_CODES \
>> _C(MEM_ALLOC_FAILED, "failed to allocate memory"), \
>> _C(PARSE_EVENT_FAILED, "failed to parse event"), \
>> _C(READ_ID_FAILED, "failed to read event id"), \
>> _C(READ_FORMAT_FAILED, "failed to read event format"), \
>> _C(READ_PRINT_FAILED, "failed to read event print fmt"), \
>> _C(OLD_FTRACE_ARG_FAILED, "failed to allocate field name for ftrace"),
>>
>> #undef _C
>> #define _C(a,b) PEVENT_ERRNO__ ## a
>
> I think you wanted b on this one. ;-)
>

Oops, right. :)


>> static const char * const pevent_error_str[] = { __PEVENT_ERROR_CODES };
>>
>> But it make them less grep-able?
>
> Yeah, that is a problem, although we could perhaps teach ctags and etags
> how to find them.
>

Ok, then I'll go with yours.

Thanks,
Namhyung


\
 
 \ /
  Last update: 2012-06-16 01:21    [W:0.079 / U:0.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site