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

Re: [PATCH 1/2] GIT: Try all addresses for given remote name

From
Petr Baudis <pasky@suse.cz>
Date
Jul 22, 2005, 21:37 UTC
Message-ID
<20050722213753.GK11916@pasky.ji.cz>
In-Reply-To
<20050722.172629.73295196.yoshfuji@linux-ipv6.org>

Dear diary, on Fri, Jul 22, 2005 at 11:26:29PM CEST, I got a letter where "YOSHIFUJI Hideaki / ?$B5HF#1QL@" <yoshfuji@linux-ipv6.org> told me that...

Show 33 quoted lines
> In article <20050722210913.GH11916@pasky.ji.cz> (at Fri, 22 Jul 2005 23:09:13 +0200), Petr Baudis <pasky@suse.cz> says:
> 
> > > -}
> > > +#define STR_(s)	# s
> > > +#define STR(s)	STR_(s)
> > 
> > Uh-huh? Why two macros? Well, why any macros at all?
> > 
> :
> > > +	char *colon, *end;
> > > +	char *port = STR(DEFAULT_GIT_PORT);
> > > +	struct addrinfo hints, *ai0, *ai;
> 
> The macro is used here.
> This is trick.
> 
> After preprocess,
> 
> /* --- cut here --- */
> #define TEST 12345
> #define STR_(s) # s
> #define STR(s) STR_(s)
> 
> test(STR(TEST));
> test(STR_(TEST));
> test(# TEST);
> /* --- cut here --- */
> 
> becomes
> 
> test("12345");
> test("TEST");
> test(# 12345);

I see, I didn't know about this. Well, I didn't actually use the # stringificator many times. Perhaps a short comment would be due.

Show 11 quoted lines
> > >  	if (sockfd < 0)
> > >  		die("unable to create socket (%s)", strerror(errno));
> > > -	if (connect(sockfd, (void *)&addr, sizeof(addr)) < 0)
> > > -		die("unable to connect (%s)", strerror(errno));
> :
> > You are saying that you were unable to create socket while you just were
> > unable to connect.  Not any biggie, but it saves the user the trouble of
> > one strace after being confused by an error message. :-)
> 
> In fact, I don't think it is really worng, because it says that
> it could not create (connected) socket or endpoint of connection.
It uses only two words ("create socket") from that, though. ;-)
> Anyway, I agree that it would be confusing.
> Better ideas / wordings?
	if (connect() < 0) sockfd = -2;
	...
	if (sockfd == -1) die("unable to create socket");
	else die("unable to connect")

or I'd prefer the second error message "unable to connect", which is perhaps more descriptive regarding what effectively happened.

BTW, could the close() on the socket ever fail (read as "modify errno") here?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
If you want the holes in your knowledge showing up try teaching
someone.  -- Alan Cox
Previous: YOSHIFUJI Hideaki / 吉藤英明Next: Sam Ravnborg
Message 4 of 5 in “GIT: Try all addresses for given remote name”
  1. 1/2 GIT: Try all addresses for given remote nameYOSHIFUJI Hideaki / 吉藤英明, Jul 21, 2005
  2. Petr BaudisJul 22, 2005
  3. YOSHIFUJI Hideaki / 吉藤英明Jul 22, 2005
  4. Petr BaudisJul 22, 2005
  5. Sam RavnborgJul 23, 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.