[libvirt] [PATCHv2] maint: balance {} usage

Eric Blake eblake at redhat.com
Mon Mar 24 18:50:27 UTC 2014


Emacs gets lost when finding function boundaries when #ifdef
sections do not have balanced {}.

* libvirt-override.c (libvirt_PyString_Check): New define.
(virPyDictToTypedParams): Avoid unbalanced {} across ifdef.

Signed-off-by: Eric Blake <eblake at redhat.com>
---

v2: Hoisting #ifdefs outside of function bodies makes it nicer

 libvirt-override.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libvirt-override.c b/libvirt-override.c
index 2532400..6a85d24 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -4,7 +4,7 @@
  *           entry points where an automatically generated stub is
  *           unpractical
  *
- * Copyright (C) 2005, 2007-2013 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2014 Red Hat, Inc.
  *
  * Daniel Veillard <veillard at redhat.com>
  */
@@ -272,6 +272,12 @@ typedef struct {
 } virPyTypedParamsHint;
 typedef virPyTypedParamsHint *virPyTypedParamsHintPtr;

+# if PY_MAJOR_VERSION > 2
+#  define libvirt_PyString_Check PyUnicode_Check
+# else
+#  define libvirt_PyString_Check PyString_Check
+# endif
+
 /* Automatically convert dict into type parameters based on types reported
  * by python. All integer types are converted into LLONG (in case of a negative
  * value) or ULLONG (in case of a positive value). If you need different
@@ -321,11 +327,7 @@ virPyDictToTypedParams(PyObject *dict,
         }

         if (type == -1) {
-#if PY_MAJOR_VERSION > 2
-            if (PyUnicode_Check(value)) {
-#else
-            if (PyString_Check(value)) {
-#endif
+            if (libvirt_PyString_Check(value)) {
                 type = VIR_TYPED_PARAM_STRING;
             } else if (PyBool_Check(value)) {
                 type = VIR_TYPED_PARAM_BOOLEAN;
-- 
1.8.5.3




More information about the libvir-list mailing list