Re: [PATCH 01/17] tools lib traceevent: Add state member to struct trace_seq

From: Namhyung Kim
Date: Tue Jan 14 2014 - 21:49:38 EST


Hi Steve,

On Tue, 14 Jan 2014 21:00:58 -0500, Steven Rostedt wrote:
> On Wed, 15 Jan 2014 10:45:24 +0900
> Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
>>
>> @@ -32,8 +33,9 @@
>> #define TRACE_SEQ_POISON ((void *)0xdeadbeef)
>> #define TRACE_SEQ_CHECK(s) \
>> do { \
>> - if ((s)->buffer == TRACE_SEQ_POISON) \
>> - die("Usage of trace_seq after it was destroyed"); \
>> + if (WARN_ONCE((s)->buffer == TRACE_SEQ_POISON, \
>> + "Usage of trace_seq after it was destroyed")) \
>> + (s)->state = TRACE_SEQ__BUFFER_POISONED; \
>> } while (0)
>>
>> @@ -189,9 +205,15 @@ int trace_seq_putc(struct trace_seq *s, unsigned char c)
>> {
>> TRACE_SEQ_CHECK(s);
>>
>> + if (s->state != TRACE_SEQ__GOOD)
>> + return 0;
>> +
>
> Instead of adding all of these, we can extend the macro
> TRACE_SEQ_CHECK() which does a
> if (s->state != TRACE_SEQ__GOOD)
> return;
>
> and a TRACE_SEQ_CHECK_RET() that does a return 0;

Oh, it looks better. But I'd like to TRACE_SEQ_CHECK() as is for some
cases. How about this?