summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-11-13 14:39:57 +0100
committerThomas Haller <thaller@redhat.com>2016-11-13 15:06:57 +0100
commit13a95c363c91666d5702f6cc4c861157130f65fc (patch)
tree8b9f3dd1ad6778940e802eb50c580ef8fab9a86c
parenta791a9aa4b2b71436c4c31341689fec510c4ea8e (diff)
downloadNetworkManager-13a95c363c91666d5702f6cc4c861157130f65fc.tar.gz
device: drop factory-no-default global arrays
On some architectures, it seems we don't properly expose the symbol of these static variables from NetworkManager binary. Just avoid that and don't instead use a static array inside the device plugin itself. While at it, make the arrays all const, which possibly allows the linker to put those symbols in the read-only section.
-rw-r--r--src/NetworkManager.ver-orig2
-rw-r--r--src/devices/nm-device-factory.c23
-rw-r--r--src/devices/nm-device-factory.h28
3 files changed, 20 insertions, 33 deletions
diff --git a/src/NetworkManager.ver-orig b/src/NetworkManager.ver-orig
index 3d8690431b..08d5c6e4ec 100644
--- a/src/NetworkManager.ver-orig
+++ b/src/NetworkManager.ver-orig
@@ -5,8 +5,6 @@ global:
_nm_dbus_error_has_name;
_nm_dbus_proxy_call_finish;
_nm_dbus_signal_connect_data;
- _nm_device_factory_no_default_links;
- _nm_device_factory_no_default_settings;
_nm_exported_object_clear_and_unexport;
_nm_log_impl;
_nm_logging_enabled_state;
diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c
index 1f65300861..87f60a716a 100644
--- a/src/devices/nm-device-factory.c
+++ b/src/devices/nm-device-factory.c
@@ -33,11 +33,6 @@
/*****************************************************************************/
-const NMLinkType _nm_device_factory_no_default_links[] = { NM_LINK_TYPE_NONE };
-const char *_nm_device_factory_no_default_settings[] = { NULL };
-
-/*****************************************************************************/
-
enum {
DEVICE_ADDED,
COMPONENT_ADDED,
@@ -65,18 +60,10 @@ nm_device_factory_emit_component_added (NMDeviceFactory *factory, GObject *compo
void
nm_device_factory_get_supported_types (NMDeviceFactory *factory,
const NMLinkType **out_link_types,
- const char ***out_setting_types)
+ const char *const**out_setting_types)
{
- const NMLinkType *link_types_fallback;
- const char **setting_types_fallback;
-
g_return_if_fail (NM_IS_DEVICE_FACTORY (factory));
- if (!out_link_types)
- out_link_types = &link_types_fallback;
- if (!out_setting_types)
- out_setting_types = &setting_types_fallback;
-
NM_DEVICE_FACTORY_GET_CLASS (factory)->get_supported_types (factory,
out_link_types,
out_setting_types);
@@ -101,7 +88,7 @@ nm_device_factory_create_device (NMDeviceFactory *factory,
{
NMDeviceFactoryClass *klass;
const NMLinkType *link_types = NULL;
- const char **setting_types = NULL;
+ const char *const*setting_types = NULL;
int i;
NMDevice *device;
gboolean ignore = FALSE;
@@ -266,7 +253,7 @@ _cleanup (void)
static NMDeviceFactory *
find_factory (const NMLinkType *needle_link_types,
- const char **needle_setting_types)
+ const char *const*needle_setting_types)
{
NMDeviceFactory *found;
guint i;
@@ -305,7 +292,7 @@ nm_device_factory_manager_find_factory_for_link_type (NMLinkType link_type)
NMDeviceFactory *
nm_device_factory_manager_find_factory_for_connection (NMConnection *connection)
{
- const char *stypes[2] = { nm_connection_get_connection_type (connection), NULL };
+ const char *const stypes[2] = { nm_connection_get_connection_type (connection), NULL };
g_assert (stypes[0]);
return find_factory (NULL, stypes);
@@ -442,7 +429,7 @@ _add_factory (NMDeviceFactory *factory,
{
NMDeviceFactory *found = NULL;
const NMLinkType *link_types = NULL;
- const char **setting_types = NULL;
+ const char *const*setting_types = NULL;
int i;
g_return_val_if_fail (factories_by_link, FALSE);
diff --git a/src/devices/nm-device-factory.h b/src/devices/nm-device-factory.h
index 2faaad9df6..ff105da712 100644
--- a/src/devices/nm-device-factory.h
+++ b/src/devices/nm-device-factory.h
@@ -60,7 +60,7 @@ typedef struct {
*/
void (*get_supported_types) (NMDeviceFactory *factory,
const NMLinkType **out_link_types,
- const char ***out_setting_types);
+ const char *const**out_setting_types);
/**
* start:
@@ -176,7 +176,7 @@ typedef NMDeviceFactory * (*NMDeviceFactoryCreateFunc) (GError **error);
void nm_device_factory_get_supported_types (NMDeviceFactory *factory,
const NMLinkType **out_link_types,
- const char ***out_setting_types);
+ const char *const**out_setting_types);
const char *nm_device_factory_get_connection_parent (NMDeviceFactory *factory,
NMConnection *connection);
@@ -200,25 +200,27 @@ gboolean nm_device_factory_emit_component_added (NMDeviceFactory *factory,
GObject *component);
#define NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(...) \
- { static const NMLinkType _df_links[] = { __VA_ARGS__, NM_LINK_TYPE_NONE }; *out_link_types = _df_links; }
+ { static NMLinkType const _link_types_declared[] = { __VA_ARGS__, NM_LINK_TYPE_NONE }; _link_types = _link_types_declared; }
#define NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(...) \
- { static const char *_df_settings[] = { __VA_ARGS__, NULL }; *out_setting_types = _df_settings; }
-
-extern const NMLinkType _nm_device_factory_no_default_links[];
-extern const char *_nm_device_factory_no_default_settings[];
+ { static const char *const _setting_types_declared[] = { __VA_ARGS__, NULL }; _setting_types = _setting_types_declared; }
#define NM_DEVICE_FACTORY_DECLARE_TYPES(...) \
static void \
get_supported_types (NMDeviceFactory *factory, \
const NMLinkType **out_link_types, \
- const char ***out_setting_types) \
+ const char *const**out_setting_types) \
{ \
- *out_link_types = _nm_device_factory_no_default_links; \
- *out_setting_types = _nm_device_factory_no_default_settings; \
- \
+ static NMLinkType const _link_types_null[1] = { NM_LINK_TYPE_NONE }; \
+ static const char *const _setting_types_null[1] = { NULL }; \
+ \
+ const NMLinkType *_link_types = _link_types_null; \
+ const char *const*_setting_types = _setting_types_null; \
+ \
{ __VA_ARGS__; } \
- } \
- \
+ \
+ NM_SET_OUT (out_link_types, _link_types); \
+ NM_SET_OUT (out_setting_types, _setting_types); \
+ }
/**************************************************************************
* INTERNAL DEVICE FACTORY FUNCTIONS - devices provided by plugins should