device: use empty string as drvname when devicetree label is absent
As we move to making the `label` property optional, we need to account for widespread use of `dev->name` in contexts where the pointer is not validated before it is dereferenced. Use an empty string instead of a null pointer when no label is provided. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
5b36a01a67
commit
28897df295
3 changed files with 3 additions and 3 deletions
|
@ -170,7 +170,7 @@ extern "C" {
|
|||
#define DEVICE_DT_DEFINE(node_id, init_fn, pm_control_fn, \
|
||||
data_ptr, cfg_ptr, level, prio, api_ptr) \
|
||||
Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
|
||||
DT_PROP_OR(node_id, label, NULL), init_fn, \
|
||||
DT_PROP_OR(node_id, label, ""), init_fn, \
|
||||
pm_control_fn, \
|
||||
data_ptr, cfg_ptr, level, prio, api_ptr)
|
||||
|
||||
|
|
|
@ -712,7 +712,7 @@ static inline bool net_eth_get_vlan_status(struct net_if *iface)
|
|||
#define ETH_NET_DEVICE_DT_DEFINE(node_id, init_fn, pm_control_fn, data, \
|
||||
cfg, prio, api, mtu) \
|
||||
Z_ETH_NET_DEVICE_INIT(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
|
||||
DT_PROP_OR(node_id, label, NULL), \
|
||||
DT_PROP_OR(node_id, label, ""), \
|
||||
init_fn, pm_control_fn, data, cfg, prio, \
|
||||
api, mtu)
|
||||
|
||||
|
|
|
@ -2269,7 +2269,7 @@ struct net_if_api {
|
|||
#define NET_DEVICE_DT_DEFINE(node_id, init_fn, pm_control_fn, data, cfg, \
|
||||
prio, api, l2, l2_ctx_type, mtu) \
|
||||
Z_NET_DEVICE_INIT(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
|
||||
DT_PROP_OR(node_id, label, NULL), init_fn, \
|
||||
DT_PROP_OR(node_id, label, ""), init_fn, \
|
||||
pm_control_fn, data, cfg, prio, api, l2, \
|
||||
l2_ctx_type, mtu)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue