Re: [PATCH v7 08/14] Introduce chr-testdev

Radim Krčmář
2014-07-22T18:06:15Z

2014-07-16 11:33+0200, Andrew Jones:
> On Wed, Jul 16, 2014 at 05:31:33AM -0400, Levente Kurusa wrote:
> > ----- Original Message -----
> > > [...]
> > > +void chr_testdev_exit(int code)
> > > +{
> > > + char buf[8];
> > > + int len;
> > > +
> > > + snprintf(buf, sizeof(buf), "%dq", code);
> > > + len = strlen(buf);
> >
> > AFAIK, snprintf returns the number of characters written, so
> > these two statements can be merged into one.
>
> You are correct. I'll do this for v8 (if a v8 is needed).

snprintf returns the number of characters that would be written without
truncation, so it wouldn't handle a very long code ;)

I'd prefer the obvious v7, to finding a minimum with 'sizeof(buf) - 1'.