From: Eric Wong <bofh@yhbt.net>
To: raindrops-public@yhbt.net
Subject: [PATCH] linux_inet_diag: avoid errors for users compiling w/o assertions
Date: Sat, 30 Sep 2023 23:26:40 +0000 [thread overview]
Message-ID: <20230930232640.27806-1-bofh@yhbt.net> (raw)
We should warn gracefully when we hit IPv7+ or whatever...
---
ext/raindrops/linux_inet_diag.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c
index e4050cb..6d421e7 100644
--- a/ext/raindrops/linux_inet_diag.c
+++ b/ext/raindrops/linux_inet_diag.c
@@ -235,7 +235,9 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
break;
}
default:
- assert(0 && "unsupported address family, could that be IPv7?!");
+ fprintf(stderr, "unsupported .idiag_family: %u\n",
+ (unsigned)r->idiag_family);
+ return NULL; /* can't raise w/o GVL */
}
if (!inet_ntop(r->idiag_family, src, host, hostlen)) {
bug_warn_nogvl("BUG: inet_ntop: %s\n", strerror(errno));
@@ -255,7 +257,8 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
port = host + hostlen + 2;
break;
default:
- assert(0 && "unsupported address family, could that be IPv7?!");
+ assert(0 && "should never get here (returned above)");
+ abort();
}
n = snprintf(port, portlen, "%u", ntohs(r->id.idiag_sport));
@@ -300,12 +303,14 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
static void table_incr_active(st_table *table, struct inet_diag_msg *r)
{
struct listen_stats *stats = stats_for(table, r);
+ if (!stats) return;
++stats->active;
}
static void table_set_queued(st_table *table, struct inet_diag_msg *r)
{
struct listen_stats *stats = stats_for(table, r);
+ if (!stats) return;
stats->listener_p = 1;
stats->queued += r->idiag_rqueue;
}
next reply other threads:[~2023-09-30 23:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-30 23:26 Eric Wong [this message]
2024-03-24 0:26 ` [PATCH v2] linux_inet_diag: avoid errors for users compiling w/o assertions Eric Wong
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
List information: https://yhbt.net/raindrops/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230930232640.27806-1-bofh@yhbt.net \
--to=bofh@yhbt.net \
--cc=raindrops-public@yhbt.net \
/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.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/raindrops.git/
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 read-only IMAP folder(s) and NNTP newsgroup(s).