raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <bofh@yhbt.net>
To: raindrops-public@yhbt.net
Subject: [PATCH v2] linux_inet_diag: avoid errors for users compiling w/o assertions
Date: Sun, 24 Mar 2024 00:26:53 +0000	[thread overview]
Message-ID: <20240324002653.M350077@dcvr> (raw)
In-Reply-To: <20230930232640.27806-1-bofh@yhbt.net>

We should warn gracefully when we hit IPv7+ or whatever...
---
 Rebased against khashl changes

 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 d0638d7..058936b 100644
--- a/ext/raindrops/linux_inet_diag.c
+++ b/ext/raindrops/linux_inet_diag.c
@@ -208,7 +208,9 @@ static struct listen_stats *stats_for(addr2stats *a2s, 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));
@@ -228,7 +230,8 @@ static struct listen_stats *stats_for(addr2stats *a2s, 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));
@@ -278,12 +281,14 @@ static struct listen_stats *stats_for(addr2stats *a2s, struct inet_diag_msg *r)
 static void table_incr_active(addr2stats *a2s, struct inet_diag_msg *r)
 {
 	struct listen_stats *stats = stats_for(a2s, r);
+	if (!stats) return;
 	++stats->active;
 }
 
 static void table_set_queued(addr2stats *a2s, struct inet_diag_msg *r)
 {
 	struct listen_stats *stats = stats_for(a2s, r);
+	if (!stats) return;
 	stats->listener_p = 1;
 	stats->queued += r->idiag_rqueue;
 }

      reply	other threads:[~2024-03-24  0:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-30 23:26 [PATCH] linux_inet_diag: avoid errors for users compiling w/o assertions Eric Wong
2024-03-24  0:26 ` Eric Wong [this message]

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=20240324002653.M350077@dcvr \
    --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).