Commit fde9250c authored by Thomas Haller's avatar Thomas Haller Committed by Lubomir Rintel

libnm: mark NMVariantAttributeSpec pointers as const

This actually allows the compiler/linker to mark the memory as read-only and any
modification will cause a segmentation fault.

I would also think that it allows the compiler to put the structure directly
beside the outer constant array (in which this pointer is embedded). That is good
locality-wise.

(cherry picked from commit 4e3955e6)
parent b954ddc2
......@@ -1213,7 +1213,7 @@ nm_ip_route_set_attribute (NMIPRoute *route, const char *name, GVariant *value)
}
#define ATTR_SPEC_PTR(name, type, v4, v6, str_type) \
&(NMVariantAttributeSpec) { name, type, v4, v6, FALSE, FALSE, str_type }
&((const NMVariantAttributeSpec) { name, type, v4, v6, FALSE, FALSE, str_type })
static const NMVariantAttributeSpec * const ip_route_attribute_spec[] = {
ATTR_SPEC_PTR (NM_IP_ROUTE_ATTRIBUTE_TABLE, G_VARIANT_TYPE_UINT32, TRUE, TRUE, 0 ),
......
......@@ -366,7 +366,7 @@ nm_sriov_vf_get_attribute (const NMSriovVF *vf, const char *name)
}
#define SRIOV_ATTR_SPEC_PTR(name, type, str_type) \
&(NMVariantAttributeSpec) { name, type, FALSE, FALSE, FALSE, FALSE, str_type }
&((const NMVariantAttributeSpec) { name, type, FALSE, FALSE, FALSE, FALSE, str_type })
const NMVariantAttributeSpec * const _nm_sriov_vf_attribute_spec[] = {
SRIOV_ATTR_SPEC_PTR (NM_SRIOV_VF_ATTRIBUTE_MAC, G_VARIANT_TYPE_STRING, 'm'),
......
......@@ -2319,7 +2319,7 @@ fail:
}
#define TC_ATTR_SPEC_PTR(name, type, no_value, consumes_rest, str_type) \
&(NMVariantAttributeSpec) { name, type, FALSE, FALSE, no_value, consumes_rest, str_type }
&((const NMVariantAttributeSpec) { name, type, FALSE, FALSE, no_value, consumes_rest, str_type })
static const NMVariantAttributeSpec * const tc_object_attribute_spec[] = {
TC_ATTR_SPEC_PTR ("root", G_VARIANT_TYPE_BOOLEAN, TRUE, FALSE, 0 ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment