diff options
author | Thomas Haller <thaller@redhat.com> | 2020-10-27 14:46:49 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-10-27 17:04:21 +0100 |
commit | 0438820805386268d43e25a7d76824ef931a98ad (patch) | |
tree | 57de3a7c5d272b3d869a6499e47cfeb988692cb5 | |
parent | 379dde287cafd383024495b8fa83f2fbe3b5af07 (diff) | |
download | NetworkManager-0438820805386268d43e25a7d76824ef931a98ad.tar.gz |
device: use static array for modules in share_init()
A static const array is marked as immutable by the linker.
This is what we want, because there is no need to change this
array.
Also, the tailing %NULL entry is not necessary, we can just
iterate over the fixed number of elements.
-rw-r--r-- | src/devices/nm-device.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 06693b4f70..dfd106486b 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -11536,17 +11536,16 @@ activate_stage4_ip_config_timeout_6(NMDevice *self) static gboolean share_init(NMDevice *self, GError **error) { - char * modules[] = {"ip_tables", - "iptable_nat", - "nf_nat_ftp", - "nf_nat_irc", - "nf_nat_sip", - "nf_nat_tftp", - "nf_nat_pptp", - "nf_nat_h323", - NULL}; - char **iter; - int errsv; + const char *const modules[] = {"ip_tables", + "iptable_nat", + "nf_nat_ftp", + "nf_nat_irc", + "nf_nat_sip", + "nf_nat_tftp", + "nf_nat_pptp", + "nf_nat_h323"}; + guint i; + int errsv; if (nm_platform_sysctl_get_int32(nm_device_get_platform(self), NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv4/ip_forward"), @@ -11584,8 +11583,8 @@ share_init(NMDevice *self, GError **error) nm_strerror_native(errsv)); } - for (iter = modules; *iter; iter++) - nm_utils_modprobe(NULL, FALSE, *iter, NULL); + for (i = 0; i < G_N_ELEMENTS(modules); i++) + nm_utils_modprobe(NULL, FALSE, modules[i], NULL); return TRUE; } |