summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-11-30 11:37:21 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2018-11-30 16:59:55 +0100
commitfc8a8e46b924e4cc7866f6a0c376e94fcb69afcb (patch)
tree181af0f7611c4441bb55dc01df9f51680ee1fa63
parentd6e23a37b43f025073223c6126bc5ce5b68207bf (diff)
downloadNetworkManager-bg/conf-check-rh1541013.tar.gz
all: make use of NM_MAKE_STRV() macrobg/conf-check-rh1541013
-rw-r--r--libnm-core/nm-utils.c2
-rw-r--r--libnm-core/tests/test-setting.c11
-rw-r--r--src/devices/nm-device-private.h4
-rw-r--r--src/devices/nm-device.c6
-rw-r--r--src/tests/test-general.c69
-rw-r--r--src/tests/test-utils.c12
6 files changed, 55 insertions, 49 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 631d7aa00f..b70f784d54 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -67,7 +67,7 @@ struct IsoLangToEncodings
const char *const *encodings;
};
-#define LANG_ENCODINGS(l, ...) { .lang = l, .encodings = (const char *[]) { __VA_ARGS__, NULL }}
+#define LANG_ENCODINGS(l, ...) { .lang = l, .encodings = NM_MAKE_STRV (__VA_ARGS__), }
/* 5-letter language codes */
static const struct IsoLangToEncodings isoLangEntries5[] =
diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c
index 4e010feb6e..79c8257610 100644
--- a/libnm-core/tests/test-setting.c
+++ b/libnm-core/tests/test-setting.c
@@ -421,20 +421,17 @@ create_bond_connection (NMConnection **con, NMSettingBond **s_bond)
}
#define test_verify_options(exp, ...) \
- G_STMT_START { \
- const char *__opts[] = { __VA_ARGS__ , NULL }; \
- \
- _test_verify_options (__opts, exp); \
- } G_STMT_END
+ _test_verify_options (NM_MAKE_STRV (__VA_ARGS__), exp)
static void
-_test_verify_options (const char **options, gboolean expected_result)
+_test_verify_options (const char *const *options,
+ gboolean expected_result)
{
gs_unref_object NMConnection *con = NULL;
NMSettingBond *s_bond;
GError *error = NULL;
gboolean success;
- const char **option;
+ const char *const *option;
create_bond_connection (&con, &s_bond);
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index 1e19dbfbf8..d02d8c3b5d 100644
--- a/src/devices/nm-device-private.h
+++ b/src/devices/nm-device-private.h
@@ -147,9 +147,9 @@ void nm_device_commit_mtu (NMDevice *self);
)
gboolean _nm_device_hash_check_invalid_keys (GHashTable *hash, const char *setting_name,
- GError **error, const char **whitelist);
+ GError **error, const char *const*whitelist);
#define nm_device_hash_check_invalid_keys(hash, setting_name, error, ...) \
- _nm_device_hash_check_invalid_keys (hash, setting_name, error, ((const char *[]) { __VA_ARGS__, NULL }))
+ _nm_device_hash_check_invalid_keys (hash, setting_name, error, NM_MAKE_STRV (__VA_ARGS__))
gboolean nm_device_match_parent (NMDevice *device, const char *parent);
gboolean nm_device_match_parent_hwaddr (NMDevice *device,
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 3eeac921ef..57021e4b79 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -10763,8 +10763,10 @@ _cleanup_ip_pre (NMDevice *self, int addr_family, CleanupType cleanup_type)
}
gboolean
-_nm_device_hash_check_invalid_keys (GHashTable *hash, const char *setting_name,
- GError **error, const char **whitelist)
+_nm_device_hash_check_invalid_keys (GHashTable *hash,
+ const char *setting_name,
+ GError **error,
+ const char *const*whitelist)
{
guint found_whitelisted_keys = 0;
guint i;
diff --git a/src/tests/test-general.c b/src/tests/test-general.c
index e99158345d..16121facf0 100644
--- a/src/tests/test-general.c
+++ b/src/tests/test-general.c
@@ -1115,7 +1115,10 @@ _test_match_spec_device (const GSList *specs, const char *match_str)
}
static void
-_do_test_match_spec_device (const char *spec_str, const char **matches, const char **no_matches, const char **neg_matches)
+_do_test_match_spec_device (const char *spec_str,
+ const char *const *matches,
+ const char *const *no_matches,
+ const char *const *neg_matches)
{
GSList *specs, *specs_randperm = NULL, *specs_resplit, *specs_i, *specs_j;
guint i;
@@ -1187,98 +1190,96 @@ _do_test_match_spec_device (const char *spec_str, const char **matches, const ch
static void
test_match_spec_device (void)
{
-#define S(...) ((const char *[]) { __VA_ARGS__, NULL } )
_do_test_match_spec_device ("em1",
- S ("em1"),
+ NM_MAKE_STRV ("em1"),
NULL,
NULL);
_do_test_match_spec_device ("em1,em2",
- S ("em1", "em2"),
+ NM_MAKE_STRV ("em1", "em2"),
NULL,
NULL);
_do_test_match_spec_device ("em1,em2,interface-name:em2",
- S ("em1", "em2"),
+ NM_MAKE_STRV ("em1", "em2"),
NULL,
NULL);
_do_test_match_spec_device ("interface-name:em1",
- S ("em1"),
+ NM_MAKE_STRV ("em1"),
NULL,
NULL);
_do_test_match_spec_device ("interface-name:em*",
- S ("em", "em*", "em\\", "em\\*", "em\\1", "em\\11", "em\\2", "em1", "em11", "em2", "em3"),
+ NM_MAKE_STRV ("em", "em*", "em\\", "em\\*", "em\\1", "em\\11", "em\\2", "em1", "em11", "em2", "em3"),
NULL,
NULL);
_do_test_match_spec_device ("interface-name:em\\*",
- S ("em\\", "em\\*", "em\\1", "em\\11", "em\\2"),
+ NM_MAKE_STRV ("em\\", "em\\*", "em\\1", "em\\11", "em\\2"),
NULL,
NULL);
_do_test_match_spec_device ("interface-name:~em\\*",
- S ("em\\", "em\\*", "em\\1", "em\\11", "em\\2"),
+ NM_MAKE_STRV ("em\\", "em\\*", "em\\1", "em\\11", "em\\2"),
NULL,
NULL);
_do_test_match_spec_device ("except:*",
NULL,
- S (NULL),
- S ("a"));
+ NM_MAKE_STRV (NULL),
+ NM_MAKE_STRV ("a"));
_do_test_match_spec_device ("interface-name:=em*",
- S ("em*"),
+ NM_MAKE_STRV ("em*"),
NULL,
NULL);
_do_test_match_spec_device ("interface-name:em*,except:interface-name:em1*",
- S ("em", "em*", "em\\", "em\\*", "em\\1", "em\\11", "em\\2", "em2", "em3"),
+ NM_MAKE_STRV ("em", "em*", "em\\", "em\\*", "em\\1", "em\\11", "em\\2", "em2", "em3"),
NULL,
- S ("em1", "em11"));
+ NM_MAKE_STRV ("em1", "em11"));
_do_test_match_spec_device ("interface-name:em*,except:interface-name:=em*",
- S ("em", "em\\", "em\\*", "em\\1", "em\\11", "em\\2", "em1", "em11", "em2", "em3"),
+ NM_MAKE_STRV ("em", "em\\", "em\\*", "em\\1", "em\\11", "em\\2", "em1", "em11", "em2", "em3"),
NULL,
- S ("em*"));
+ NM_MAKE_STRV ("em*"));
_do_test_match_spec_device ("aa,bb,cc\\,dd,e,,",
- S ("aa", "bb", "cc,dd", "e"),
+ NM_MAKE_STRV ("aa", "bb", "cc,dd", "e"),
NULL,
NULL);
_do_test_match_spec_device ("aa;bb;cc\\;dd;e,;",
- S ("aa", "bb", "cc;dd", "e"),
+ NM_MAKE_STRV ("aa", "bb", "cc;dd", "e"),
NULL,
NULL);
_do_test_match_spec_device ("interface-name:em\\;1,em\\,2,\\,,\\\\,,em\\\\x",
- S ("em;1", "em,2", ",", "\\", "em\\x"),
+ NM_MAKE_STRV ("em;1", "em,2", ",", "\\", "em\\x"),
NULL,
NULL);
_do_test_match_spec_device ("\\s\\s,\\sinterface-name:a,\\s,",
- S (" ", " ", " interface-name:a"),
+ NM_MAKE_STRV (" ", " ", " interface-name:a"),
NULL,
NULL);
_do_test_match_spec_device (" aa ; bb ; cc\\;dd ;e , ; \t\\t , ",
- S ("aa", "bb", "cc;dd", "e", "\t"),
+ NM_MAKE_STRV ("aa", "bb", "cc;dd", "e", "\t"),
NULL,
NULL);
_do_test_match_spec_device ("s390-subchannels:0.0.1000\\,0.0.1001",
- S (MATCH_S390"0.0.1000", MATCH_S390"0.0.1000,deadbeef", MATCH_S390"0.0.1000,0.0.1001", MATCH_S390"0.0.1000,0.0.1002"),
- S (MATCH_S390"0.0.1001"),
+ NM_MAKE_STRV (MATCH_S390"0.0.1000", MATCH_S390"0.0.1000,deadbeef", MATCH_S390"0.0.1000,0.0.1001", MATCH_S390"0.0.1000,0.0.1002"),
+ NM_MAKE_STRV (MATCH_S390"0.0.1001"),
NULL);
_do_test_match_spec_device ("*,except:s390-subchannels:0.0.1000\\,0.0.1001",
NULL,
- S (NULL),
- S (MATCH_S390"0.0.1000", MATCH_S390"0.0.1000,deadbeef", MATCH_S390"0.0.1000,0.0.1001", MATCH_S390"0.0.1000,0.0.1002"));
+ NM_MAKE_STRV (NULL),
+ NM_MAKE_STRV (MATCH_S390"0.0.1000", MATCH_S390"0.0.1000,deadbeef", MATCH_S390"0.0.1000,0.0.1001", MATCH_S390"0.0.1000,0.0.1002"));
_do_test_match_spec_device ("driver:DRV",
- S (MATCH_DRIVER"DRV", MATCH_DRIVER"DRV|1.6"),
- S (MATCH_DRIVER"DR", MATCH_DRIVER"DR*"),
+ NM_MAKE_STRV (MATCH_DRIVER"DRV", MATCH_DRIVER"DRV|1.6"),
+ NM_MAKE_STRV (MATCH_DRIVER"DR", MATCH_DRIVER"DR*"),
NULL);
_do_test_match_spec_device ("driver:DRV//",
- S (MATCH_DRIVER"DRV/"),
- S (MATCH_DRIVER"DRV/|1.6", MATCH_DRIVER"DR", MATCH_DRIVER"DR*"),
+ NM_MAKE_STRV (MATCH_DRIVER"DRV/"),
+ NM_MAKE_STRV (MATCH_DRIVER"DRV/|1.6", MATCH_DRIVER"DR", MATCH_DRIVER"DR*"),
NULL);
_do_test_match_spec_device ("driver:DRV//*",
- S (MATCH_DRIVER"DRV/", MATCH_DRIVER"DRV/|1.6"),
- S (MATCH_DRIVER"DR", MATCH_DRIVER"DR*"),
+ NM_MAKE_STRV (MATCH_DRIVER"DRV/", MATCH_DRIVER"DRV/|1.6"),
+ NM_MAKE_STRV (MATCH_DRIVER"DR", MATCH_DRIVER"DR*"),
NULL);
_do_test_match_spec_device ("driver:DRV//1.5*",
- S (MATCH_DRIVER"DRV/|1.5", MATCH_DRIVER"DRV/|1.5.2"),
- S (MATCH_DRIVER"DRV/", MATCH_DRIVER"DRV/|1.6", MATCH_DRIVER"DR", MATCH_DRIVER"DR*"),
+ NM_MAKE_STRV (MATCH_DRIVER"DRV/|1.5", MATCH_DRIVER"DRV/|1.5.2"),
+ NM_MAKE_STRV (MATCH_DRIVER"DRV/", MATCH_DRIVER"DRV/|1.6", MATCH_DRIVER"DR", MATCH_DRIVER"DR*"),
NULL);
-#undef S
}
/*****************************************************************************/
diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c
index 16eb3aeccf..9572ec7a51 100644
--- a/src/tests/test-utils.c
+++ b/src/tests/test-utils.c
@@ -64,10 +64,10 @@ _do_test_hw_addr (NMUtilsStableType stable_type,
const char *ifname,
const char *current_mac_address,
const char *generate_mac_address_mask,
- const char **expected)
+ const char *const *expected)
{
gs_free char *generated = NULL;
- const char **e;
+ const char *const *e;
gboolean found = FALSE;
for (e = expected; *e; e++) {
@@ -95,7 +95,13 @@ _do_test_hw_addr (NMUtilsStableType stable_type,
g_assert (found);
}
#define do_test_hw_addr(stable_type, stable_id, secret_key, ifname, current_mac_address, generate_mac_address_mask, ...) \
- _do_test_hw_addr ((stable_type), (stable_id), (const guint8 *) ""secret_key"", NM_STRLEN (secret_key), (ifname), ""current_mac_address"", generate_mac_address_mask, (const char *[]) { __VA_ARGS__, NULL })
+ _do_test_hw_addr ((stable_type), \
+ (stable_id), \
+ (const guint8 *) ""secret_key"", \
+ NM_STRLEN (secret_key), (ifname), \
+ ""current_mac_address"", \
+ generate_mac_address_mask, \
+ NM_MAKE_STRV (__VA_ARGS__))
static void
test_hw_addr_gen_stable_eth (void)