Git development
 help / color / mirror / Atom feed
From: "Gary V. Vaughan" <git@mlists.thewrittenword.com>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, Erik Faye-Lund <kusmabite@gmail.com>
Subject: [PATCH 5/5] struct sockaddr_storage->ss_family is not portable
Date: Thu, 11 Mar 2010 16:37:15 +0000	[thread overview]
Message-ID: <20100311163715.GE7877@thor.il.thewrittenword.com> (raw)

Many of our supported platforms do not have this declaration, for
example solaris2.6 thru 2.7.  Lack of ss_family implies no IPV6
support, so we can wrap all the ss_family references in an ifndef
NO_IPV6, and assume sockaddr_in otherwise.

Actually, the test for setting NO_IPV6 at configure time is still
too optimistic and I have to manually pass '-DNO_IPV6' in CPPFLAGS
at build time on aix-5.2.0.0 and earlier, and irix-6.5 and older
for them to pick up the right branch.
---
 daemon.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/daemon.c b/daemon.c
index 6bc1c23..c9ea500 100644
--- a/daemon.c
+++ b/daemon.c
@@ -591,17 +591,23 @@ static int execute(struct sockaddr *addr)
 static int addrcmp(const struct sockaddr_storage *s1,
     const struct sockaddr_storage *s2)
 {
+#ifndef NO_IPV6
 	if (s1->ss_family != s2->ss_family)
 		return s1->ss_family - s2->ss_family;
 	if (s1->ss_family == AF_INET)
 		return memcmp(&((struct sockaddr_in *)s1)->sin_addr,
 		    &((struct sockaddr_in *)s2)->sin_addr,
 		    sizeof(struct in_addr));
-#ifndef NO_IPV6
 	if (s1->ss_family == AF_INET6)
 		return memcmp(&((struct sockaddr_in6 *)s1)->sin6_addr,
 		    &((struct sockaddr_in6 *)s2)->sin6_addr,
 		    sizeof(struct in6_addr));
+#else
+	/* Assume AF_INET or equivalent for the likes of Solaris 2.7,
+	   HP/UX 11.00 and others do not implement ss_family */
+	return memcmp(&((struct sockaddr_in *)s1)->sin_addr,
+	    &((struct sockaddr_in *)s2)->sin_addr,
+	    sizeof(struct in_addr));
 #endif
 	return 0;
 }
-- 
1.7.0.2

-- 
Gary V. Vaughan (gary@thewrittenword.com)

             reply	other threads:[~2010-03-11 16:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-11 16:37 Gary V. Vaughan [this message]
2010-03-11 16:40 ` [PATCH 5/5] struct sockaddr_storage->ss_family is not portable Martin Storsjö
2010-03-12  4:56   ` Gary V. Vaughan
2010-03-12  7:24     ` Martin Storsjö
2010-03-15 21:03       ` [PATCH] daemon.c: avoid accessing ss_family member of struct sockaddr_storage Brandon Casey
2010-03-15 21:29         ` Jeff King
2010-03-15 21:41           ` Martin Storsjö
2010-03-15 21:42           ` Brandon Casey
2010-04-25  8:37             ` Gary V. Vaughan
2010-03-15 21:37         ` Martin Storsjö
2010-03-15 22:10           ` [PATCH v2] " Brandon Casey
2010-03-16  7:52             ` Martin Storsjö
2010-04-25  8:36       ` [PATCH 5/5] struct sockaddr_storage->ss_family is not portable Gary V. Vaughan
2010-04-25 19:05         ` Martin Storsjö
2010-04-26 16:55           ` Gary V. Vaughan
2010-03-11 22:27 ` Jeff King
2010-03-11 23:57   ` Brandon Casey

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=20100311163715.GE7877@thor.il.thewrittenword.com \
    --to=git@mlists.thewrittenword.com \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@gmail.com \
    --cc=peff@peff.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox