From: Shigeru Yoshida <syoshida@redhat.com>
To: jmaloy@redhat.com, ying.xue@windriver.com
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, tipc-discussion@lists.sourceforge.net,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
tung.q.nguyen@endava.com, Shigeru Yoshida <syoshida@redhat.com>
Subject: [PATCH net-next] tipc: Return -EINVAL on error from addr2str() methods
Date: Tue, 8 Oct 2024 23:24:42 +0900 [thread overview]
Message-ID: <20241008142442.652219-1-syoshida@redhat.com> (raw)
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
next reply other threads:[~2024-10-08 14:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 14:24 Shigeru Yoshida [this message]
2024-10-10 9:39 ` [PATCH net-next] tipc: Return -EINVAL on error from addr2str() methods Paolo Abeni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241008142442.652219-1-syoshida@redhat.com \
--to=syoshida@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jmaloy@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=tung.q.nguyen@endava.com \
--cc=ying.xue@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).