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

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



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., _("...")).

Jirka


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