On Mon, Nov 18, 2013 at 12:51 PM, Saurabh Shah <ssaur...@vmware.com> wrote:

>
> Ben wrote:
>
> Microsoft documentation is just hilarious:
>      vsnprintf is included for compliance to the ANSI standard; ...
>  But I guess this wrapper won't help much because the MS libc doesn't
> support, for example, the 'z' modifier.  What's your plan for dealing
> with that?
>
>
> On Mon, Nov 18, 2013 at 09:45:48AM -0800, Saurabh Shah wrote:
>
> I was hoping we can just print with a larger length specifier. '%z'
> will there have to be disallowed and an appropriate signed/unsigned
> specifier should be used instead. Do you think that would be OK?
>
>
> It's going to cause trouble not just now but in the future.  Everyone
> knows and uses 'z' for size_t, and new uses of 'z' will therefore
> continue to be introduced.  We need to come up with some way to scan
> source code for it to avoid introducing new uses, or to avoid the
> problem entirely.
>
>
> By cause trouble, do you mean it will introduce bugs? I agree it will be a
> little annoying for people who know and use 'z'. And, I can definitely
> document the reason for not using the modifier where I define
> ovs_vsnprintf.
>

vsnprintf() is only a tiny part of the problem.  Very little code directly
calls vsnprintf(), although a significant amount of code calls it
indirectly.
A quick grep shows that here are at least 143 uses of the 'z' format
modifier in OVS.

Documentation can help in some cases, but I don't think it will help in
this case.  No one reads the documentation for printf-like functions
when they use them, because everyone already knows how printf
format specifiers work.

What would be a better alternative in your opinion?
>

 I can see two alternatives.  One is to add a rule to the Makefiles that
reports
uses of the 'z' format specifier.  Another is to add a correct
implementation
of *printf() and related functions to the tree, and set up the build so
that this
implementation gets used transparently (either all the time or just when the
C library's implementation is buggy).

>
> If not, there are only a handful of places where we use
> vsnprintf()'s, so I could #ifdefs the code.
>
>
> Why is vsnprintf the only issue?  *printf() has many variants, and all
> of them are potential problems.
>
> Sure
>
-- 
"I don't normally do acked-by's.  I think it's my way of avoiding
getting blamed when it all blows up."               Andrew Morton
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to