# compile error in Git v2.7.0-rc0

5 messages from 2015-12-14 to 2015-12-14. Participants: johan defries, Junio C Hamano, Jeff King.
Thread: https://gitlist.dev/t/40995

## johan defries, 2015-12-14 20:28

Subject: compile error in Git v2.7.0-rc0
Message-ID: <CALibRqFajuBuv9ooaBWL1kUzaVps2WfodqucyHni2ggv6JpwDg@mail.gmail.com>
URL: https://gitlist.dev/e/CALibRqFajuBuv9ooaBWL1kUzaVps2WfodqucyHni2ggv6JpwDg%40mail.gmail.com

```
Probably because I have NO_IPV6 defined.

ident.c: In function ‘canonical_name’:
ident.c:89:37: error: ‘buf’ undeclared (first use in this function)
  struct hostent *he = gethostbyname(buf);
                                     ^
ident.c:89:37: note: each undeclared identifier is reported only once
for each function it appears in
make: *** [ident.o] Fout 1

```

## Junio C Hamano, 2015-12-14 20:35

Subject: Re: compile error in Git v2.7.0-rc0
Message-ID: <xmqqvb80ix9u.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqvb80ix9u.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CALibRqFajuBuv9ooaBWL1kUzaVps2WfodqucyHni2ggv6JpwDg@mail.gmail.com>

```
johan defries <johandefries@gmail.com> writes:

> Probably because I have NO_IPV6 defined.
>
> ident.c: In function ‘canonical_name’:
> ident.c:89:37: error: ‘buf’ undeclared (first use in this function)
>   struct hostent *he = gethostbyname(buf);
>                                      ^
> ident.c:89:37: note: each undeclared identifier is reported only once
> for each function it appears in
> make: *** [ident.o] Fout 1

Thanks.  This should perhaps do?

 ident.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ident.c b/ident.c
index 4e7f99d..2900879 100644
--- a/ident.c
+++ b/ident.c
@@ -86,6 +86,7 @@ static int canonical_name(const char *host, struct strbuf *out)
 		freeaddrinfo(ai);
 	}
 #else
+	char buf[1024];
 	struct hostent *he = gethostbyname(buf);
 	if (he && strchr(he->h_name, '.')) {
 		strbuf_addstr(out, he->h_name);

```

## Jeff King, 2015-12-14 20:46

Subject: Re: compile error in Git v2.7.0-rc0
Message-ID: <20151214204624.GA14788@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20151214204624.GA14788%40sigill.intra.peff.net
In-Reply-To: <xmqqvb80ix9u.fsf@gitster.mtv.corp.google.com>

```
On Mon, Dec 14, 2015 at 12:35:25PM -0800, Junio C Hamano wrote:

> johan defries <johandefries@gmail.com> writes:
> 
> > Probably because I have NO_IPV6 defined.
> >
> > ident.c: In function ‘canonical_name’:
> > ident.c:89:37: error: ‘buf’ undeclared (first use in this function)
> >   struct hostent *he = gethostbyname(buf);
> >                                      ^
> > ident.c:89:37: note: each undeclared identifier is reported only once
> > for each function it appears in
> > make: *** [ident.o] Fout 1
> 
> Thanks.  This should perhaps do?
> 
>  ident.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/ident.c b/ident.c
> index 4e7f99d..2900879 100644
> --- a/ident.c
> +++ b/ident.c
> @@ -86,6 +86,7 @@ static int canonical_name(const char *host, struct strbuf *out)
>  		freeaddrinfo(ai);
>  	}
>  #else
> +	char buf[1024];
>  	struct hostent *he = gethostbyname(buf);
>  	if (he && strchr(he->h_name, '.')) {
>  		strbuf_addstr(out, he->h_name);

Whoops. Looks like we didn't test the NO_IPV6 code path.

I don't think that fix is right, though. We should be passing "host" to
gethostbyname.

-Peff

```

## Jeff King, 2015-12-14 20:52

Subject: Re: compile error in Git v2.7.0-rc0
Message-ID: <20151214205241.GB14788@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20151214205241.GB14788%40sigill.intra.peff.net
In-Reply-To: <20151214204624.GA14788@sigill.intra.peff.net>

```
On Mon, Dec 14, 2015 at 03:46:25PM -0500, Jeff King wrote:

> I don't think that fix is right, though. We should be passing "host" to
> gethostbyname.

Here it is in patch form. It can go on top of ep/ident-with-getaddrinfo.

-- >8 --
Subject: [PATCH] ident: fix undefined variable when NO_IPV6 is set

Commit 00bce77 (ident.c: add support for IPv6, 2015-11-27)
moved the "gethostbyname" call out of "add_domainname" and
into the helper function "canonical_name". But when moving
the code, it forgot that the "buf" variable is passed as
"host" in the helper.

Reported-by: johan defries <johandefries@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
---
 ident.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ident.c b/ident.c
index 4e7f99d..00a62e0 100644
--- a/ident.c
+++ b/ident.c
@@ -86,7 +86,7 @@ static int canonical_name(const char *host, struct strbuf *out)
 		freeaddrinfo(ai);
 	}
 #else
-	struct hostent *he = gethostbyname(buf);
+	struct hostent *he = gethostbyname(host);
 	if (he && strchr(he->h_name, '.')) {
 		strbuf_addstr(out, he->h_name);
 		status = 0;
-- 
2.7.0.rc0.348.g8e7037f

```

## Junio C Hamano, 2015-12-14 21:11

Subject: Re: compile error in Git v2.7.0-rc0
Message-ID: <CAPc5daWWSNRdMSaQvakkK=mA_626QfuafmU5SkDTRC9kZpKzSw@mail.gmail.com>
URL: https://gitlist.dev/e/CAPc5daWWSNRdMSaQvakkK%3DmA_626QfuafmU5SkDTRC9kZpKzSw%40mail.gmail.com
In-Reply-To: <20151214205241.GB14788@sigill.intra.peff.net>

```
On Mon, Dec 14, 2015 at 12:52 PM, Jeff King <peff@peff.net> wrote:
> On Mon, Dec 14, 2015 at 03:46:25PM -0500, Jeff King wrote:
>
>> I don't think that fix is right, though. We should be passing "host" to
>> gethostbyname.
>
> Here it is in patch form. It can go on top of ep/ident-with-getaddrinfo.


Thanks.

I recall you were looking for a brown-paper-bag earlier.
When you are done with it, could you pass it to me ;-)?

```
