[ovs-dev] [PATCH] util: New wrapper function ovs_vsnprintf().

Saurabh Shah ssaurabh at vmware.com
Mon Nov 18 20:51:21 UTC 2013


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.
What would be a better alternative in your opinion?


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20131118/b4b8b6ee/attachment-0003.html>


More information about the dev mailing list