Re: [PATCH] libvirt, logging: cleanup VIR_DEBUG0() VIR_INFO0() VIR_WARN0() VIR_ERROR0()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]