From c884d4d347e90c77a71dffb48c521b551f1ec912 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 7 Nov 2022 08:33:01 +0100 Subject: [PATCH] nm-setting: fix static assertions for NM_SETTING_PARAM_* flags and numeric values - the static assertions were wrong, there was a "," instead of "==". - the numeric values were wrong, as shown by the static assertions. - move the code comment to the implementation. This does not seem relevant for the library user and should not be in the public header. Fixes: 08e845f651d4 ('nm-setting: mangle public constant to make g-ir-scanner happy') --- src/libnm-core-impl/nm-setting.c | 20 ++++++++++++++------ src/libnm-core-public/nm-setting.h | 13 +++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index dd4cb8f53..1858af7ca 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -16,12 +16,6 @@ #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 @@ -36,6 +30,20 @@ G_STATIC_ASSERT(NM_SETTING_PARAM_FUZZY_IGNORE, (1 << (3 + G_PARAM_USER_SHIFT))); /*****************************************************************************/ +/* + * We use literal numbers in the header (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 + */ + +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))); + +/*****************************************************************************/ + typedef struct { GHashTable *hash; const char **names; diff --git a/src/libnm-core-public/nm-setting.h b/src/libnm-core-public/nm-setting.h index 578231cba..5c5b621cd 100644 --- a/src/libnm-core-public/nm-setting.h +++ b/src/libnm-core-public/nm-setting.h @@ -23,23 +23,16 @@ 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 0x100 +#define NM_SETTING_PARAM_REQUIRED 0x200 /* The property of the #NMSetting is a secret */ -#define NM_SETTING_PARAM_SECRET 0x200 +#define NM_SETTING_PARAM_SECRET 0x400 /* 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 0x400 +#define NM_SETTING_PARAM_FUZZY_IGNORE 0x800 /* Note: all non-glib GParamFlags bits are reserved by NetworkManager */