Re: [RFC][PATCH 1/3] trace_seq: Move the trace_seq code to lib/

Johannes Berg
2014-06-22T07:38:14Z

On Fri, 2014-06-20 at 12:58 -0400, Steven Rostedt wrote:

> > > +#define HEX_CHARS (MAX_MEMHEX_BYTES*2 + 1)
> > > +
> > > +int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, size_t len)
> > > +{
> > > + unsigned char hex[HEX_CHARS];
> > > + const unsigned char *data = mem;
> > > + int i, j;
> > > +
> > > + if (s->full)
> > > + return 0;
> >
> > What's this ->full thing all about anyway? Some central comment which
> > explains the design is needed.
>
> Comment? What? Git blame isn't good enough for ya? ;-)
>
> >
> > Is this test really needed? trace_seq_putmem() will handle this.
>
> It was added as an optimization, because once it filled up, you could
> still have multiple calls to the trace_seq() functions that would waste
> time trying to write the buffer.
>
> It seemed like a good idea at the time. I Cc'd Johannes Berg as he's
> the one that implemented.
>
> Johannes, is this really needed, should we bother keeping it?

Honestly, I don't remember, sorry.

Looking at the code though, I'm not sure it's a pure optimisation - if
you do say putc() after a failed puts(), without this code the putc()
would succeed? I can't tell right now if that's really a problem, but it
seems you could get some odd behaviour out of it.

johannes