Skip to contentSkip to conversation

tipc: Return -EINVAL on error from addr2str() methods

PATCH In review Shigeru Yoshida 2 participants 2 messages Oct 8, 2024 – Oct 10, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tipc: Return -EINVAL on error from addr2str() methods

The return value 1 on error of the addr2str() methods are not descriptive. Return -EINVAL instead.

---
 net/tipc/eth_media.c | 2 +-
 net/tipc/ib_media.c  | 2 +-
 net/tipc/udp_media.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
net/tipc/eth_media.c +1 -1
index cb0d185e06af..fa33b333fb0d 100644
@@ -42,7 +42,7 @@ static int tipc_eth_addr2str(struct tipc_media_addr *addr,
 			     char *strbuf, int bufsz)
 {
 	if (bufsz < 18)	/* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */
-		return 1;
+		return -EINVAL;
 
 	sprintf(strbuf, "%pM", addr->value);
 	return 0;
net/tipc/ib_media.c +1 -1
index b9ad0434c3cd..8bda3aa78891 100644
@@ -49,7 +49,7 @@ static int tipc_ib_addr2str(struct tipc_media_addr *a, char *str_buf,
 			    int str_size)
 {
 	if (str_size < 60)	/* 60 = 19 * strlen("xx:") + strlen("xx\0") */
-		return 1;
+		return -EINVAL;
 
 	sprintf(str_buf, "%20phC", a->value);
 
net/tipc/udp_media.c +1 -1
index 439f75539977..78fff7ad4b2f 100644
@@ -137,7 +137,7 @@ static int tipc_udp_addr2str(struct tipc_media_addr *a, char *buf, int size)
 		snprintf(buf, size, "%pI6:%u", &ua->ipv6, ntohs(ua->port));
 	else {
 		pr_err("Invalid UDP media address\n");
-		return 1;
+		return -EINVAL;
 	}
 
 	return 0;
Signature · 1 line
2.46.0
maintainer
#1 lore raw
Quoted 4 lines · Shigeru Yoshida

The return value 1 on error of the addr2str() methods are not descriptive. Return -EINVAL instead.

I'm sorry if I gave conflicting advice in the past, but I now think this patch falls under the 'small cleanup patches' category we are actively discouraging outside the scope of a wider (functional) change:

https://lore.kernel.org/netdev/[email protected]/

Thanks,

Paolo