Skip to contentSkip to conversation

xdiff: avoid accidental redefinition of LFS feature in OpenIndiana

PATCH In review Carlo Marcelo Arenas Belón 4 participants 17 messages Jun 18, 2019 – Jul 29, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xdiff: avoid accidental redefinition of LFS feature in OpenIndiana

after b46054b374 ("xdiff: use git-compat-util", 2019-04-11), two system headers added in 2012 to xutils where no longer needed and could conflict as shown below:

In file included from xdiff/xinclude.h:26:0,

                 from xdiff/xutils.c:25:

./git-compat-util.h:4:0: warning: "_FILE_OFFSET_BITS" redefined
#define _FILE_OFFSET_BITS 64

In file included from /usr/include/limits.h:37:0,

                 from xdiff/xutils.c:23:

/usr/include/sys/feature_tests.h:231:0: note: this is the location of the previous definition
#define _FILE_OFFSET_BITS 32

make sure git-compat-util.h is the first header (through xinclude.h)

---
 xdiff/xutils.c | 4 ----
 1 file changed, 4 deletions(-)
xdiff/xutils.c +0 -4
index 963e1c58b9..cfa6e2220f 100644
@@ -20,13 +20,9 @@
  *
  */
 
-#include <limits.h>
-#include <assert.h>
 #include "xinclude.h"
 
 
