From 77faadfdd3d2d934f52d1d35b60e774c494d84b8 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 28 Sep 2021 09:33:30 +0200 Subject: 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. --- src/shared/netif-naming-scheme.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/shared/netif-naming-scheme.c') 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; -- cgit v1.2.3