raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / Atom feed
From: Eric Wong <e@80x24.org>
To: raindrops-public@bogomips.org
Subject: [PATCH] linux_inet_diag: fix Wshorten-64-to-32 warnings
Date: Wed, 14 Jan 2015 01:39:38 +0000
Message-ID: <1421199578-8222-1-git-send-email-e@80x24.org> (raw)

POSIX and glibc 2.2+ declare the hostlen and servlen
args of getnameinfo(3) to be socklen_t, not size_t,
so favor socklen_t for those calculations.

While we're at it, nlmsg_len is u32, too, so cast it
as such to avoid the warning.

Tested on clang version 3.5-1ubuntu1 on x86-64
---
 ext/raindrops/linux_inet_diag.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c
index 5f21295..35bb127 100644
--- a/ext/raindrops/linux_inet_diag.c
+++ b/ext/raindrops/linux_inet_diag.c
@@ -232,8 +232,8 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
 	char *key, *port, *old_key;
 	size_t alloca_len;
 	struct listen_stats *stats;
-	size_t keylen;
-	size_t portlen = sizeof("65535");
+	socklen_t keylen;
+	socklen_t portlen = (socklen_t)sizeof("65535");
 	union any_addr sa;
 	socklen_t len = sizeof(struct sockaddr_storage);
 	int rc;
@@ -274,8 +274,8 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
 		*key = 0;
 	}
 
-	keylen = strlen(key);
-	portlen = strlen(port);
+	keylen = (socklen_t)strlen(key);
+	portlen = (socklen_t)strlen(port);
 
 	switch (sa.ss.ss_family) {
 	case AF_INET:
@@ -396,8 +396,8 @@ static void prep_diag_args(
 
 	nladdr->nl_family = AF_NETLINK;
 
-	req->nlh.nlmsg_len = sizeof(struct diag_req) +
-	                    RTA_LENGTH(args->iov[2].iov_len);
+	req->nlh.nlmsg_len = (unsigned int)(sizeof(struct diag_req) +
+	                    RTA_LENGTH(args->iov[2].iov_len));
 	req->nlh.nlmsg_type = TCPDIAG_GETSOCK;
 	req->nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
 	req->nlh.nlmsg_pid = getpid();
-- 
EW


                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically 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=1421199578-8222-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=raindrops-public@bogomips.org \
    /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

raindrops RubyGem user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://yhbt.net/raindrops-public
	git clone --mirror http://ou63pmih66umazou.onion/raindrops-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.raindrops
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.raindrops

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git