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 05/09/2011 03:24 AM, 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

Yuck, that leaves trailing space.  I'd rather have a real message.

> VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions

Good that nothing hit this pattern, because my followup patch will
magically transform 1-arg vir_XXXX("xyz") to vir_XXXX("%s", "xyz"), and
any doubled-up %% would thus cause a change in output.

> VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal) (for security) 6 conversions

Good.

Also, cfg.mk can be simplified (hmm, we don't have any syntax-rules for
VIR_INFO, so I'll do that as a followup).

Here's what I squashed in; I'll wait to push until my followups have
been reviewed.

diff --git i/cfg.mk w/cfg.mk
index 9ee0dd0..1b60282 100644
--- i/cfg.mk
+++ w/cfg.mk
@@ -390,7 +390,6 @@ msg_gen_function += ESX_ERROR
 msg_gen_function += ESX_VI_ERROR
 msg_gen_function += PHYP_ERROR
 msg_gen_function += VIR_ERROR
-msg_gen_function += VIR_ERROR0
 msg_gen_function += VMX_ERROR
 msg_gen_function += XENXS_ERROR
 msg_gen_function += eventReportError
@@ -525,7 +524,7 @@ sc_copyright_format:
 # Some functions/macros produce messages intended solely for developers
 # and maintainers.  Do not mark them for translation.
 sc_prohibit_gettext_markup:
-	@prohibit='\<VIR_(WARN|DEBUG)0? *\(_\('				\
+	@prohibit='\<VIR_(WARN|DEBUG) *\(_\('				\
 	halt='do not mark these strings for translation'		\
 	  $(_sc_search_regexp)

diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
index 126003f..047a81f 100644
--- i/src/qemu/qemu_monitor_json.c
+++ w/src/qemu/qemu_monitor_json.c
@@ -2529,7 +2529,7 @@ int qemuMonitorJSONInjectNMI(qemuMonitorPtr mon)

     if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
         qemuMonitorCheckHMP(mon, "inject-nmi")) {
-        VIR_DEBUG0("inject-nmi command not found, trying HMP");
+        VIR_DEBUG("inject-nmi command not found, trying HMP");
         ret = qemuMonitorTextInjectNMI(mon);
     } else {
         ret = qemuMonitorJSONCheckError(cmd, reply);
diff --git i/src/util/event.c w/src/util/event.c
index cfaffc8..11f025b 100644
--- i/src/util/event.c
+++ w/src/util/event.c
@@ -145,7 +145,7 @@ void virEventRegisterImpl(virEventAddHandleFunc
addHandle,
  */
 int virEventRegisterDefaultImpl(void)
 {
-    VIR_DEBUG(" ");
+    VIR_DEBUG("registering default event implementation");

     virResetLastError();

@@ -185,7 +185,7 @@ int virEventRegisterDefaultImpl(void)
  */
 int virEventRunDefaultImpl(void)
 {
-    VIR_DEBUG(" ");
+    VIR_DEBUG("running default event implementation");
     virResetLastError();

     if (virEventPollRunOnce() < 0) {

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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