[network-manager-openvpn] properties: cleanup compatibility wrapper for nm_utils_is_valid_iface_name()



commit a9d4268bc79fa2a87238eb2902c47662c6bb64b4
Author: Thomas Haller <thaller redhat com>
Date:   Wed Sep 20 17:30:06 2017 +0200

    properties: cleanup compatibility wrapper for nm_utils_is_valid_iface_name()
    
    libnm deprecated nm_utils_iface_valid_name() for nm_utils_is_valid_iface_name().
    In hindsight, that was a mistake because there wasn't really anything wrong
    with the existing function which requires to discourage it's use.
    
    Anyway, so to build the same code against libnm and libnm-glib, we need to
    add a compatibility wrapper *sigh*.
    
    It is wrong that the nm_utils_is_valid_iface_name() compatiblity macro has
    an output argument @e, which is silently dropped. It means, when building
    against libnm-glib, the compatiblity wrapper behaves differently. That
    would lead to a crash when somebody tried to make use of the error
    output argument.
    
    Instead, the macro shall have no error argument. At that point, it shall
    also not have the same name as nm_utils_is_valid_iface_name(), to avoid
    confusion.

 properties/auth-helpers.c |    5 +++--
 shared/nm-default.h       |    4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/properties/auth-helpers.c b/properties/auth-helpers.c
index 6067548..f9babfb 100644
--- a/properties/auth-helpers.c
+++ b/properties/auth-helpers.c
@@ -34,7 +34,6 @@
 #include <errno.h>
 
 #ifdef NM_VPN_OLD
-#define nm_utils_is_valid_iface_name(n,e) nm_utils_iface_valid_name(n)
 #include <nm-cert-chooser.h>
 #else
 #include <nma-cert-chooser.h>
@@ -1377,7 +1376,9 @@ device_name_changed_cb (GtkEntry *entry,
        entry_text = gtk_editable_get_chars (editable, 0, -1);
 
        /* Change cell's background to red if the value is invalid */
-       if (entry_sensitive && entry_text[0] != '\0' && !nm_utils_is_valid_iface_name (entry_text, NULL)) {
+       if (   entry_sensitive
+           && entry_text[0] != '\0'
+           && !_nm_utils_is_valid_iface_name (entry_text)) {
                widget_set_error (GTK_WIDGET (editable));
                gtk_widget_set_sensitive (ok_button, FALSE);
        } else {
diff --git a/shared/nm-default.h b/shared/nm-default.h
index 1476f5d..4aeb62f 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -88,6 +88,8 @@
 #define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE   NM_SETTING_VPN_ERROR_UNKNOWN
 #define NMV_EDITOR_PLUGIN_ERROR_FILE_INVALID        NM_SETTING_VPN_ERROR_UNKNOWN
 
+#define _nm_utils_is_valid_iface_name(n)            nm_utils_iface_valid_name(n)
+
 #else /* !NM_VPN_OLD */
 
 #include <NetworkManager.h>
@@ -100,6 +102,8 @@
 #define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE   NM_CONNECTION_ERROR_FAILED
 #define NMV_EDITOR_PLUGIN_ERROR_FILE_INVALID        NM_CONNECTION_ERROR_FAILED
 
+#define _nm_utils_is_valid_iface_name(n)            nm_utils_is_valid_iface_name(n, NULL)
+
 #endif /* NM_VPN_OLD */
 
 /*****************************************************************************/


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