[PATCH] v4l2.c: add decoding for VIDIOC_CREATE_BUFS's arg.

Dmitry V. Levin ldv at altlinux.org
Fri Apr 17 11:23:37 UTC 2015


On Fri, Apr 17, 2015 at 12:47:10PM +0200, Philippe De Muyter wrote:
> On Thu, Apr 16, 2015 at 09:56:30PM +0300, Dmitry V. Levin wrote:
> > On Thu, Apr 16, 2015 at 03:33:34PM +0200, Philippe De Muyter wrote:
> > > +		else {
> > > +			static char fmt[] = "{index=%u, count=%u}";
> > 
> > This fmt does not have to be static.
> > 
> > > +			static char outstr[sizeof(fmt) + sizeof(int) * 6];
> > > +
> > > +			sprintf(outstr, fmt, b.index, b.count);
> > > +			tcp->auxstr = outstr;
> > > +			return 1 + RVAL_STR;
> 
> The 'static' attributes makes the binary smaller.  Try this for yourself :

I certainly do not suggest to place it on the stack.

[...]
> I should even add the 'const' qualifier to put the string in the
> 'text' segment.

The same effect could be achieved by using the format string verbatim,
without assigning a variable.

OK, let it be static const then.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20150417/b3ab5ba5/attachment.bin>


More information about the Strace-devel mailing list