summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-06-01 12:26:07 +0200
committerThomas Haller <thaller@redhat.com>2018-06-01 12:26:07 +0200
commitb18c9e44ed2304b867aae833cd2d579e5c75cdf4 (patch)
tree65f69083961552eaacb7cfbe695d45314ee93a43
parenta1f1b13f4fa508cd94c641fd3e0ec0b9836b01b5 (diff)
downloadNetworkManager-b18c9e44ed2304b867aae833cd2d579e5c75cdf4.tar.gz
shared/trivial: add code comment to explain NMUtilsEnumValueInfo consistency rules
-rw-r--r--shared/nm-utils/nm-enum-utils.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-enum-utils.c b/shared/nm-utils/nm-enum-utils.c
index 023f8385ff..b83c42078e 100644
--- a/shared/nm-utils/nm-enum-utils.c
+++ b/shared/nm-utils/nm-enum-utils.c
@@ -64,9 +64,18 @@ _ASSERT_enum_values_info (GType type,
* And then, when actually running against a newer library version where
* @type knows the nick, we have this situation.
*
+ * Another reason for specifying a nick both in @value_infos and @type,
+ * is to specify an alias which is not used with highest preference. For
+ * example, if you add an alias "disabled" for "none" (both numerically
+ * equal), then the first alias in @value_infos will be preferred over
+ * the name from @type. So, to still use "none" as preferred name, you may
+ * explicitly specify the "none" alias in @value_infos before "disabled".
+ *
* However, what never is allowed, is to use a name (nick) to re-number
* the value. That is, if both @value_infos and @type contain a particular
* nick, their numeric values must agree as well.
+ * Allowing this, would be very confusing, because the name would have a different
+ * value from the regular GLib GEnum API.
*/
g_assert (enum_value->value == value_infos->value);
}