libvirt,logging: cleanup VIR_XXX0()

These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead.

How do these coversions works? The magic is using the gcc extension of ##.
When __VA_ARGS__ is empty, "##" will swallow the "," in "fmt," to
avoid compile error.

example: origin				after CPP
	high_level_api("%d", a_int)	low_level_api("%d", a_int)
	high_level_api("a  string")	low_level_api("a  string")

About 400 conversions.

8 special conversions:
VIR_XXXX0("") -> VIR_XXXX("msg") (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

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
This commit is contained in:
Lai Jiangshan
2011-05-09 17:24:09 +08:00
committed by Eric Blake
parent 0e5a7ace8a
commit b65f37a4a1
60 changed files with 417 additions and 428 deletions

View File

@@ -572,7 +572,7 @@ virCommandSetWorkingDirectory(virCommandPtr cmd, const char *pwd)
if (cmd->pwd) {
cmd->has_error = -1;
VIR_DEBUG0("cannot set directory twice");
VIR_DEBUG("cannot set directory twice");
} else {
cmd->pwd = strdup(pwd);
if (!cmd->pwd)
@@ -592,7 +592,7 @@ virCommandSetInputBuffer(virCommandPtr cmd, const char *inbuf)
if (cmd->infd != -1 || cmd->inbuf) {
cmd->has_error = -1;
VIR_DEBUG0("cannot specify input twice");
VIR_DEBUG("cannot specify input twice");
return;
}
@@ -617,7 +617,7 @@ virCommandSetOutputBuffer(virCommandPtr cmd, char **outbuf)
if (cmd->outfdptr) {
cmd->has_error = -1;
VIR_DEBUG0("cannot specify output twice");
VIR_DEBUG("cannot specify output twice");
return;
}
@@ -641,7 +641,7 @@ virCommandSetErrorBuffer(virCommandPtr cmd, char **errbuf)
if (cmd->errfdptr) {
cmd->has_error = -1;
VIR_DEBUG0("cannot specify stderr twice");
VIR_DEBUG("cannot specify stderr twice");
return;
}
@@ -661,12 +661,12 @@ virCommandSetInputFD(virCommandPtr cmd, int infd)
if (cmd->infd != -1 || cmd->inbuf) {
cmd->has_error = -1;
VIR_DEBUG0("cannot specify input twice");
VIR_DEBUG("cannot specify input twice");
return;
}
if (infd < 0) {
cmd->has_error = -1;
VIR_DEBUG0("cannot specify invalid input fd");
VIR_DEBUG("cannot specify invalid input fd");
return;
}
@@ -685,7 +685,7 @@ virCommandSetOutputFD(virCommandPtr cmd, int *outfd)
if (cmd->outfdptr) {
cmd->has_error = -1;
VIR_DEBUG0("cannot specify output twice");
VIR_DEBUG("cannot specify output twice");
return;
}
@@ -704,7 +704,7 @@ virCommandSetErrorFD(virCommandPtr cmd, int *errfd)
if (cmd->errfdptr) {
cmd->has_error = -1;
VIR_DEBUG0("cannot specify stderr twice");
VIR_DEBUG("cannot specify stderr twice");
return;
}
@@ -725,7 +725,7 @@ virCommandSetPreExecHook(virCommandPtr cmd, virExecHook hook, void *opaque)
if (cmd->hook) {
cmd->has_error = -1;
VIR_DEBUG0("cannot specify hook twice");
VIR_DEBUG("cannot specify hook twice");
return;
}
cmd->hook = hook;