summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2022-11-02 23:30:56 +0100
committerLubomir Rintel <lkundrak@v3.sk>2022-11-03 15:41:35 +0100
commitd9551bbc6894ca83cf46df7e5eb4bf7eea0d2cfd (patch)
tree46bce104f39c07fd9e582f8467aeb13c4348163b
parent941e8b70f8b187ecc3bc5bb97f1ab60aef10a452 (diff)
downloadNetworkManager-lr/sad-gir-scanner.tar.gz
nm-setting: mangle public constant to make g-ir-scanner happylr/sad-gir-scanner
Some versions of g-ir-scanner's C parser silently coerce unrecognized symbols into zeroes [1]. Let's avoid that so that we don't end up with wrong constants in our Gir data. [1] https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/366 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1446
-rw-r--r--src/libnm-core-impl/nm-setting.c6
-rw-r--r--src/libnm-core-public/nm-setting.h13
2 files changed, 16 insertions, 3 deletions
diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c
index 045c703b23..dd4cb8f531 100644
--- a/src/libnm-core-impl/nm-setting.c
+++ b/src/libnm-core-impl/nm-setting.c
@@ -16,6 +16,12 @@
#include "nm-utils-private.h"
#include "nm-utils.h"
+/* We rely on this in src/libnm-core-public/nm-setting.h */
+G_STATIC_ASSERT(G_PARAM_USER_SHIFT == 8);
+G_STATIC_ASSERT(NM_SETTING_PARAM_REQUIRED, (1 << (1 + G_PARAM_USER_SHIFT)));
+G_STATIC_ASSERT(NM_SETTING_PARAM_SECRET, (1 << (2 + G_PARAM_USER_SHIFT)));
+G_STATIC_ASSERT(NM_SETTING_PARAM_FUZZY_IGNORE, (1 << (3 + G_PARAM_USER_SHIFT)));
+
/**
* SECTION:nm-setting
* @short_description: Describes related configuration information
diff --git a/src/libnm-core-public/nm-setting.h b/src/libnm-core-public/nm-setting.h
index ee2076c362..578231cba5 100644
--- a/src/libnm-core-public/nm-setting.h
+++ b/src/libnm-core-public/nm-setting.h
@@ -23,16 +23,23 @@ G_BEGIN_DECLS
#define NM_SETTING_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_SETTING, NMSettingClass))
+/*
+ * The literals are used below (as opposed to e.g.
+ * (1 << (1 + G_PARAM_USER_SHIFT))), because g-ir-scanner sometimes gets
+ * confused by unknown tokens and silently treats them as zero:
+ * https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/366
+ */
+
/* The property of the #NMSetting is required for the setting to be valid */
-#define NM_SETTING_PARAM_REQUIRED (1 << (1 + G_PARAM_USER_SHIFT))
+#define NM_SETTING_PARAM_REQUIRED 0x100
/* The property of the #NMSetting is a secret */
-#define NM_SETTING_PARAM_SECRET (1 << (2 + G_PARAM_USER_SHIFT))
+#define NM_SETTING_PARAM_SECRET 0x200
/* The property of the #NMSetting should be ignored during comparisons that
* use the %NM_SETTING_COMPARE_FLAG_FUZZY flag.
*/
-#define NM_SETTING_PARAM_FUZZY_IGNORE (1 << (3 + G_PARAM_USER_SHIFT))
+#define NM_SETTING_PARAM_FUZZY_IGNORE 0x400
/* Note: all non-glib GParamFlags bits are reserved by NetworkManager */