git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Use int instead of socklen_t

From
Junio C Hamano <junkio@cox.net>
Date
Sep 11, 2005, 21:01 UTC
Message-ID
<7v8xy3qpyh.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.58.0509111100260.3242@g5.osdl.org>

This should work around the compilation problem Johannes Schindelin and others had on Mac OS/X.

Quoting Linus:
    Any operating system where socklen_t is anything else than
    "int" is terminally broken. The people who introduced that
    typedef were confused, and I actually had to argue with them
    that it was fundamentally wrong: there is no other valid
    type than "int" that makes sense for it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
    Linus Torvalds <torvalds@osdl.org> writes:
    > On Sun, 11 Sep 2005, Junio C Hamano wrote:
    >> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
    >> 
    >> > I have three fixes in my personal tree without which git refuses to 
    >> > compile:
    >> >
    >> > - daemon.c needs a define or typedef for socklen_t.
    >> 
    >> I still keep that patch around (the patch was end of July), but
    >> have not touched it only because I did not hear from you asking
    >> about its inclusion.
    >
    > Side note: one simple solution for "socklen_t" is to just replace it with 
    > "int".
 daemon.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
def13dbdb962069f4cb22e3d72483ae443bda6cf
diff --git a/daemon.c b/daemon.c
--- a/daemon.c
+++ b/daemon.c
@@ -80,11 +80,11 @@ static unsigned int children_deleted = 0
 
 static struct child {
 	pid_t pid;
-	socklen_t addrlen;
+	int addrlen;
 	struct sockaddr_storage address;
 } live_child[MAX_CHILDREN];
 
-static void add_child(int idx, pid_t pid, struct sockaddr *addr, socklen_t addrlen)
+static void add_child(int idx, pid_t pid, struct sockaddr *addr, int addrlen)
 {
 	live_child[idx].pid = pid;
 	live_child[idx].addrlen = addrlen;
@@ -178,7 +178,7 @@ static void check_max_connections(void)
 	}
 }
 
-static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
+static void handle(int incoming, struct sockaddr *addr, int addrlen)
 {
 	pid_t pid = fork();
 
@@ -308,7 +308,7 @@ static int serve(int port)
 
 			if (FD_ISSET(sockfd, &fds)) {
 				struct sockaddr_storage ss;
-				socklen_t sslen = sizeof(ss);
+				int sslen = sizeof(ss);
 				int incoming = accept(sockfd, (struct sockaddr *)&ss, &sslen);
 				if (incoming < 0) {
 					switch (errno) {
Previous: Linus TorvaldsNext: Johannes Schindelin
Message 12 of 22 in “Status of Mac OS/X ports of git and cogito?”
  1. John EllsonAug 27, 2005
  2. Junio C HamanoAug 27, 2005
  3. Johannes SchindelinSep 11, 2005
  4. Martin LanghoffSep 11, 2005
  5. Johannes SchindelinSep 11, 2005
  6. Junio C HamanoSep 11, 2005
  7. Linus TorvaldsSep 11, 2005
  8. A Large Angry SCMSep 11, 2005
  9. Junio C HamanoSep 11, 2005
  10. Johannes SchindelinSep 11, 2005
  11. Linus TorvaldsSep 11, 2005
  12. Use int instead of socklen_tJunio C Hamano, Sep 11, 2005
  13. Johannes SchindelinSep 11, 2005
  14. Linus TorvaldsSep 11, 2005
  15. Linus TorvaldsSep 11, 2005
  16. Johannes SchindelinSep 12, 2005
  17. Daniel BarkalowSep 11, 2005
  18. Martin LanghoffSep 11, 2005
  19. Johannes SchindelinSep 11, 2005
  20. Martin LanghoffAug 27, 2005
  21. Martin LanghoffAug 29, 2005
  22. Martin LanghoffAug 30, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.