# [PATCH] Change include order in two compat/ files to avoid compiler warning

4 messages from 2012-02-05 to 2012-02-05. Participants: Ben Walton, Junio C Hamano.
Thread: https://gitlist.dev/t/29549

## Ben Walton, 2012-02-05 01:08

Subject: [PATCH] Change include order in two compat/ files to avoid compiler warning
Message-ID: <1328404107-15757-1-git-send-email-bwalton@artsci.utoronto.ca>
URL: https://gitlist.dev/e/1328404107-15757-1-git-send-email-bwalton%40artsci.utoronto.ca

```
The inet_ntop and inet_pton compatibility wrapper source files
included system headers before git-compat-utils.h.  This was causing a
warning on Solaris as _FILE_OFFSET_BITS was being redefined in
git-compat-utils.h.  Including git-compat-utils.h first avoids the
warnings.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
---

I verified that this re-ordering doesn't affect either the build or the 
test suite completion on both i386 and sparc.  I think the ordering is
simply the result of placing the git-compat-utils.h include where some
others were removed in da523cc597b1.

 compat/inet_ntop.c |    4 +---
 compat/inet_pton.c |    4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
index 60b5a1d..f1bf81c 100644
--- a/compat/inet_ntop.c
+++ b/compat/inet_ntop.c
@@ -15,11 +15,9 @@
  * SOFTWARE.
  */
 
+#include "../git-compat-util.h"
 #include <errno.h>
 #include <sys/types.h>
-
-#include "../git-compat-util.h"
-
 #include <stdio.h>
 #include <string.h>
 
diff --git a/compat/inet_pton.c b/compat/inet_pton.c
index 2ec995e..1d44a5d 100644
--- a/compat/inet_pton.c
+++ b/compat/inet_pton.c
@@ -15,11 +15,9 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include "../git-compat-util.h"
 #include <errno.h>
 #include <sys/types.h>
-
-#include "../git-compat-util.h"
-
 #include <stdio.h>
 #include <string.h>
 
-- 
1.7.8.3

```

## Junio C Hamano, 2012-02-05 20:41

Subject: Re: [PATCH] Change include order in two compat/ files to avoid compiler warning
Message-ID: <7vr4y9ggij.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vr4y9ggij.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1328404107-15757-1-git-send-email-bwalton@artsci.utoronto.ca>

```
Ben Walton <bwalton@artsci.utoronto.ca> writes:

> The inet_ntop and inet_pton compatibility wrapper source files
> included system headers before git-compat-utils.h.

Thanks, that is definitely a breakage.

> diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
> index 60b5a1d..f1bf81c 100644
> --- a/compat/inet_ntop.c
> +++ b/compat/inet_ntop.c
> @@ -15,11 +15,9 @@
>   * SOFTWARE.
>   */
>  
> +#include "../git-compat-util.h"
>  #include <errno.h>
>  #include <sys/types.h>
> -
> -#include "../git-compat-util.h"
> -
>  #include <stdio.h>
>  #include <string.h>

I actually have to wonder if any of these four inclusion of the system headers
are warranted. Wouldn't they be included as part of git-compat-util.h anyway?

```

## Ben Walton, 2012-02-05 22:32

Subject: (unknown)
Message-ID: <1328481141-21037-1-git-send-email-bwalton@artsci.utoronto.ca>
URL: https://gitlist.dev/e/1328481141-21037-1-git-send-email-bwalton%40artsci.utoronto.ca
In-Reply-To: <7vr4y9ggij.fsf@alter.siamese.dyndns.org>

```
Hi Junio,

> > diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
> > index 60b5a1d..f1bf81c 100644
> > --- a/compat/inet_ntop.c
> > +++ b/compat/inet_ntop.c
> > @@ -15,11 +15,9 @@
> >   * SOFTWARE.
> >   */
> >
> > +#include "../git-compat-util.h"
> >  #include <errno.h>
> >  #include <sys/types.h>
> > -
> > -#include "../git-compat-util.h"
> > -
> >  #include <stdio.h>
> >  #include <string.h>
> 
> I actually have to wonder if any of these four inclusion of the
> system headers are warranted. Wouldn't they be included as part of
> git-compat-util.h anyway?

Yes, you're correct.  Dropping the system includes is correct as
opposed to rearranging the order.  Updated patch to follow.

Thanks
-Ben

```

## Ben Walton, 2012-02-05 22:32

Subject: [PATCH] Drop system includes from inet_pton/inet_ntop compatibility wrappers
Message-ID: <1328481141-21037-2-git-send-email-bwalton@artsci.utoronto.ca>
URL: https://gitlist.dev/e/1328481141-21037-2-git-send-email-bwalton%40artsci.utoronto.ca
In-Reply-To: <1328481141-21037-1-git-send-email-bwalton@artsci.utoronto.ca>

```
As both of these compatibility wrappers include git-compat-utils.h,
all of the system includes were redundant.

Dropping these system includes also makes git-compat-utils.h the first
include which avoids a compiler warning on Solaris due to the
redefinition of _FILE_OFFSET_BITS.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
---
 compat/inet_ntop.c |    6 ------
 compat/inet_pton.c |    6 ------
 2 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
index 60b5a1d..90b7cc4 100644
--- a/compat/inet_ntop.c
+++ b/compat/inet_ntop.c
@@ -15,14 +15,8 @@
  * SOFTWARE.
  */
 
-#include <errno.h>
-#include <sys/types.h>
-
 #include "../git-compat-util.h"
 
-#include <stdio.h>
-#include <string.h>
-
 #ifndef NS_INADDRSZ
 #define NS_INADDRSZ	4
 #endif
diff --git a/compat/inet_pton.c b/compat/inet_pton.c
index 2ec995e..2b9a0a4 100644
--- a/compat/inet_pton.c
+++ b/compat/inet_pton.c
@@ -15,14 +15,8 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <errno.h>
-#include <sys/types.h>
-
 #include "../git-compat-util.h"
 
-#include <stdio.h>
-#include <string.h>
-
 #ifndef NS_INT16SZ
 #define NS_INT16SZ       2
 #endif
-- 
1.7.5.4

```
