Skip to contentSkip to conversation

net/core: tidy up an error message

PATCH Superseded Qian Cai 3 participants 3 messages Dec 1, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Qian Cai

author
#0 lore raw

PATCH 1/1 net/core: tidy up an error message

netif_napi_add() could report an error like this below due to it allows to pass a format string for wildcarding before calling dev_get_valid_name(),

"netif_napi_add() called with weight 256 on device eth%d"

For example, hns_enet_drv module does this.

hns_nic_try_get_ae
hns_nic_init_ring_data
netif_napi_add
register_netdev
dev_get_valid_name

Hence, make it a bit more human-readable.

---
 net/core/dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/dev.c +2 -1
index ddc551f24ba2..bbd7cdbbbebd 100644
@@ -6205,7 +6205,8 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
 	napi->poll = poll;
 	if (weight > NAPI_POLL_WEIGHT)
 		pr_err_once("netif_napi_add() called with weight %d on device %s\n",
-			    weight, dev->name);
+			    weight,
+			    !strchr(dev->name, '%') ? dev->name : "unknown");
 	napi->weight = weight;
 	list_add(&napi->dev_list, &dev->napi_list);
 	napi->dev = dev;
Signature · 1 line
2.17.2 (Apple Git-113)
#1 lore raw
Quoted 8 lines · Qian Cai

netif_napi_add() could report an error like this below due to it allows to pass a format string for wildcarding before calling dev_get_valid_name(),

"netif_napi_add() called with weight 256 on device eth%d"

For example, hns_enet_drv module does this.

Quoted 7 lines

hns_nic_try_get_ae
hns_nic_init_ring_data
netif_napi_add
register_netdev
dev_get_valid_name

Hence, make it a bit more human-readable.

[]

net/core/dev.c

Quoted 1 line
net/core/dev.c +0 -0

[]

net/core/dev.c void netif_napi_add(struct net_device *dev, struct napi_struct *napi, · line 6209

Quoted 7 lines
net/core/dev.c +2 -1
@@ -6205,7 +6205,8 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
 	napi->poll = poll;
 	if (weight > NAPI_POLL_WEIGHT)
 		pr_err_once("netif_napi_add() called with weight %d on device %s\n",
-			    weight, dev->name);
+			    weight,
+			    !strchr(dev->name, '%') ? dev->name : "unknown");

perhaps instead use netdev_err_once