summaryrefslogtreecommitdiff
path: root/src/shared/netif-naming-scheme.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-09-28 09:33:30 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-09-28 14:22:37 +0200
commit77faadfdd3d2d934f52d1d35b60e774c494d84b8 (patch)
tree2f5f066dccd84fcf7ec1c5256cc4022f4b2bdc4d /src/shared/netif-naming-scheme.c
parentacaa6368663a8972e3722751bd67bb1e0b3f272f (diff)
downloadsystemd-77faadfdd3d2d934f52d1d35b60e774c494d84b8.tar.gz
meson: drop the list of valid net naming schemes
We used 'combo' type for the scheme list. For a while we forgot to add new names, and recently aa0a23ec86 added v241, v243, v245, and v247. I want to allow defining new values during configuration, which means that we can't use meson to verify the list of options. So any value is allowed, but then two tests are added: one that will fail compilation if some invalid name is given (other than "latest"), and one that converts DEFAULT_NET_NAMING_SCHEME to a NamingScheme pointer.
Diffstat (limited to 'src/shared/netif-naming-scheme.c')
-rw-r--r--src/shared/netif-naming-scheme.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/shared/netif-naming-scheme.c b/src/shared/netif-naming-scheme.c
index 0a80931b0f..287a942014 100644
--- a/src/shared/netif-naming-scheme.c
+++ b/src/shared/netif-naming-scheme.c
@@ -5,6 +5,13 @@
#include "proc-cmdline.h"
#include "string-util.h"
+#ifdef _DEFAULT_NET_NAMING_SCHEME_TEST
+/* The primary purpose of this check is to verify that _DEFAULT_NET_NAMING_SCHEME_TEST
+ * is a valid identifier. If an invalid name is given during configuration, this will
+ * fail with a name error. */
+assert_cc(_DEFAULT_NET_NAMING_SCHEME_TEST >= 0);
+#endif
+
static const NamingScheme naming_schemes[] = {
{ "v238", NAMING_V238 },
{ "v239", NAMING_V239 },
@@ -15,10 +22,9 @@ static const NamingScheme naming_schemes[] = {
{ "v247", NAMING_V247 },
{ "v249", NAMING_V249 },
/* … add more schemes here, as the logic to name devices is updated … */
- /* also remember to update the list of options in meson_options.txt */
};
-static const NamingScheme* naming_scheme_from_name(const char *name) {
+const NamingScheme* naming_scheme_from_name(const char *name) {
if (streq(name, "latest"))
return naming_schemes + ELEMENTSOF(naming_schemes) - 1;