netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] tipc: Return -EINVAL on error from addr2str() methods
@ 2024-10-08 14:24 Shigeru Yoshida
  2024-10-10  9:39 ` Paolo Abeni
  0 siblings, 1 reply; 2+ messages in thread
From: Shigeru Yoshida @ 2024-10-08 14:24 UTC (permalink / raw)
  To: jmaloy, ying.xue
  Cc: davem, edumazet, kuba, pabeni, tipc-discussion, netdev,
	linux-kernel, tung.q.nguyen, Shigeru Yoshida

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

Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
---
 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(-)

diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index cb0d185e06af..fa33b333fb0d 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -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;
diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c
index b9ad0434c3cd..8bda3aa78891 100644
--- a/net/tipc/ib_media.c
+++ b/net/tipc/ib_media.c
@@ -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);
 
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index 439f75539977..78fff7ad4b2f 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -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;
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] tipc: Return -EINVAL on error from addr2str() methods
  2024-10-08 14:24 [PATCH net-next] tipc: Return -EINVAL on error from addr2str() methods Shigeru Yoshida
@ 2024-10-10  9:39 ` Paolo Abeni
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Abeni @ 2024-10-10  9:39 UTC (permalink / raw)
  To: Shigeru Yoshida, jmaloy, ying.xue
  Cc: davem, edumazet, kuba, tipc-discussion, netdev, linux-kernel,
	tung.q.nguyen

On 10/8/24 16:24, Shigeru Yoshida wrote:
> The return value 1 on error of the addr2str() methods are not
> descriptive. Return -EINVAL instead.
> 
> Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>

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/20241009-doc-mc-clean-v2-1-e637b665fa81@kernel.org/

Thanks,

Paolo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-10  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 14:24 [PATCH net-next] tipc: Return -EINVAL on error from addr2str() methods Shigeru Yoshida
2024-10-10  9:39 ` Paolo Abeni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).