[PATCHv2] maint: balance {} usage

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

 



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@xxxxxxxxxx>
---

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@xxxxxxxxxx>
  */
@@ -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

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