stop generating platform_defs.h
Hi all,
this series gets rid of the need to generate platform_defs.h from autoconf. Let me know what you think.
PATCH 1/5 xfsprogs: remove the ENABLE_GETTEXT substitution in platform_defs.h.in
ENABLE_GETTEXT is already defined on the command line if enabled, no need to duplicate it in platform_defs.h.in.
--- include/platform_defs.h.in | 2 -- 1 file changed, 2 deletions(-)
include/platform_defs.h.in +0 -2
@@ -36,8 +36,6 @@ typedef struct filldir filldir_t; typedef unsigned short umode_t; #endif -/* Define if you want gettext (I18N) support */ -#undef ENABLE_GETTEXT #ifdef ENABLE_GETTEXT # include <libintl.h> # define _(x) gettext(x)
Signature · 1 line
2.24.1
Re: [PATCH 1/5] xfsprogs: remove the ENABLE_GETTEXT substitution in platform_defs.h.in
Quoted 4 lines · Christoph Hellwig
ENABLE_GETTEXTis already defined on the command line if enabled, no need to duplicate it in platform_defs.h.in.Signed-off-by Christoph Hellwig <[email protected]>
Seems reasonable, though I wonder
--D
Quoted 20 lines
--- include/platform_defs.h.in | 2 -- 1 file changed, 2 deletions(-)include/platform_defs.h.in +0
-2@@ -36,8 +36,6 @@ typedef struct filldir filldir_t; typedef unsigned short umode_t; #endif -/* Define if you want gettext (I18N) support */ -#undef ENABLE_GETTEXT #ifdef ENABLE_GETTEXT # include <libintl.h> # define _(x) gettext(x)Signature · 1 line
2.24.1
PATCH 2/5 xfsprogs: remove the SIZEOF_CHAR_P substitution in platform_defs.h.in
In reply to Christoph HellwigSIZEOF_CHAR_P is not used anywhere in the code, so remove the reference to it.
--- include/platform_defs.h.in | 1 - 1 file changed, 1 deletion(-)
include/platform_defs.h.in +0 -1
@@ -28,7 +28,6 @@ typedef struct filldir filldir_t; /* long and pointer must be either 32 bit or 64 bit */ #undef SIZEOF_LONG -#undef SIZEOF_CHAR_P #define BITS_PER_LONG (SIZEOF_LONG * CHAR_BIT) /* Check whether to define umode_t ourselves. */
Signature · 1 line
2.24.1
Re: [PATCH 2/5] xfsprogs: remove the SIZEOF_CHAR_P substitution in platform_defs.h.in
Quoted 4 lines · Christoph Hellwig
SIZEOF_CHAR_Pis not used anywhere in the code, so remove the reference to it.Signed-off-by Christoph Hellwig <[email protected]>
Woo.
--D
Quoted 19 lines
--- include/platform_defs.h.in | 1 - 1 file changed, 1 deletion(-)include/platform_defs.h.in +0
-1@@ -28,7 +28,6 @@ typedef struct filldir filldir_t; /* long and pointer must be either 32 bit or 64 bit */ #undef SIZEOF_LONG -#undef SIZEOF_CHAR_P #define BITS_PER_LONG (SIZEOF_LONG * CHAR_BIT) /* Check whether to define umode_t ourselves. */Signature · 1 line
2.24.1
PATCH 3/5 repair: remove BITS_PER_LONG cpp checks in bmap.[ch]
In reply to Christoph HellwigAdd a little helper to validate the nex count so that we can use compile time magic checks for sizeof long directly. Also don't print the max in case of an overflow as the value will always be the same.
--- repair/bmap.c | 29 +++++++++++++++++++++-------- repair/bmap.h | 13 ------------- 2 files changed, 21 insertions(+), 21 deletions(-)
repair/bmap.c +21 -8
@@ -22,6 +22,22 @@pthread_key_t dblkmap_key;pthread_key_t ablkmap_key; +/* +* For 32 bit platforms, we are limited to extent arrays of 2^31 bytes, which +* limits the number of extents in an inode we can check. If we don't limit the +* valid range, we can overflow the BLKMAP_SIZE() calculation and allocate less +* memory than we think we needed, and hence walk off the end of the array and +* corrupt memory. +*/ +static inline bool +blkmap_nex_valid ( +xfs_extnum_t nex) +{ +if (sizeof (long ) <64 && nex >=INT_MAX /sizeof (bmap_ext_t)) +return false; +return true; +} +blkmap_t * blkmap_alloc( xfs_extnum_t nex,
@@ -35,8 +51,7 @@ blkmap_alloc(if (nex <1 ) nex =1 ; -#if (BITS_PER_LONG ==32 )/* on 64-bit platforms this is never true */ -if (nex >BLKMAP_NEXTS_MAX ) { +if (!blkmap_nex_valid (nex)) { do_warn( _("Number of extents requested in blkmap_alloc (%d) overflows 32 bits.\n" "If this is not a corruption, then you will need a 64 bit system\n"
@@ -44,7 +59,6 @@ blkmap_alloc( nex);return NULL ; } -#endif key = whichfork ? ablkmap_key : dblkmap_key; blkmap =pthread_getspecific (key);
@@ -278,20 +292,19 @@ blkmap_grow(ASSERT (pthread_getspecific (key) == blkmap); } -#if (BITS_PER_LONG ==32 )/* on 64-bit platforms this is never true */ -if (new_naexts >BLKMAP_NEXTS_MAX ) { +if (!blkmap_nex_valid (new_naexts)) {do_error (_ ("Number of extents requested in blkmap_grow (%d) overflows 32 bits.\n" "You need a 64 bit system to repair this filesystem.\n" ), new_naexts);return NULL ; } -#endif +if (new_naexts <=0 ) {do_error (_ ("Number of extents requested in blkmap_grow (%d) overflowed the\n" -"maximum number of supported extents (%d).\n" ), - new_naexts,BLKMAP_NEXTS_MAX ); +"maximum number of supported extents.\n" ), + new_naexts);return NULL ; }
repair/bmap.h +0 -13
@@ -28,19 +28,6 @@ typedef struct blkmap {#define BLKMAP_SIZE (n) \ (offsetof(blkmap_t, exts) + (sizeof(bmap_ext_t) * (n))) -/* -* For 32 bit platforms, we are limited to extent arrays of 2^31 bytes, which -* limits the number of extents in an inode we can check. If we don't limit the -* valid range, we can overflow the BLKMAP_SIZE() calculation and allocate less -* memory than we think we needed, and hence walk off the end of the array and -* corrupt memory. -*/ -#if BITS_PER_LONG ==32 -#define BLKMAP_NEXTS_MAX ((INT_MAX / sizeof(bmap_ext_t)) - 1) -#else -#define BLKMAP_NEXTS_MAX INT_MAX -#endif -extern pthread_key_t dblkmap_key;extern pthread_key_t ablkmap_key;
Signature · 1 line
2.24.1
Re: [PATCH 3/5] repair: remove BITS_PER_LONG cpp checks in bmap.[ch]
Quoted 20 lines · Christoph Hellwig
Add a little helper to validate the nex count so that we can use compile time magic checks for sizeof long directly. Also don't print the max in case of an overflow as the value will always be the same.
Signed-off-by Christoph Hellwig <[email protected]>--- repair/bmap.c | 29 +++++++++++++++++++++-------- repair/bmap.h | 13 ------------- 2 files changed, 21 insertions(+), 21 deletions(-)repair/bmap.c +2
-0@@ -22,6 +22,22 @@pthread_key_t dblkmap_key;pthread_key_t ablkmap_key; +/* +* For 32 bit platforms, we are limited to extent arrays of 2^31 bytes, which
repair/bmap.c line 36
Quoted 10 lines
repair/bmap.c +10
-0+* limits the number of extents in an inode we can check. If we don't limit the +* valid range, we can overflow the BLKMAP_SIZE() calculation and allocate less +* memory than we think we needed, and hence walk off the end of the array and +* corrupt memory. +*/ +static inline bool +blkmap_nex_valid ( +xfs_extnum_t nex) +{ +if (sizeof (long ) <64 && nex >=INT_MAX /sizeof (bmap_ext_t))
sizeof(long) < 8
Frankly I suspect the maximum array length on 32 bit platforms is far less than 2^31 bytes...
--D
Quoted 77 lines
repair/bmap.c +9
-8+return false; +return true; +} +blkmap_t * blkmap_alloc( xfs_extnum_t nex,@@ -35,8 +51,7 @@ blkmap_alloc(if (nex <1 ) nex =1 ; -#if (BITS_PER_LONG ==32 )/* on 64-bit platforms this is never true */ -if (nex >BLKMAP_NEXTS_MAX ) { +if (!blkmap_nex_valid (nex)) { do_warn( _("Number of extents requested in blkmap_alloc (%d) overflows 32 bits.\n" "If this is not a corruption, then you will need a 64 bit system\n"@@ -44,7 +59,6 @@ blkmap_alloc( nex);return NULL ; } -#endif key = whichfork ? ablkmap_key : dblkmap_key; blkmap =pthread_getspecific (key);@@ -278,20 +292,19 @@ blkmap_grow(ASSERT (pthread_getspecific (key) == blkmap); } -#if (BITS_PER_LONG ==32 )/* on 64-bit platforms this is never true */ -if (new_naexts >BLKMAP_NEXTS_MAX ) { +if (!blkmap_nex_valid (new_naexts)) {do_error (_ ("Number of extents requested in blkmap_grow (%d) overflows 32 bits.\n" "You need a 64 bit system to repair this filesystem.\n" ), new_naexts);return NULL ; } -#endif +if (new_naexts <=0 ) {do_error (_ ("Number of extents requested in blkmap_grow (%d) overflowed the\n" -"maximum number of supported extents (%d).\n" ), - new_naexts,BLKMAP_NEXTS_MAX ); +"maximum number of supported extents.\n" ), + new_naexts);return NULL ; }repair/bmap.h +0
-13@@ -28,19 +28,6 @@ typedef struct blkmap {#define BLKMAP_SIZE (n) \ (offsetof(blkmap_t, exts) + (sizeof(bmap_ext_t) * (n))) -/* -* For 32 bit platforms, we are limited to extent arrays of 2^31 bytes, which -* limits the number of extents in an inode we can check. If we don't limit the -* valid range, we can overflow the BLKMAP_SIZE() calculation and allocate less -* memory than we think we needed, and hence walk off the end of the array and -* corrupt memory. -*/ -#if BITS_PER_LONG ==32 -#define BLKMAP_NEXTS_MAX ((INT_MAX / sizeof(bmap_ext_t)) - 1) -#else -#define BLKMAP_NEXTS_MAX INT_MAX -#endif -extern pthread_key_t dblkmap_key;extern pthread_key_t ablkmap_key;Signature · 1 line
2.24.1
PATCH 4/5 xfsprogs: remove the SIZEOF_LONG substitution in platform_defs.h.in
In reply to Christoph HellwigBITS_PER_LONG is now only checked in C expressions, so we can simply define it based on sizeof(long).
--- include/platform_defs.h.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
include/platform_defs.h.in +1 -3
@@ -26,9 +26,7 @@ typedef struct filldir filldir_t; -/* long and pointer must be either 32 bit or 64 bit */ -#undef SIZEOF_LONG -#define BITS_PER_LONG (SIZEOF_LONG * CHAR_BIT) +#define BITS_PER_LONG (sizeof(long) * CHAR_BIT) /* Check whether to define umode_t ourselves. */ #ifndef HAVE_UMODE_T
Signature · 1 line
2.24.1
Re: [PATCH 4/5] xfsprogs: remove the SIZEOF_LONG substitution in platform_defs.h.in
Quoted 4 lines · Christoph Hellwig
BITS_PER_LONGis now only checked in C expressions, so we can simply define it based on sizeof(long).Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 22 lines
--- include/platform_defs.h.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)include/platform_defs.h.in +1
-3@@ -26,9 +26,7 @@ typedef struct filldir filldir_t; -/* long and pointer must be either 32 bit or 64 bit */ -#undef SIZEOF_LONG -#define BITS_PER_LONG (SIZEOF_LONG * CHAR_BIT) +#define BITS_PER_LONG (sizeof(long) * CHAR_BIT) /* Check whether to define umode_t ourselves. */ #ifndef HAVE_UMODE_TSignature · 1 line
2.24.1
PATCH 5/5 xfsprogs: stop generating platform_defs.h
In reply to Christoph HellwigNow that all the autoconf substituations are gone, there is no need to generate this (and thus any) header.
---
.gitignore | 1 -
Makefile | 15 ++++-----------
configure.ac | 1 -
debian/rules | 2 --
include/Makefile | 2 +-
include/{platform_defs.h.in => platform_defs.h} | 0
6 files changed, 5 insertions(+), 16 deletions(-)
rename include/{platform_defs.h.in => platform_defs.h} (100%).gitignore +0 -1
@@ -6,7 +6,6 @@ # build system .census .gitcensus -/include/platform_defs.h /include/builddefs /install-sh
Makefile +4 -11
@@ -49,7 +49,7 @@ SRCTARINC = m4/libtool.m4 m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 \ m4/ltversion.m4 po/xfsprogs.pot .gitcensus $(CONFIGURE) LDIRT = config.log .ltdep .dep config.status config.cache confdefs.h \ conftest* built .census install.* install-dev.* *.gz *.xz \ - autom4te.cache/* libtool include/builddefs include/platform_defs.h + autom4te.cache/* libtool include/builddefs ifeq ($(HAVE_BUILDDEFS), yes) LDIRDIRT = $(SRCDIR)
@@ -84,7 +84,7 @@ endif # include is listed last so it is processed last in clean rules. SUBDIRS = $(LIBFROG_SUBDIR) $(LIB_SUBDIRS) $(TOOL_SUBDIRS) include -default: include/builddefs include/platform_defs.h +default: include/builddefs ifeq ($(HAVE_BUILDDEFS), no) $(Q)$(MAKE) $(MAKEOPTS) -C . $@ else
@@ -130,13 +130,6 @@ configure: configure.ac include/builddefs: configure ./configure $$LOCAL_CONFIGURE_OPTIONS -include/platform_defs.h: include/builddefs -## Recover from the removal of $@ - @if test -f $@; then :; else \ - rm -f include/builddefs; \ - $(MAKE) $(MAKEOPTS) $(AM_MAKEFLAGS) include/builddefs; \ - fi - install: $(addsuffix -install,$(SUBDIRS)) $(INSTALL) -m 755 -d $(PKG_DOC_DIR) $(INSTALL) -m 644 README $(PKG_DOC_DIR)
@@ -160,14 +153,14 @@ realclean: distclean # # All this gunk is to allow for a make dist on an unconfigured tree # -dist: include/builddefs include/platform_defs.h default +dist: include/builddefs default ifeq ($(HAVE_BUILDDEFS), no) $(Q)$(MAKE) $(MAKEOPTS) -C . $@ else $(Q)$(MAKE) $(MAKEOPTS) $(SRCTAR) endif -deb: include/builddefs include/platform_defs.h +deb: include/builddefs ifeq ($(HAVE_BUILDDEFS), no) $(Q)$(MAKE) $(MAKEOPTS) -C . $@ else
configure.ac +0 -1
@@ -3,7 +3,6 @@ AC_PREREQ(2.50) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([include/libxfs.h]) -AC_CONFIG_HEADER(include/platform_defs.h) AC_PREFIX_DEFAULT(/usr) AC_PROG_INSTALL
debian/rules +0 -2
@@ -43,14 +43,12 @@ config: .census @echo "== dpkg-buildpackage: configure" 1>&2 $(checkdir) AUTOHEADER=/bin/true dh_autoreconf - $(options) $(MAKE) $(PMAKEFLAGS) include/platform_defs.h touch .census dibuild: $(checkdir) @echo "== dpkg-buildpackage: installer" 1>&2 if [ ! -f mkfs/mkfs.xfs-$(bootpkg) ]; then \ - $(diopts) $(MAKE) include/platform_defs.h; \ mkdir -p include/xfs; \ for dir in include libxfs; do \ $(MAKE) $(PMAKEFLAGS) -C $$dir NODEP=1 install-headers; \
include/Makefile +1 -1
@@ -37,7 +37,7 @@ HFILES = handle.h \ xqm.h \ xfs_arch.h -LSRCFILES = platform_defs.h.in builddefs.in buildmacros buildrules install-sh +LSRCFILES = builddefs.in buildmacros buildrules install-sh LSRCFILES += $(DKHFILES) $(LIBHFILES) LDIRT = disk LDIRDIRT = xfs
include/platform_defs.h renamed from include/platform_defs.h.in +0 -0
Signature · 1 line
2.24.1
Re: [PATCH 5/5] xfsprogs: stop generating platform_defs.h
Quoted 4 lines · Christoph Hellwig
Now that all the autoconf substituations are gone, there is no need to generate this (and thus any) header.
Signed-off-by Christoph Hellwig <[email protected]>
Seems fine to me,
--D
Quoted 126 lines
--- .gitignore | 1 - Makefile | 15 ++++----------- configure.ac | 1 - debian/rules | 2 -- include/Makefile | 2 +- include/{platform_defs.h.in => platform_defs.h} | 0 6 files changed, 5 insertions(+), 16 deletions(-) rename include/{platform_defs.h.in => platform_defs.h} (100%).gitignore +0
-1@@ -6,7 +6,6 @@ # build system .census .gitcensus -/include/platform_defs.h /include/builddefs /install-shMakefile +4
-11@@ -49,7 +49,7 @@ SRCTARINC = m4/libtool.m4 m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 \ m4/ltversion.m4 po/xfsprogs.pot .gitcensus $(CONFIGURE) LDIRT = config.log .ltdep .dep config.status config.cache confdefs.h \ conftest* built .census install.* install-dev.* *.gz *.xz \ - autom4te.cache/* libtool include/builddefs include/platform_defs.h + autom4te.cache/* libtool include/builddefs ifeq ($(HAVE_BUILDDEFS), yes) LDIRDIRT = $(SRCDIR)@@ -84,7 +84,7 @@ endif # include is listed last so it is processed last in clean rules. SUBDIRS = $(LIBFROG_SUBDIR) $(LIB_SUBDIRS) $(TOOL_SUBDIRS) include -default: include/builddefs include/platform_defs.h +default: include/builddefs ifeq ($(HAVE_BUILDDEFS), no) $(Q)$(MAKE) $(MAKEOPTS) -C . $@ else@@ -130,13 +130,6 @@ configure: configure.ac include/builddefs: configure ./configure $$LOCAL_CONFIGURE_OPTIONS -include/platform_defs.h: include/builddefs -## Recover from the removal of $@ - @if test -f $@; then :; else \ - rm -f include/builddefs; \ - $(MAKE) $(MAKEOPTS) $(AM_MAKEFLAGS) include/builddefs; \ - fi - install: $(addsuffix -install,$(SUBDIRS)) $(INSTALL) -m 755 -d $(PKG_DOC_DIR) $(INSTALL) -m 644 README $(PKG_DOC_DIR)@@ -160,14 +153,14 @@ realclean: distclean # # All this gunk is to allow for a make dist on an unconfigured tree # -dist: include/builddefs include/platform_defs.h default +dist: include/builddefs default ifeq ($(HAVE_BUILDDEFS), no) $(Q)$(MAKE) $(MAKEOPTS) -C . $@ else $(Q)$(MAKE) $(MAKEOPTS) $(SRCTAR) endif -deb: include/builddefs include/platform_defs.h +deb: include/builddefs ifeq ($(HAVE_BUILDDEFS), no) $(Q)$(MAKE) $(MAKEOPTS) -C . $@ elseconfigure.ac +0
-1@@ -3,7 +3,6 @@ AC_PREREQ(2.50) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([include/libxfs.h]) -AC_CONFIG_HEADER(include/platform_defs.h) AC_PREFIX_DEFAULT(/usr) AC_PROG_INSTALLdebian/rules +0
-2@@ -43,14 +43,12 @@ config: .census @echo "== dpkg-buildpackage: configure" 1>&2 $(checkdir) AUTOHEADER=/bin/true dh_autoreconf - $(options) $(MAKE) $(PMAKEFLAGS) include/platform_defs.h touch .census dibuild: $(checkdir) @echo "== dpkg-buildpackage: installer" 1>&2 if [ ! -f mkfs/mkfs.xfs-$(bootpkg) ]; then \ - $(diopts) $(MAKE) include/platform_defs.h; \ mkdir -p include/xfs; \ for dir in include libxfs; do \ $(MAKE) $(PMAKEFLAGS) -C $$dir NODEP=1 install-headers; \include/Makefile +1
-1@@ -37,7 +37,7 @@ HFILES = handle.h \ xqm.h \ xfs_arch.h -LSRCFILES = platform_defs.h.in builddefs.in buildmacros buildrules install-sh +LSRCFILES = builddefs.in buildmacros buildrules install-sh LSRCFILES += $(DKHFILES) $(LIBHFILES) LDIRT = disk LDIRDIRT = xfsinclude/platform_defs.h renamed from include/platform_defs.h.in +0
-0Signature · 1 line
2.24.1