mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 18:10:08 +01:00
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.
This commit is contained in:
parent
cc9f071676
commit
4e3955e6dd
3 changed files with 3 additions and 3 deletions
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -2318,7 +2318,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 ),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue