[libvirt] [python PATCH] maint: balance {} usage

Emacs gets lost when finding function boundaries when #ifdef sections do not have balanced {}. * libvirt-override.c (virPyDictToTypedParams): Avoid unbalanced {} across ifdef. Signed-off-by: Eric Blake <eblake@redhat.com> --- This feels trivial, but it's also hacky enough that I'll wait for a review. libvirt-override.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index aecf25d..3a21bcc 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -321,10 +321,12 @@ virPyDictToTypedParams(PyObject *dict, } if (type == -1) { + if (false) { + /* hack to keep balanced {} */ #if PY_MAJOR_VERSION > 2 - if (PyUnicode_Check(value)) { + } else if (PyUnicode_Check(value)) { #else - if (PyString_Check(value)) { + } else if (PyString_Check(value)) { #endif type = VIR_TYPED_PARAM_STRING; } else if (PyBool_Check(value)) { -- 1.8.5.3

On 03/24/14 18:03, Eric Blake wrote:
Emacs gets lost when finding function boundaries when #ifdef sections do not have balanced {}.
* libvirt-override.c (virPyDictToTypedParams): Avoid unbalanced {} across ifdef.
Signed-off-by: Eric Blake <eblake@redhat.com> ---
This feels trivial, but it's also hacky enough that I'll wait for a review.
libvirt-override.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c index aecf25d..3a21bcc 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -321,10 +321,12 @@ virPyDictToTypedParams(PyObject *dict, }
if (type == -1) { + if (false) { + /* hack to keep balanced {} */ #if PY_MAJOR_VERSION > 2 - if (PyUnicode_Check(value)) { + } else if (PyUnicode_Check(value)) { #else - if (PyString_Check(value)) { + } else if (PyString_Check(value)) {
IMHO a little less hacky solution would be to break the coding style and move the opening curly brace after the #endif section and thus avoid the extra if statement and the comment
#endif
and still keep them balanced.
type = VIR_TYPED_PARAM_STRING; } else if (PyBool_Check(value)) {
Peter

On 03/24/2014 12:09 PM, Peter Krempa wrote:
On 03/24/14 18:03, Eric Blake wrote:
Emacs gets lost when finding function boundaries when #ifdef sections do not have balanced {}.
* libvirt-override.c (virPyDictToTypedParams): Avoid unbalanced {} across ifdef.
Signed-off-by: Eric Blake <eblake@redhat.com> ---
This feels trivial, but it's also hacky enough that I'll wait for a review.
IMHO a little less hacky solution would be to break the coding style and move the opening curly brace after the #endif section and thus avoid the extra if statement and the comment
Or even hoist the #ifdef outside of the function. I'll post a v2. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Peter Krempa