-
-
 long xdl_bogosqrt(long n) {
 	long i;
 
Signature · 1 line
2.22.0
#1 lore raw

Hi Carlo,

in the Git ecosystem, the abbreviation "LFS" does not mean what you think it means... Let's not use the abbreviation for anything else.

Quoted 2 lines · Carlo Marcelo Arenas Belón

after b46054b374 ("xdiff: use git-compat-util", 2019-04-11), two system headers added in 2012 to xutils where no longer needed and could conflict

s/where/are/

Otherwise the patch looks fine to me, thanks,
Johannes

Quoted 41 lines

as shown below:

In file included from xdiff/xinclude.h:26:0,

                 from xdiff/xutils.c:25:

./git-compat-util.h:4:0: warning: "_FILE_OFFSET_BITS" redefined
#define _FILE_OFFSET_BITS 64

In file included from /usr/include/limits.h:37:0,

                 from xdiff/xutils.c:23:

/usr/include/sys/feature_tests.h:231:0: note: this is the location of the previous definition
#define _FILE_OFFSET_BITS 32

make sure git-compat-util.h is the first header (through xinclude.h)

---
 xdiff/xutils.c | 4 ----
 1 file changed, 4 deletions(-)
xdiff/xutils.c +0 -5
index 963e1c58b9..cfa6e2220f 100644
@@ -20,13 +20,9 @@
  *
  */
 
-#include <limits.h>
-#include <assert.h>
 #include "xinclude.h"
 
 
-
-
 long xdl_bogosqrt(long n) {
 	long i;
 
--

2.22.0

#2 lore raw

cover a few more redundant system include cleanups

In reply to Carlo Marcelo Arenas Belón
Quoted 9 lines · Carlo Marcelo Arenas Belón

after b46054b374 ("xdiff: use git-compat-util", 2019-04-11), two system headers added in 2012 to xutils where no longer needed and could conflict as shown below:

In file included from xdiff/xinclude.h:26:0,

                 from xdiff/xutils.c:25:

./git-compat-util.h:4:0: warning: "_FILE_OFFSET_BITS" redefined
#define _FILE_OFFSET_BITS 64

Quoted 6 lines

In file included from /usr/include/limits.h:37:0,

                 from xdiff/xutils.c:23:

/usr/include/sys/feature_tests.h:231:0: note: this is the location of the previous definition
#define _FILE_OFFSET_BITS 32

make sure git-compat-util.h is the first header (through xinclude.h)

Thanks, this looks good to me. I fixed the system headers in xinclude.h, but didn't think to check for individual C files including them.

I did a quick grep for similar cases, and didn't find any that I think would be problematic. There were a few cleanups, below.

There are still some other system includes, but they are mostly one-offs that we wouldn't expect git-compat-util to cover (e.g., threading stuff in thread-utils.[ch], openssl stuff in hash.h). So I think with your patch, plus the patches below, there's nothing left to clean up.

[1/2]: verify-tag: drop signal.h include
[2/2]: wt-status.h: drop stdio.h include

 builtin/verify-commit.c | 1 -
 builtin/verify-tag.c    | 1 -
 wt-status.h             | 1 -
 3 files changed, 3 deletions(-)

-Peff

#3 lore raw

PATCH 1/2 verify-tag: drop signal.h include

There's no reason verify-tag.c needs to include signal.h. It's already in git-compat-util.h, which we properly include as the first header. And there doesn't seem to be a particular reason for this include; it's just an artifact from the file creation in 2ae68fcb78 (Make verify-tag a builtin., 2007-07-27).

Likewise verify-commit.c has the same issue, probably because it was created using verify-tag as a template in d07b00b7f3 (verify-commit:
scriptable commit signature verification, 2014-06-23).

These includes are probably just redundant, and not hurting anything by circumventing the order that git-compat-util.h tries to impose, since we'll always have loaded git-compat-util by the time we get to these. So this is just a cleanup, and shouldn't fix or break any platforms.

---
 builtin/verify-commit.c | 1 -
 builtin/verify-tag.c    | 1 -
 2 files changed, 2 deletions(-)
builtin/verify-commit.c +0 -1
index 4b9e823f8f..40c69a0bed 100644
@@ -12,7 +12,6 @@
 #include "repository.h"
 #include "commit.h"
 #include "run-command.h"
-#include <signal.h>
 #include "parse-options.h"
 #include "gpg-interface.h"
 
builtin/verify-tag.c +0 -1
index 6fa04b751a..f45136a06b 100644
@@ -10,7 +10,6 @@
 #include "builtin.h"
 #include "tag.h"
 #include "run-command.h"
-#include <signal.h>
 #include "parse-options.h"
 #include "gpg-interface.h"
 #include "ref-filter.h"
Signature · 1 line
2.22.0.rc3.685.g5185838c9a
#4 lore raw

PATCH 2/2 wt-status.h: drop stdio.h include

In reply to Jeff King

We started including stdio.h to pick up the declaration of "FILE" in f26a001226 (Enable wt-status output to a given FILE pointer., 2007-09-17). But there's no need, since headers can assume that git-compat-util.h has been included, which covers stdio.

This should just be redundant, and not hurting anything (like pulling in includes out of order) because C files are supposed to always include git-compat-util.h first. But it's worth cleaning up to model good behavior.

---
 wt-status.h | 1 -
 1 file changed, 1 deletion(-)
wt-status.h +0 -1
index 64f1ddc9fd..8849768e92 100644
@@ -1,7 +1,6 @@
 #ifndef STATUS_H
 #define STATUS_H
 
-#include <stdio.h>
 #include "string-list.h"
 #include "color.h"
 #include "pathspec.h"
Signature · 1 line
2.22.0.rc3.685.g5185838c9a
#5 lore raw

Re: [PATCH 0/2] a few more redundant system include cleanups

In reply to Jeff King
Quoted 3 lines · Jeff King

Thanks, this looks good to me. I fixed the system headers in xinclude.h, but didn't think to check for individual C files including them.

also noticed that after the refactoring some files will include a couple of headers twice (not an issue, though thanks to the header guards) but didn't send that patch to reduce the churn and avoid confusion.

Quoted 2 lines

I did a quick grep for similar cases, and didn't find any that I think would be problematic. There were a few cleanups, below.

would you mind if I add your 2 patches to a series and include that missing one?, that way I'll also have a chance to write a better commit message from my original change, including the other feedback I got as well

Carlo

PS. is there a recommendation on how to version a patch that move into a series that would be preferred?

#6 lore raw

Re: [PATCH 0/2] a few more redundant system include cleanups

Quoted 7 lines · Carlo Arenas
Quoted 2 lines

I did a quick grep for similar cases, and didn't find any that I think would be problematic. There were a few cleanups, below.

would you mind if I add your 2 patches to a series and include that missing one?, that way I'll also have a chance to write a better commit message from my original change, including the other feedback I got as well

That's be fine with me. Thanks.

Quoted 2 lines

PS. is there a recommendation on how to version a patch that move into a series that would be preferred?

I think you can just say "v2" on the whole thing, include all three patches, and then write a note that the series supersedes what I sent.

-Peff

#7 lore raw

Re: [PATCH 0/2] a few more redundant system include cleanups

Quoted 10 lines · Jeff King
Quoted 7 lines · Carlo Arenas
Quoted 2 lines

I did a quick grep for similar cases, and didn't find any that I think would be problematic. There were a few cleanups, below.

would you mind if I add your 2 patches to a series and include that missing one?, that way I'll also have a chance to write a better commit message from my original change, including the other feedback I got as well

Quoted 7 lines

That's be fine with me. Thanks.

Quoted 2 lines

PS. is there a recommendation on how to version a patch that move into a series that would be preferred?

I think you can just say "v2" on the whole thing, include all three patches, and then write a note that the series supersedes what I sent.

Carlo, no need to rush, but has this happened already? I do not recall seeing an update, and I am wondering if I missed one.

Thanks.

#8 lore raw

Re: [PATCH 0/2] a few more redundant system include cleanups

Quoted 3 lines · Junio C Hamano

Carlo, no need to rush, but has this happened already? I do not recall seeing an update, and I am wondering if I missed one.

Junio; had yet to send the update, so nothing was missed

Carlo

#9 lore raw

v2 cover system header cleanup

This series is a reroll of jk/no-system-includes-in-dot-c with cb/xdiff-no-system-includes-in-dot-c applied on top with minor fixes for the commit message based on feedback from Johannes and the example put forward by Peff with his own patches.

The changes proposed shouldn't affect any systems (except for the 3rd one) and that has since shown to also be needed in Alpine Linux (because of _XOPEN_SOURCE redefinition).

The last 2 patches are new to the series and just cleanup the dependency list in xdiff.

Carlo Marcelo Arenas Belón (3):
xdiff: drop system includes in xutils.c
xdiff: remove duplicate headers from xhistogram.c
xdiff: remove duplicate headers from xpatience.c

Jeff King (2):
verify-tag: drop signal.h include
wt-status.h: drop stdio.h include

 builtin/verify-commit.c | 1 -
 builtin/verify-tag.c    | 1 -
 wt-status.h             | 1 -
 xdiff/xhistogram.c      | 2 --
 xdiff/xpatience.c       | 2 --
 xdiff/xutils.c          | 4 ----
 6 files changed, 11 deletions(-)
Signature · 1 line
2.22.0
#10 lore raw

PATCH v2 1/5 verify-tag: drop signal.h include

From: Jeff King <[email protected]>

There's no reason verify-tag.c needs to include signal.h. It's already in git-compat-util.h, which we properly include as the first header. And there doesn't seem to be a particular reason for this include; it's just an artifact from the file creation in 2ae68fcb78 (Make verify-tag a builtin., 2007-07-27).

Likewise verify-commit.c has the same issue, probably because it was created using verify-tag as a template in d07b00b7f3 (verify-commit:
scriptable commit signature verification, 2014-06-23).

These includes are probably just redundant, and not hurting anything by circumventing the order that git-compat-util.h tries to impose, since we'll always have loaded git-compat-util by the time we get to these. So this is just a cleanup, and shouldn't fix or break any platforms.

---
 builtin/verify-commit.c | 1 -
 builtin/verify-tag.c    | 1 -
 2 files changed, 2 deletions(-)
builtin/verify-commit.c +0 -1
index 7772c07ed7..4e93914e59 100644
@@ -12,7 +12,6 @@
 #include "repository.h"
 #include "commit.h"
 #include "run-command.h"
-#include <signal.h>
 #include "parse-options.h"
 #include "gpg-interface.h"
 
builtin/verify-tag.c +0 -1
index 6fa04b751a..f45136a06b 100644
@@ -10,7 +10,6 @@
 #include "builtin.h"
 #include "tag.h"
 #include "run-command.h"
-#include <signal.h>
 #include "parse-options.h"
 #include "gpg-interface.h"
 #include "ref-filter.h"
Signature · 1 line
2.22.0
#11 lore raw

PATCH v2 2/5 wt-status.h: drop stdio.h include

In reply to Carlo Marcelo Arenas Belón

From: Jeff King <[email protected]>

We started including stdio.h to pick up the declaration of "FILE" in f26a001226 (Enable wt-status output to a given FILE pointer., 2007-09-17). But there's no need, since headers can assume that git-compat-util.h has been included, which covers stdio.

This should just be redundant, and not hurting anything (like pulling in includes out of order) because C files are supposed to always include git-compat-util.h first. But it's worth cleaning up to model good behavior.

---
 wt-status.h | 1 -
 1 file changed, 1 deletion(-)
wt-status.h +0 -1
index 64f1ddc9fd..8849768e92 100644
@@ -1,7 +1,6 @@
 #ifndef STATUS_H
 #define STATUS_H
 
-#include <stdio.h>
 #include "string-list.h"
 #include "color.h"
 #include "pathspec.h"
Signature · 1 line
2.22.0
#12 lore raw

PATCH v2 3/5 xdiff: drop system includes in xutils.c

In reply to Carlo Marcelo Arenas Belón

After b46054b374 ("xdiff: use git-compat-util", 2019-04-11), two system headers added with 6942efcfa9 ("xdiff: load full words in the inner loop of xdl_hash_record", 2012-04-06) to xutils.c are no longer needed and could conflict as shown below from an OpenIndiana build:

In file included from xdiff/xinclude.h:26:0,

                 from xdiff/xutils.c:25:

./git-compat-util.h:4:0: warning: "_FILE_OFFSET_BITS" redefined
#define _FILE_OFFSET_BITS 64

In file included from /usr/include/limits.h:37:0,

                 from xdiff/xutils.c:23:

/usr/include/sys/feature_tests.h:231:0: note: this is the location of the previous definition
#define _FILE_OFFSET_BITS 32

Make sure git-compat-util.h is the first header (through xinclude.h)

---
V2: reword commit with feedback from Johannes

 xdiff/xutils.c | 4 ----
 1 file changed, 4 deletions(-)
xdiff/xutils.c +0 -4
index 963e1c58b9..cfa6e2220f 100644
@@ -20,13 +20,9 @@
  *
  */
 
-#include <limits.h>
-#include <assert.h>
 #include "xinclude.h"
 
 
-
-
 long xdl_bogosqrt(long n) {
 	long i;
 
Signature · 1 line
2.22.0
#13 lore raw

PATCH v2 4/5 xdiff: remove duplicate headers from xhistogram.c

In reply to Carlo Marcelo Arenas Belón

8c912eea94 ("teach --histogram to diff", 2011-07-12) included them, but were already part of xinclude.h

---
 xdiff/xhistogram.c | 2 --
 1 file changed, 2 deletions(-)
xdiff/xhistogram.c +0 -2
index ec85f5992b..c7b35a9667 100644
@@ -42,8 +42,6 @@
  */
 
 #include "xinclude.h"
-#include "xtypes.h"
-#include "xdiff.h"
 
 #define MAX_PTR	UINT_MAX
 #define MAX_CNT	UINT_MAX
Signature · 1 line
2.22.0
#14 lore raw

PATCH v2 5/5 xdiff: remove duplicate headers from xpatience.c

In reply to Carlo Marcelo Arenas Belón

92b7de93fb (Implement the patience diff algorithm, 2009-01-07) added them but were already part of xinclude.h

---
 xdiff/xpatience.c | 2 --
 1 file changed, 2 deletions(-)
xdiff/xpatience.c +0 -2
index f3573d9f00..3c5601b602 100644
@@ -20,8 +20,6 @@
  *
  */
 #include "xinclude.h"
-#include "xtypes.h"
-#include "xdiff.h"
 
 /*
  * The basic idea of patience diff is to find lines that are unique in
Signature · 1 line
2.22.0
#15 lore raw

Re: [PATCH v2 0/5] system header cleanup

In reply to Carlo Marcelo Arenas Belón
Quoted 11 lines · Carlo Marcelo Arenas Belón

This series is a reroll of jk/no-system-includes-in-dot-c with cb/xdiff-no-system-includes-in-dot-c applied on top with minor fixes for the commit message based on feedback from Johannes and the example put forward by Peff with his own patches.

The changes proposed shouldn't affect any systems (except for the 3rd one) and that has since shown to also be needed in Alpine Linux (because of _XOPEN_SOURCE redefinition).

The last 2 patches are new to the series and just cleanup the dependency list in xdiff.

Thanks, these all look good to me.

-Peff

#16 lore raw

Re: [PATCH v2 0/5] system header cleanup

Quoted 7 lines · Jeff King
Quoted 5 lines · Carlo Marcelo Arenas Belón

This series is a reroll of jk/no-system-includes-in-dot-c with cb/xdiff-no-system-includes-in-dot-c applied on top with minor fixes for the commit message based on feedback from Johannes and the example put forward by Peff with his own patches.

Quoted 8 lines
Quoted 6 lines

The changes proposed shouldn't affect any systems (except for the 3rd one) and that has since shown to also be needed in Alpine Linux (because of _XOPEN_SOURCE redefinition).

The last 2 patches are new to the series and just cleanup the dependency list in xdiff.

Thanks, these all look good to me.

Thanks, both. They look good to me too.