On Tue, May 10, 2011 at 04:28:22PM +0200, Jiri Denemark wrote:
On Mon, May 09, 2011 at 17:24:09 +0800, Lai Jiangshan wrote:
> These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead.
>
> How these coversions works? The magic is using ##.
> #define high_levle_api(fmt, ...) low_levle_api(fmt, ##__VA_ARGS__)
> When __VA_ARGS__ is empty, "##" will swallow the "," in
"fmt," to avoid compile error.
>
> example: origin after CPP
> high_levle_api("%d", a_int) low_levle_api("%d", a_int)
> high_levle_api("a string") low_levle_api("a string")
>
> About 400 conversions.
>
> 8 special conversions:
> VIR_XXXX0("") -> VIR_XXXX(" ") (avoid empty format) 2
conversions
> VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions
> VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal)
(for security) 6 conversions
Hmm, I'm not entirely sure this patch is correct. VIR_XXX0(msg) should really
be translated into "%s" format string and msg argument. It definitely needs to
be so when msg is translated (i.e., _("...")).
In 99% of the cases, we don't really need '%s', because the strings
are constant. So only the VIR_ERROR0 replacements need to be fixed to
pass ("%s", ...)
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|