xdiff: avoid accidental redefinition of LFS feature in OpenIndiana
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
@@ -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
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_BITS64In 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_BITS32make sure
git-compat-util.his the first header (throughxinclude.h)Signed-off-by Carlo Marcelo Arenas Belón <[email protected]>--- xdiff/xutils.c | 4 ---- 1 file changed, 4 deletions(-)xdiff/xutils.c +0
-5@@ -20,13 +20,9 @@* */ -#include <limits.h> -#include <assert.h> #include "xinclude.h" - -long xdl_bogosqrt (long n) {long i; --2.22.0
cover a few more redundant system include cleanups
In reply to Carlo Marcelo Arenas BelónQuoted 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_BITS64
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_BITS32make sure
git-compat-util.his the first header (throughxinclude.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
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
@@ -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
@@ -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
PATCH 2/2 wt-status.h: drop stdio.h include
In reply to Jeff KingWe 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
@@ -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
Re: [PATCH 0/2] a few more redundant system include cleanups
In reply to Jeff KingQuoted 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?
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
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.
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
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
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
@@ -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
@@ -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
PATCH v2 2/5 wt-status.h: drop stdio.h include
In reply to Carlo Marcelo Arenas BelónFrom: 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
@@ -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
PATCH v2 3/5 xdiff: drop system includes in xutils.c
In reply to Carlo Marcelo Arenas BelónAfter 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
@@ -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
PATCH v2 4/5 xdiff: remove duplicate headers from xhistogram.c
In reply to Carlo Marcelo Arenas Belón8c912eea94 ("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
@@ -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
PATCH v2 5/5 xdiff: remove duplicate headers from xpatience.c
In reply to Carlo Marcelo Arenas Belón92b7de93fb (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
@@ -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
Re: [PATCH v2 0/5] system header cleanup
In reply to Carlo Marcelo Arenas BelónQuoted 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_SOURCEredefinition).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
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_SOURCEredefinition).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.