e2fsprogs: misc fixes, and add a GitHub Actions file
cover e2fsprogs: misc fixes, and add a GitHub Actions file
The last patch of this series adds a workflow file for GitHub Actions that builds and tests e2fsprogs on Ubuntu, macOS, and Windows. It's enforced that the build does not produce warnings with -Wall.
(For now, the Windows build is much more basic than the others; only mke2fs is built, and the unit tests are not run.)
The workflow will run on pushes to any fork of e2fsprogs that has GitHub Actions enabled. I'm hoping that Ted will enable it for the "official" fork at https://github.com/tytso/e2fsprogs, but anyone can use it in their own fork too. The results for this patch series are at
https://github.com/ebiggers/e2fsprogs/actions/runs/3976382057
As a prerequisite to actually getting everything to pass, patches 1-37 of this series fix a large number of miscellaneous issues, mainly pertaining to warnings with -Wall or to the Windows build.
Some patches in this series I've already sent out individually. This series supersedes all my previous patches.
Eric Biggers (38):
configure.ac: only use Windows I/O manager on native Windows configure.ac: disable tdb by default on Windows configure.ac: automatically add include/mingw/ headers
configure: regenerate
config/install-sh: update to latest version
lib, misc: eliminate dependency on Winsock
lib/blkid: remove 32-bit x86 byteswap assembly
lib/blkid: fix unaligned access to hfs_mdb
lib/blkid: fix -Wunused-variable warning in blkid_get_dev_size() lib/blkid: suppress -Wunused-result warning in blkid_flush_cache() lib/blkid: suppress -Wstringop-truncation warning in blkid_strndup() lib/e2p: fix a -Wunused-variable warning in getflags() lib/{e2p,ss}: remove manual declarations of errno
lib/et: fix "unused variable" warnings when !HAVE_FCNTL lib/ext2fs: remove 32-bit x86 bitops assembly
lib/ext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics() lib/ext2fs: remove unused variable in ext2fs_xattrs_read_inode() lib/ext2fs: fix a printf format specifier in file_test() lib/ext2fs: fix two compiler warnings in windows_io.c lib/ext2fs: fix a -Wpointer-sign warning in ext2fs_mmp_start() lib/{ext2fs,support}: fix 32-bit Windows build
lib/ss: fix 'make install' by creating man1dir lib/support: remove unused label in get_devname() lib/support: clean up definition of flags_array
lib/uuid: remove conflicting Windows implementation of gettimeofday()
e2fsck: use real functions for kernel slab functions misc/create_inode: fix -Wunused-variable warnings in __populate_fs() misc/create_inode: simplify logic in scandir() misc/e4defrag: fix -Wstringop-truncation warnings misc/fuse2fs: avoid error-prone strncpy() pattern misc/mk_hugefiles: simplify get_partition_start() misc/mke2fs: fix Windows build
misc/mke2fs: fix a -Wunused-variable warning in PRS() misc/tune2fs: fix setting fsuuid::fsu_len
misc/tune2fs: fix -Wunused-variable warnings in handle_fslabel() misc/util.c: enable MinGW alarm() when building for Windows
resize2fs: remove unused variable from adjust_superblock() Add a configuration file for GitHub Actions
.github/workflows/ci.yml | 116 ++++++ aclocal.m4 | 180 +++++---- config/install-sh | 683 ++++++++++++++++++++++++---------- configure | 105 ++++-- configure.ac | 50 ++- e2fsck/jfs_user.h | 62 ++- include/mingw/arpa/inet.h | 5 + include/mingw/sys/sysmacros.h | 8 +- lib/blkid/Android.bp | 1 - lib/blkid/devno.c | 10 + lib/blkid/getsize.c | 2 +- lib/blkid/probe.c | 10 +- lib/blkid/probe.h | 43 --- lib/blkid/save.c | 8 + lib/config.h.in | 100 ++++- lib/e2p/Android.bp | 4 - lib/e2p/fgetversion.c | 2 - lib/e2p/fsetversion.c | 1 - lib/e2p/getflags.c | 3 +- lib/e2p/getversion.c | 1 - lib/e2p/setversion.c | 1 - lib/et/Android.bp | 3 - lib/et/error_message.c | 10 +- lib/ext2fs/Android.bp | 2 - lib/ext2fs/bitops.c | 14 +- lib/ext2fs/bitops.h | 97 ----- lib/ext2fs/ext2_io.h | 2 + lib/ext2fs/ext_attr.c | 2 - lib/ext2fs/gen_bitmap64.c | 6 +- lib/ext2fs/getsectsize.c | 12 +- lib/ext2fs/inline_data.c | 2 +- lib/ext2fs/jfs_compat.h | 4 - lib/ext2fs/mmp.c | 2 +- lib/ext2fs/windows_io.c | 12 +- lib/ss/Makefile.in | 5 +- lib/ss/execute_cmd.c | 2 - lib/ss/help.c | 2 - lib/ss/pager.c | 2 - lib/support/devname.c | 1 - lib/support/plausible.c | 7 +- lib/support/print_fs_flags.c | 60 +-- lib/uuid/gen_uuid.c | 21 -- misc/Android.bp | 3 - misc/create_inode.c | 36 +- misc/e4defrag.c | 30 +- misc/fuse2fs.c | 5 +- misc/mk_hugefiles.c | 134 +------ misc/mke2fs.c | 22 +- misc/tune2fs.c | 7 +- misc/util.c | 5 + resize/resize2fs.c | 4 - util/android_config.h | 1 - util/subst.c | 4 +- 53 files changed, 1102 insertions(+), 812 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 include/mingw/arpa/inet.h
base-commit: aad34909b6648579f42dade5af5b46821aa4d845
Signature · 1 line
2.39.0
PATCH 1/38 configure.ac: only use Windows I/O manager on native Windows
From: Eric Biggers <[email protected]>
Cygwin and MSYS2 are UNIX-compatible platforms on top of Windows, so they should use the UNIX I/O manager, not the Windows I/O manager.
(Note that "cygwin" was misspelled as "cigwin", so the code did not have the intended effect anyway.)
--- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
@@ -1826,7 +1826,7 @@ dnl Adjust the compiled files if we are on windows vs everywhere else dnl OS_IO_FILE="" [case "$host_os" in - cigwin*|mingw*|msys*) + mingw*) OS_IO_FILE=windows_io ;; *)
Signature · 1 line
2.39.0
PATCH 2/38 configure.ac: disable tdb by default on Windows
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
The tdb support does not build for Windows, due to the use of various UNIX-isms, so disable it by default when building for Windows.
--- configure.ac | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
configure.ac +24 -8
@@ -845,23 +845,39 @@ dnl AH_TEMPLATE([CONFIG_TDB], [Define to 1 to enable tdb support]) AC_ARG_ENABLE([tdb], AS_HELP_STRING([--disable-tdb],[disable tdb support]), +[ if test "$enableval" = "no" then AC_MSG_RESULT([Disabling tdb support]) - TDB_CMT="#" - TDB_MAN_COMMENT='.\"' + CONFIG_TDB=0 else AC_MSG_RESULT([Enabling tdb support]) + CONFIG_TDB=1 +fi +] +, +[ +case "$host_os" in +mingw*) + AC_MSG_RESULT([Disabling tdb support by default]) + CONFIG_TDB=0 + ;; +*) + AC_MSG_RESULT([Enabling tdb support by default]) + CONFIG_TDB=1 + ;; +esac +] +) +if test "$CONFIG_TDB" = "1" +then AC_DEFINE(CONFIG_TDB, 1) TDB_CMT="" TDB_MAN_COMMENT="" +else + TDB_CMT="#" + TDB_MAN_COMMENT='.\"' fi -, -AC_MSG_RESULT([Enabling mmp support by default]) -AC_DEFINE(CONFIG_TDB, 1) -TDB_CMT="" -TDB_MAN_COMMENT="" -) AC_SUBST(TDB_CMT) AC_SUBST(TDB_MAN_COMMENT) dnl
Signature · 1 line
2.39.0
PATCH 3/38 configure.ac: automatically add include/mingw/ headers
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Since the include/mingw/ directory needs to be on the include path when building for Windows with MinGW, add it to INCLUDES automatically, and AC_DEFINE the corresponding HAVE_*_H constants.
--- configure.ac | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
configure.ac +16 -0
@@ -1036,6 +1036,17 @@ AC_CHECK_HEADERS(m4_flatten([ sys/wait.h sys/xattr.h ])) +case "$host_os" in +mingw*) + # The above checks only detect system headers, not the headers in + # ./include/mingw/, so explicitly define them to be available. + AC_DEFINE(HAVE_LINUX_TYPES_H, 1) + AC_DEFINE(HAVE_SYS_STAT_H, 1) + AC_DEFINE(HAVE_SYS_SYSMACROS_H, 1) + AC_DEFINE(HAVE_SYS_TYPES_H, 1) + AC_DEFINE(HAVE_UNISTD_H, 1) + ;; +esac dnl Check where to find a dd(1) that supports iflag=fullblock dnl and oflag=append AC_MSG_CHECKING([for a dd(1) program that supports iflag=fullblock])
@@ -1710,6 +1721,11 @@ fi if test -n "$WITH_DIET_LIBC" ; then INCLUDES="$INCLUDES -D_REENTRANT" fi +case "$host_os" in +mingw*) + INCLUDES=$INCLUDES' -I$(top_srcdir)/include/mingw' + ;; +esac AC_SUBST(INCLUDES) dnl dnl Build CFLAGS
Signature · 1 line
2.39.0
PATCH 4/38 configure: regenerate
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Run autoreconf.
--- aclocal.m4 | 180 ++++++++++++++++++++++++++---------------------- configure | 105 +++++++++++++++++++++------- lib/config.h.in | 100 ++++++++++++++++++++++----- 3 files changed, 262 insertions(+), 123 deletions(-)
aclocal.m4 +99 -81
@@ -535,7 +535,7 @@ fi AC_LANG_POP ])dnl AX_PTHREAD -# gettext.m4 serial 71 (gettext-0.20.2) +# gettext.m4 serial 72 (gettext-0.21.1) dnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it,
@@ -592,22 +592,22 @@ dnl AC_DEFUN([AM_GNU_GETTEXT], [ dnl Argument checking. - ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [use-libtool], , + m4_if([$1], [], , [m4_if([$1], [external], , [m4_if([$1], [use-libtool], , [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT ])])])]) - ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], + m4_if(m4_if([$1], [], [old])[]m4_if([$1], [no-libtool], [old]), [old], [errprint([ERROR: Use of AM_GNU_GETTEXT without [external] argument is no longer supported. ])]) - ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , + m4_if([$2], [], , [m4_if([$2], [need-ngettext], , [m4_if([$2], [need-formatstring-macros], , [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT ])])])]) define([gt_included_intl], - ifelse([$1], [external], [no], [yes])) + m4_if([$1], [external], [no], [yes])) gt_NEEDS_INIT AM_GNU_GETTEXT_NEED([$2]) AC_REQUIRE([AM_PO_SUBDIRS])dnl - ifelse(gt_included_intl, yes, [ + m4_if(gt_included_intl, yes, [ AC_REQUIRE([AM_INTL_SUBDIR])dnl ])
@@ -625,7 +625,7 @@ AC_DEFUN([AM_GNU_GETTEXT], dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. dnl Since AC_PROVIDE_IFELSE is not documented, we avoid it. - ifelse(gt_included_intl, yes, , [ + m4_if(gt_included_intl, yes, , [ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) ])
@@ -635,7 +635,7 @@ AC_DEFUN([AM_GNU_GETTEXT], dnl Set USE_NLS. AC_REQUIRE([AM_NLS]) - ifelse(gt_included_intl, yes, [ + m4_if(gt_included_intl, yes, [ BUILD_INCLUDED_LIBINTL=no USE_INCLUDED_LIBINTL=no ])
@@ -655,7 +655,7 @@ AC_DEFUN([AM_GNU_GETTEXT], dnl If we use NLS figure out what method if test "$USE_NLS" = "yes"; then gt_use_preinstalled_gnugettext=no - ifelse(gt_included_intl, yes, [ + m4_if(gt_included_intl, yes, [ AC_MSG_CHECKING([whether included gettext is requested]) AC_ARG_WITH([included-gettext], [ --with-included-gettext use the GNU gettext library included here],
@@ -711,7 +711,7 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then dnl Sometimes libintl requires libiconv, so first search for libiconv. - ifelse(gt_included_intl, yes, , [ + m4_if(gt_included_intl, yes, , [ AM_ICONV_LINK ]) dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
@@ -798,7 +798,7 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION INCINTL= fi - ifelse(gt_included_intl, yes, [ + m4_if(gt_included_intl, yes, [ if test "$gt_use_preinstalled_gnugettext" != "yes"; then dnl GNU gettext is not found in the C library. dnl Fall back on included GNU gettext library.
@@ -810,8 +810,8 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION dnl Mark actions used to generate GNU NLS library. BUILD_INCLUDED_LIBINTL=yes USE_INCLUDED_LIBINTL=yes - LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD" - LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD" + LIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD" + LTLIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD" LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` fi
@@ -878,7 +878,7 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION POSUB=po fi - ifelse(gt_included_intl, yes, [ + m4_if(gt_included_intl, yes, [ dnl In GNU gettext we have to set BUILD_INCLUDED_LIBINTL to 'yes' dnl because some of the testsuite requires it. BUILD_INCLUDED_LIBINTL=yes
@@ -922,8 +922,8 @@ AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version]) AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], []) -# host-cpu-c-abi.m4 serial 13 -dnl Copyright (C) 2002-2020 Free Software Foundation, Inc. +# host-cpu-c-abi.m4 serial 15 +dnl Copyright (C) 2002-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved.
@@ -1135,7 +1135,7 @@ changequote([,])dnl # be generating 64-bit code. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( - [[#if defined __powerpc64__ || defined _ARCH_PPC64 + [[#if defined __powerpc64__ || defined __LP64__ int ok; #else error fail
@@ -1306,6 +1306,9 @@ EOF #ifndef __ia64__ #undef __ia64__ #endif +#ifndef __loongarch64__ +#undef __loongarch64__ +#endif #ifndef __m68k__ #undef __m68k__ #endif
@@ -1529,7 +1532,7 @@ changequote([,])dnl # be generating 64-bit code. AC_COMPILE_IFELSE( [AC_LANG_SOURCE( - [[#if defined __powerpc64__ || defined _ARCH_PPC64 + [[#if defined __powerpc64__ || defined __LP64__ int ok; #else error fail
@@ -1598,8 +1601,8 @@ changequote([,])dnl HOST_CPU_C_ABI_32BIT="$gl_cv_host_cpu_c_abi_32bit" ]) -# iconv.m4 serial 21 -dnl Copyright (C) 2000-2002, 2007-2014, 2016-2020 Free Software Foundation, +# iconv.m4 serial 24 +dnl Copyright (C) 2000-2002, 2007-2014, 2016-2022 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it,
@@ -1607,6 +1610,12 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. +AC_PREREQ([2.64]) + +dnl Note: AM_ICONV is documented in the GNU gettext manual +dnl <https://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html>. +dnl Don't make changes that are incompatible with that documentation! + AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], [ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
@@ -1686,8 +1695,9 @@ AC_DEFUN([AM_ICONV_LINK], #endif ]], [[int result = 0; - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ + /* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from + successful returns. This is even documented in + <https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html> */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1))
@@ -1825,8 +1835,7 @@ AC_DEFUN([AM_ICONV_LINK], AC_SUBST([LTLIBICONV]) ]) -dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to -dnl avoid warnings like +dnl Define AM_ICONV using AC_DEFUN_ONCE, in order to avoid warnings like dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". dnl This is tricky because of the way 'aclocal' is implemented: dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
@@ -1834,61 +1843,50 @@ dnl Otherwise aclocal's initial scan pass would miss the macro definition. dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. dnl Otherwise aclocal would emit many "Use of uninitialized value $1" dnl warnings. -m4_define([gl_iconv_AC_DEFUN], - m4_version_prereq([2.64], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [m4_ifdef([gl_00GNULIB], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [[AC_DEFUN( - [$1], [$2])]])])) -gl_iconv_AC_DEFUN([AM_ICONV], +AC_DEFUN_ONCE([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then - AC_MSG_CHECKING([for iconv declaration]) - AC_CACHE_VAL([am_cv_proto_iconv], [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ + AC_CACHE_CHECK([whether iconv is compatible with its POSIX signature], + [gl_cv_iconv_nonconst], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ #include <stdlib.h> #include <iconv.h> extern #ifdef __cplusplus "C" #endif -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); -#else -size_t iconv(); -#endif - ]], - [[]])], - [am_cv_proto_iconv_arg1=""], - [am_cv_proto_iconv_arg1="const"]) - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) - am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - AC_MSG_RESULT([ - $am_cv_proto_iconv]) + ]], + [[]])], + [gl_cv_iconv_nonconst=yes], + [gl_cv_iconv_nonconst=no]) + ]) else dnl When compiling GNU libiconv on a system that does not have iconv yet, dnl pick the POSIX compliant declaration without 'const'. - am_cv_proto_iconv_arg1="" + gl_cv_iconv_nonconst=yes fi - AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], + if test $gl_cv_iconv_nonconst = yes; then + iconv_arg1="" + else + iconv_arg1="const" + fi + AC_DEFINE_UNQUOTED([ICONV_CONST], [$iconv_arg1], [Define as const if the declaration of iconv() needs const.]) dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>. m4_ifdef([gl_ICONV_H_DEFAULTS], [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) - if test -n "$am_cv_proto_iconv_arg1"; then + if test $gl_cv_iconv_nonconst != yes; then ICONV_CONST="const" fi ]) ]) # intlmacosx.m4 serial 8 (gettext-0.20.2) -dnl Copyright (C) 2004-2014, 2016, 2019-2020 Free Software Foundation, Inc. +dnl Copyright (C) 2004-2014, 2016, 2019-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved.
@@ -1953,8 +1951,8 @@ AC_DEFUN([gt_INTL_MACOSX], AC_SUBST([INTL_MACOSX_LIBS]) ]) -# lib-ld.m4 serial 9 -dnl Copyright (C) 1996-2003, 2009-2020 Free Software Foundation, Inc. +# lib-ld.m4 serial 10 +dnl Copyright (C) 1996-2003, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved.
@@ -2077,7 +2075,7 @@ else *-*-aix*) AC_COMPILE_IFELSE( [AC_LANG_SOURCE( - [[#if defined __powerpc64__ || defined _ARCH_PPC64 + [[#if defined __powerpc64__ || defined __LP64__ int ok; #else error fail
@@ -2122,8 +2120,8 @@ fi AC_LIB_PROG_LD_GNU ]) -# lib-link.m4 serial 31 -dnl Copyright (C) 2001-2020 Free Software Foundation, Inc. +# lib-link.m4 serial 33 +dnl Copyright (C) 2001-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved.
@@ -2320,8 +2318,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" ]) AC_ARG_WITH(PACK[-prefix], -[[ --with-]]PACK[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib - --without-]]PACK[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], +[[ --with-]]PACK[[-prefix[=DIR] search for ]]PACKLIBS[[ in DIR/include and DIR/lib + --without-]]PACK[[-prefix don't search for ]]PACKLIBS[[ in includedir and libdir]], [ if test "X$withval" = "Xno"; then use_additional=no
@@ -2755,7 +2753,20 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], ;; -l*) dnl Handle this in the next round. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + dnl But on GNU systems, ignore -lc options, because + dnl - linking with libc is the default anyway, + dnl - linking with libc.a may produce an error + dnl "/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/usr/lib/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie" + dnl or may produce an executable that always crashes, see + dnl <https://lists.gnu.org/archive/html/grep-devel/2020-09/msg00052.html>. + dep=`echo "X$dep" | sed -e 's/^X-l//'` + if test "X$dep" != Xc \ + || case $host_os in + linux* | gnu* | k*bsd*-gnu) false ;; + *) true ;; + esac; then + names_next_round="$names_next_round $dep" + fi ;; *.la) dnl Handle this in the next round. Throw away the .la's
@@ -2923,8 +2934,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], AC_SUBST([$1]) ]) -# lib-prefix.m4 serial 17 -dnl Copyright (C) 2001-2005, 2008-2020 Free Software Foundation, Inc. +# lib-prefix.m4 serial 20 +dnl Copyright (C) 2001-2005, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved.
@@ -3099,14 +3110,14 @@ AC_DEFUN([AC_LIB_PREPARE_MULTILIB], AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf], [AC_EGREP_CPP([Extensible Linking Format], - [#ifdef __ELF__ + [#if defined __ELF__ || (defined __linux__ && defined __EDG__) Extensible Linking Format #endif ], [gl_cv_elf=yes], [gl_cv_elf=no]) - ]) - if test $gl_cv_elf; then + ]) + if test $gl_cv_elf = yes; then # Extract the ELF class of a file (5th byte) in decimal. # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header if od -A x < /dev/null >/dev/null 2>/dev/null; then
@@ -3123,20 +3134,23 @@ AC_DEFUN([AC_LIB_PREPARE_MULTILIB], echo } fi + # Use 'expr', not 'test', to compare the values of func_elfclass, because on + # Solaris 11 OpenIndiana and Solaris 11 OmniOS, the result is 001 or 002, + # not 1 or 2. changequote(,)dnl case $HOST_CPU_C_ABI_32BIT in yes) # 32-bit ABI. acl_is_expected_elfclass () { - test "`func_elfclass | sed -e 's/[ ]//g'`" = 1 + expr "`func_elfclass | sed -e 's/[ ]//g'`" = 1 > /dev/null } ;; no) # 64-bit ABI. acl_is_expected_elfclass () { - test "`func_elfclass | sed -e 's/[ ]//g'`" = 2 + expr "`func_elfclass | sed -e 's/[ ]//g'`" = 2 > /dev/null } ;; *)
@@ -3245,7 +3259,7 @@ changequote([,])dnl ]) # nls.m4 serial 6 (gettext-0.20.2) -dnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016, 2019-2020 Free +dnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016, 2019-2022 Free dnl Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it,
@@ -3621,8 +3635,8 @@ AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) ])dnl PKG_HAVE_DEFINE_WITH_MODULES -# po.m4 serial 31 (gettext-0.20.2) -dnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc. +# po.m4 serial 32 (gettext-0.21.1) +dnl Copyright (C) 1995-2014, 2016, 2018-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved.
@@ -3802,7 +3816,9 @@ changequote([,])dnl # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in - "$presentlang"*) useit=yes;; + "$presentlang" | "$presentlang"_* | "$presentlang".* | "$presentlang"@*) + useit=yes + ;; esac done if test $useit = yes; then
@@ -4002,7 +4018,9 @@ changequote([,])dnl # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in - "$presentlang"*) useit=yes;; + "$presentlang" | "$presentlang"_* | "$presentlang".* | "$presentlang"@*) + useit=yes + ;; esac done if test $useit = yes; then
@@ -4072,8 +4090,8 @@ AC_DEFUN([AM_XGETTEXT_OPTION], XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1" ]) -# progtest.m4 serial 8 (gettext-0.20.2) -dnl Copyright (C) 1996-2003, 2005, 2008-2020 Free Software Foundation, Inc. +# progtest.m4 serial 9 (gettext-0.21.1) +dnl Copyright (C) 1996-2003, 2005, 2008-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved.
@@ -4090,7 +4108,7 @@ dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper <[email protected]>, 1996. -AC_PREREQ([2.50]) +AC_PREREQ([2.53]) # Search path for a program which passes the given test.
@@ -4135,7 +4153,7 @@ AC_CACHE_VAL([ac_cv_path_$1], ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in ifelse([$5], , $PATH, [$5]); do + for ac_dir in m4_if([$5], , $PATH, [$5]); do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do
@@ -4151,12 +4169,12 @@ AC_CACHE_VAL([ac_cv_path_$1], IFS="$ac_save_IFS" dnl If no 4th arg is given, leave the cache variable unset, dnl so AC_PATH_PROGS will keep looking. -ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" +m4_if([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" ])dnl ;; esac])dnl $1="$ac_cv_path_$1" -if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then +if test m4_if([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then AC_MSG_RESULT([$][$1]) else AC_MSG_RESULT([no])
configure +81 -24
207 lines not on this page · raw message
lib/config.h.in +82 -18
148 lines not on this page · raw message
Signature · 1 line
2.39.0
PATCH 5/38 config/install-sh: update to latest version
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
The version of install-sh in the source tree is extremely old and doesn't work when passed multiple path arguments, which breaks 'make install' on macOS.
Therefore, delete this file and run 'autoreconf -i' to update it to the latest version.
--- config/install-sh | 683 +++++++++++++++++++++++++++++++++------------- 1 file changed, 493 insertions(+), 190 deletions(-)
config/install-sh +493 -190
@@ -1,238 +1,541 @@ -#! /bin/sh -# +#!/bin/sh # install - install a program, script, or datafile -# This comes from X11R5. + +scriptversion=2020-11-14.01; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it +# 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. -# +tab=' ' +nl=' +' +IFS=" $tab$nl" + +# Set DOITPROG to "echo" to test this script. + +doit=${DOITPROG-} +doit_exec=${doit:-exec} -# set DOITPROG to echo to test this script +# Put in absolute file names if you don't have them in your path; +# or use environment vars. -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} +posix_mkdir= -# put in absolute paths if you don't have them in your path; or use env. vars. +# Desired mode of installed file. +mode=0755 -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" +# Create dirs (including intermediate dirs) using mode 755. +# This is like GNU 'install' as of coreutils 8.32 (2020). +mkdir_umask=22 -tranformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" +backupsuffix= +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done +stripcmd= -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi +src= +dst= +dir_arg= +dst_arg= -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else +copy_on_change=false +is_target_a_directory=possibly -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic +Options: + --help display this help and exit. + --version display version info and exit. - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi + -c (ignored) + -C install only if different (preserve data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -p pass -p to $cpprog. + -s $stripprog installed files. + -S SUFFIX attempt to back up existing files, with suffix SUFFIX. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script +By default, rm is invoked with -f; when overridden with RMPROG, +it's up to you to specify -f if you want it. -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" +If -S is not specified, no backups are attempted. -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" +Email bug reports to [email protected]. +Automake home page: https://www.gnu.org/software/automake/ +" -pathcomp='' +while test $# -ne 0; do + case $1 in + -c) ;; -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift + -C) copy_on_change=true;; - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi + -d) dir_arg=true;; - pathcomp="${pathcomp}/" -done -fi + -g) chgrpcmd="$chgrpprog $2" + shift;; -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && + --help) echo "$usage"; exit $?;; - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else + -m) mode=$2 + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -# If we're going to rename the final executable, determine the name now. + -o) chowncmd="$chownprog $2" + shift;; - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi + -p) cpprog="$cpprog -p";; -# don't allow the sed command to completely eliminate the filename + -s) stripcmd=$stripprog;; - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi + -S) backupsuffix="$2" + shift;; -# Make a temp file name in the proper directory. + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; - dsttmp=$dstdir/#inst.$$# + -T) is_target_a_directory=never;; -# Move or copy the file name to the temp name + --version) echo "$0 $scriptversion"; exit $?;; - $doit $instcmd $src $dsttmp && + --) shift + break;; - trap "rm -f ${dsttmp}" 0 && + -*) echo "$0: invalid option: $1" >&2 + exit 1;; -# and set any options; do chmod last to preserve setuid bits + *) break;; + esac + shift +done -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi -# Now rename the file to the real destination. +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call 'install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi -fi && +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi +for src +do + # Protect names problematic for 'test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + # Don't chown directories that already exist. + if test $dstdir_status = 0; then + chowncmd="" + fi + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename. + if test -d "$dst"; then + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dstbase=`basename "$src"` + case $dst in + */) dst=$dst$dstbase;; + *) dst=$dst/$dstbase;; + esac + dstdir_status=0 + else + dstdir=`dirname "$dst"` + test -d "$dstdir" + dstdir_status=$? + fi + fi + + case $dstdir in + */) dstdirslash=$dstdir;; + *) dstdirslash=$dstdir/;; + esac + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + # The $RANDOM variable is not portable (e.g., dash). Use it + # here however when possible just to lower collision chance. + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + + trap ' + ret=$? + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null + exit $ret + ' 0 + + # Because "mkdir -p" follows existing symlinks and we likely work + # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directory is successfully created first before we actually test + # 'mkdir -p'. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + oIFS=$IFS + IFS=/ + set -f + set fnord $dstdir + shift + set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=${dstdirslash}_inst.$$_ + rmtmp=${dstdirslash}_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && + { test -z "$stripcmd" || { + # Create $dsttmp read-write so that cp doesn't create it read-only, + # which would cause strip to fail. + if test -z "$doit"; then + : >"$dsttmp" # No need to fork-exec 'touch'. + else + $doit touch "$dsttmp" + fi + } + } && + $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + set +f && + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # If $backupsuffix is set, and the file being installed + # already exists, attempt a backup. Don't worry if it fails, + # e.g., if mv doesn't support -f. + if test -n "$backupsuffix" && test -f "$dst"; then + $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null + fi + + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done -exit 0 +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End:
Signature · 1 line
2.39.0
PATCH 6/38 lib, misc: eliminate dependency on Winsock
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Currently Windows builds of e2fsprogs rely on the Windows Socket API (Winsock) to provide htonl() and ntohl(). For this to actually work, though, HAVE_WINSOCK_H needs to be defined, and the binaries need to be linked to -lws2_32. The Android.bp files do this; however, the autotools-based build system does not.
Since htonl() and ntohl() are trivial, let's instead just add a file include/mingw/arpa/inet.h with definitions for these.
--- include/mingw/arpa/inet.h | 5 +++++ lib/e2p/Android.bp | 4 ---- lib/ext2fs/Android.bp | 2 -- lib/ext2fs/jfs_compat.h | 4 ---- misc/Android.bp | 1 - util/android_config.h | 1 - 6 files changed, 5 insertions(+), 12 deletions(-) create mode 100644 include/mingw/arpa/inet.h
include/mingw/arpa/inet.h new file +5 -0
@@ -0,0 +1,5 @@ +#pragma once + +/* Windows is always little endian. */ +#define htonl __builtin_bswap32 +#define ntohl __builtin_bswap32
lib/e2p/Android.bp +0 -4
@@ -59,10 +59,6 @@ cc_library { "-Wno-unused-variable", "-Wno-error=typedef-redefinition", ], - - host_ldlibs: [ - "-lws2_32", - ], }, },
lib/ext2fs/Android.bp +0 -2
@@ -126,8 +126,6 @@ cc_library { "-Wno-unused-variable", "-Wno-error=typedef-redefinition", ], - - host_ldlibs: ["-lws2_32"], }, },
lib/ext2fs/jfs_compat.h +0 -4
@@ -7,11 +7,7 @@#ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif -#ifdef HAVE_WINSOCK_H -#include <winsock.h> -#else #include <arpa/inet.h> -#endif #include <stdbool.h> #define printk printf
misc/Android.bp +0 -1
@@ -91,7 +91,6 @@ cc_binary { "-Wno-error" ], ldflags: ["-static"], - host_ldlibs: ["-lws2_32"], enabled: true }, android: {
util/android_config.h +0 -1
@@ -36,7 +36,6 @@#if defined(_WIN32)# define HAVE_LINUX_TYPES_H 1 -# define HAVE_WINSOCK_H 1#endif #if defined(__APPLE__) || defined(__linux__)# define HAVE_FCNTL 1
Signature · 1 line
2.39.0
PATCH 7/38 lib/blkid: remove 32-bit x86 byteswap assembly
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
libblkid contains 32-bit x86 assembly language implementations of 16-bit and 32-bit byteswaps. However, modern compilers can easily generate the bswap instruction automatically from the corresponding C expression. And no one ever bothered to add assembly for x86_64 or other architectures, anyway. So let's just remove this outdated code, which was maybe useful in the 90s, but is no longer useful.
--- lib/blkid/probe.h | 43 ------------------------------------------- 1 file changed, 43 deletions(-)
lib/blkid/probe.h +0 -43
@@ -814,46 +814,6 @@ struct exfat_entry_label {#define _INLINE_ static inline#endif -static __u16 blkid_swab16 (__u16 val); -static __u32 blkid_swab32 (__u32 val); -static __u64 blkid_swab64 (__u64 val); - -#if ((defined __GNUC__) && \ - (defined(__i386__) || defined(__i486__) || defined(__i586__))) - -#define _BLKID_HAVE_ASM_BITOPS_ - -_INLINE_ __u32 blkid_swab32(__u32 val) -{ -#ifdef EXT2FS_REQUIRE_486 - __asm__("bswap %0" :"=r" (val) :"0" (val)); -#else - __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ -"rorl $16,%0\n\t" /* swap words */ -"xchgb %b0,%h0" /* swap higher bytes */ - :"=q" (val) - :"0" (val)); -#endif -return val; -} - -_INLINE_ __u16 blkid_swab16(__u16 val) -{ - __asm__("xchgb %b0,%h0" /* swap bytes */ \ - :"=q" (val) \ - :"0" (val)); \ -return val; -} - -_INLINE_ __u64 blkid_swab64(__u64 val) -{ -return (blkid_swab32 (val >>32 ) | - (((__u64 )blkid_swab32 (val &0xFFFFFFFFUL )) <<32 )); -} -#endif - -#if !defined(_BLKID_HAVE_ASM_BITOPS_) - _INLINE_ __u16 blkid_swab16(__u16 val) {return (val >>8 ) | (val <<8 );
@@ -870,9 +830,6 @@ _INLINE_ __u64 blkid_swab64(__u64 val)return (blkid_swab32 (val >>32 ) | (((__u64 )blkid_swab32 (val &0xFFFFFFFFUL )) <<32 )); } -#endif - -#ifdef WORDS_BIGENDIAN #define blkid_le16 (x) blkid_swab16(x)
Signature · 1 line
2.39.0
Re: [PATCH 07/38] lib/blkid: remove 32-bit x86 byteswap assembly
Quoted 9 lines · Eric Biggers
From: Eric Biggers <[email protected]>
libblkid contains 32-bit x86 assembly language implementations of 16-bit and 32-bit byteswaps. However, modern compilers can easily generate the bswap instruction automatically from the corresponding C expression. And no one ever bothered to add assembly for
x86_64or other architectures, anyway. So let's just remove this outdated code, which was maybe useful in the 90s, but is no longer useful.
I'm not sure what Ted thinks about this, but it might be time to remove the libblkid implementation in e2fsprogs, and instead depend on the newer version in util-linux? However, removing it from e2fsprogs would add an external dependency on util-linux for non-linux platforms, though AFAIK it should still be possible to build e2fsprogs without it.
That said, I think the current patch looks fine, and you can add:
Cheers, Andreas
Quoted 68 lines
Signed-off-by Eric Biggers <[email protected]>---
lib/blkid/probe.h| 43 -------------------------------------------1 file changed, 43 deletions(-)lib/blkid/probe.h +0
-44@@ -814,46 +814,6 @@ struct exfat_entry_label {#define _INLINE_ static inline#endif -static __u16 blkid_swab16 (__u16 val); -static __u32 blkid_swab32 (__u32 val); -static __u64 blkid_swab64 (__u64 val); - -#if ((defined __GNUC__) && \ - (defined(__i386__) || defined(__i486__) || defined(__i586__))) - -#define _BLKID_HAVE_ASM_BITOPS_ - -_INLINE_ __u32 blkid_swab32(__u32 val) -{ -#ifdef EXT2FS_REQUIRE_486 - __asm__("bswap %0" :"=r" (val) :"0" (val)); -#else - __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ -"rorl $16,%0\n\t" /* swap words */ -"xchgb %b0,%h0" /* swap higher bytes */ - :"=q" (val) - :"0" (val)); -#endif -return val; -} - -_INLINE_ __u16 blkid_swab16(__u16 val) -{ - __asm__("xchgb %b0,%h0" /* swap bytes */ \ - :"=q" (val) \ - :"0" (val)); \ -return val; -} - -_INLINE_ __u64 blkid_swab64(__u64 val) -{ -return (blkid_swab32 (val >>32 ) | - (((__u64 )blkid_swab32 (val &0xFFFFFFFFUL )) <<32 )); -} -#endif - -#if !defined(_BLKID_HAVE_ASM_BITOPS_) - _INLINE_ __u16 blkid_swab16(__u16 val) {return (val >>8 ) | (val <<8 );@@ -870,9 +830,6 @@ _INLINE_ __u64 blkid_swab64(__u64 val)return (blkid_swab32 (val >>32 ) | (((__u64 )blkid_swab32 (val &0xFFFFFFFFUL )) <<32 )); } -#endif - -#ifdef WORDS_BIGENDIAN #define blkid_le16 (x) blkid_swab16(x) --
Quoted 2 lines
2.39.0
Cheers, Andreas
PATCH 8/38 lib/blkid: fix unaligned access to hfs_mdb
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
With -Wall, gcc warns:
./probe.c:1209:42: error: taking address of packed member of
'struct hfs_mdb' may result in an unaligned pointer value
This seems to be a real unaligned memory access bug, as the offset of the 64-bit value from the start of the buffer is 116, which is not a multiple of 8. Fix it by using memcpy().
Do the same for hfsplus to fix the same warning, though in that case the offset is a multiple of 8 so it was defined behavior.
--- lib/blkid/probe.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
lib/blkid/probe.c +4 -6
@@ -1198,7 +1198,6 @@ static int probe_hfs(struct blkid_probe *probe __BLKID_ATTR((unused)), unsigned char *buf) {struct hfs_mdb *hfs = (struct hfs_mdb *)buf; -unsigned long long *uuid_ptr;char uuid_str[17 ];__u64 uuid;
@@ -1206,8 +1205,8 @@ static int probe_hfs(struct blkid_probe *probe __BLKID_ATTR((unused)), (memcmp(hfs->embed_sig, "HX", 2) == 0))return 1 ;/* Not hfs, but an embedded HFS+ */ - uuid_ptr = (unsigned long long *)hfs->finder_info.id; - uuid =blkid_le64 (*uuid_ptr); +memcpy (&uuid, hfs->finder_info.id,8 ); + uuid =blkid_le64 (uuid);if (uuid) {sprintf (uuid_str,"%016llX" , uuid);blkid_set_tag (probe->dev,"UUID" , uuid_str,0 );
@@ -1243,7 +1242,6 @@ static int probe_hfsplus(struct blkid_probe *probe,unsigned int leaf_node_size;unsigned int leaf_block;unsigned int label_len; -unsigned long long *uuid_ptr;__u64 leaf_off, uuid;char uuid_str[17 ], label[512 ];int ext;
@@ -1274,8 +1272,8 @@ static int probe_hfsplus(struct blkid_probe *probe, (memcmp(hfsplus->signature, "HX", 2) != 0))return 1 ; - uuid_ptr = (unsigned long long *)hfsplus->finder_info.id; - uuid =blkid_le64 (*uuid_ptr); +memcpy (&uuid, hfsplus->finder_info.id,8 ); + uuid =blkid_le64 (uuid);if (uuid) {sprintf (uuid_str,"%016llX" , uuid);blkid_set_tag (probe->dev,"UUID" , uuid_str,0 );
Signature · 1 line
2.39.0
PATCH 9/38 lib/blkid: fix -Wunused-variable warning in blkid_get_dev_size()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
This showed up when building for Windows. It's hard to conditionally define this variable, so use the 'unused' attribute.
--- lib/blkid/Android.bp | 1 - lib/blkid/getsize.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
lib/blkid/Android.bp +0 -1
@@ -42,7 +42,6 @@ cc_library { include_dirs: ["external/e2fsprogs/include/mingw"], cflags: [ "-Wno-pointer-to-int-cast", - "-Wno-unused-variable", "-Wno-error=typedef-redefinition", ],
lib/blkid/getsize.c +1 -1
@@ -75,7 +75,7 @@ static int valid_offset(int fd, blkid_loff_t offset)*/ blkid_loff_t blkid_get_dev_size (int fd) { -unsigned long long size64; + unsigned long long size64 __BLKID_ATTR((unused));blkid_loff_t high, low;#if definedDKIOCGETBLOCKCOUNT && definedDKIOCGETBLOCKSIZE /* For Apple Darwin */
Signature · 1 line
2.39.0
PATCH 10/38 lib/blkid: suppress -Wunused-result warning in blkid_flush_cache()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
When _FORTIFY_SOURCE is defined, glibc annotates link() with the warn_unused_result function attribute. With gcc, that makes '(void) link()' cause a -Wunused-result warning, despite the explicit cast to void. That's annoying, since the use case in lib/blkid/save.c is legitimate (opportunistic backup). So let's suppress this warning.
--- lib/blkid/save.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/blkid/save.c +8 -0
@@ -154,7 +154,15 @@ int blkid_flush_cache(blkid_cache cache)if (backup) {sprintf (backup,"%s.old" , filename);unlink (backup); +#if defined(__GNUC__) && __GNUC__ >=5 +/* explicit (void) cast is not enough with glibc and _FORTIFY_SOURCE */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" +#endif (void )link (filename, backup); +#if defined(__GNUC__) && __GNUC__ >=5 +#pragma GCC diagnostic pop +#endif free (backup); }if (rename (opened, filename) <0 )
Signature · 1 line
2.39.0
PATCH 11/38 lib/blkid: suppress -Wstringop-truncation warning in blkid_strndup()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Unfortunately, gcc gets confused by blkid_strndup() and incorrectly thinks the destination string is not being null-terminated. This is part of -Wstringop-truncation, enabled automatically by -Wall in gcc 8 and later. Let's just suppress this warning here.
--- lib/blkid/devno.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/blkid/devno.c +10 -0
@@ -37,6 +37,12 @@#include "blkidP.h" +#if defined(__GNUC__) && __GNUC__ >=8 +/* gcc incorrectly thinks the destination string is not being null-terminated */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif +char *blkid_strndup (const char *s,int length) {char *ret;
@@ -55,6 +61,10 @@ char *blkid_strndup(const char *s, int length)return ret; } +#if defined(__GNUC__) && __GNUC__ >=8 +#pragma GCC diagnostic pop +#endif +char *blkid_strdup (const char *s) {return blkid_strndup (s,0 );
Signature · 1 line
2.39.0
PATCH 12/38 lib/e2p: fix a -Wunused-variable warning in getflags()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
This affected Windows builds.
--- lib/e2p/getflags.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/e2p/getflags.c +2 -1
@@ -30,8 +30,8 @@int getflags (int fd,unsigned long * flags) { -struct stat buf;#if HAVE_STAT_FLAGS +struct stat buf;if (fstat (fd, &buf) ==-1 )return -1 ;
@@ -53,6 +53,7 @@ int getflags (int fd, unsigned long * flags)return 0 ;#else #if HAVE_EXT2_IOCTLS +struct stat buf;int r, f; if (!fstat(fd, &buf) &&
Signature · 1 line
2.39.0
PATCH 13/38 lib/{e2p,ss}: remove manual declarations of errno
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
As per 'man 3 errno':
On some ancient systems, <errno.h> was not present or did not declare errno, so that it was necessary to declare errno manually
(i.e., extern int errno). **Do not do this**. It long ago ceased
to be necessary, and it will cause problems with modern versions of the C library.
One of the platforms it causes a problem on is Windows:
In file included from fgetversion.c:28:
fgetversion.c: In function ‘fgetversion’:
fgetversion.c:68:20: warning: ‘_errno’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
68 | extern int errno;
| ^~~~~
Just remove these obsolete manual declarations of errno.
--- lib/e2p/fgetversion.c | 2 -- lib/e2p/fsetversion.c | 1 - lib/e2p/getversion.c | 1 - lib/e2p/setversion.c | 1 - lib/ss/execute_cmd.c | 2 -- lib/ss/help.c | 2 -- lib/ss/pager.c | 2 -- 7 files changed, 11 deletions(-)
lib/e2p/fgetversion.c +0 -2
@@ -65,8 +65,6 @@ int fgetversion(const char *name, unsigned long *version) rc =syscall (SYS_fsctl, name,EXT2_IOC_GETVERSION , &ver,0 );# endif /* !APPLE_DARWIN */ #else /* ! HAVE_EXT2_IOCTLS */ -extern int errno; - errno =EOPNOTSUPP ;#endif /* ! HAVE_EXT2_IOCTLS */ if (rc ==0 )
lib/e2p/fsetversion.c +0 -1
@@ -65,7 +65,6 @@ int fsetversion (const char * name, unsigned long version)return syscall (SYS_fsctl, name,EXT2_IOC_SETVERSION , &ver,0 );#endif #else /* ! HAVE_EXT2_IOCTLS */ -extern int errno; errno =EOPNOTSUPP ;return -1 ;#endif /* ! HAVE_EXT2_IOCTLS */
lib/e2p/getversion.c +0 -1
@@ -35,7 +35,6 @@ int getversion (int fd, unsigned long * version) *version = ver;return r;#else /* ! HAVE_EXT2_IOCTLS */ -extern int errno; errno =EOPNOTSUPP ;return -1 ;#endif /* ! HAVE_EXT2_IOCTLS */
lib/e2p/setversion.c +0 -1
@@ -34,7 +34,6 @@ int setversion (int fd, unsigned long version) ver = (int ) version;return ioctl (fd,EXT2_IOC_SETVERSION , &ver);#else /* ! HAVE_EXT2_IOCTLS */ -extern int errno; errno =EOPNOTSUPP ;return -1 ;#endif /* ! HAVE_EXT2_IOCTLS */
lib/ss/execute_cmd.c +0 -2
@@ -17,8 +17,6 @@#endif #ifdef HAVE_ERRNO_H #include <errno.h> -#else -extern int errno;#endif #include "ss_internal.h" #include <stdio.h>
lib/ss/help.c +0 -2
@@ -20,8 +20,6 @@#endif #ifdef HAVE_ERRNO_H #include <errno.h> -#else -extern int errno;#endif #include <fcntl.h> #include <sys/param.h>
lib/ss/pager.c +0 -2
@@ -20,8 +20,6 @@#endif #ifdef HAVE_ERRNO_H #include <errno.h> -#else -extern int errno;#endif #include "ss_internal.h"
Signature · 1 line
2.39.0
PATCH 14/38 lib/et: fix "unused variable" warnings when !HAVE_FCNTL
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
In init_debug(), avoid -Wunused-variable and -Wunused-but-set-variable warnings when HAVE_FCNTL is not defined by only declaring 'fd' and 'flags' when HAVE_FCNTL is defined. This affected Windows builds.
--- lib/et/Android.bp | 3 --- lib/et/error_message.c | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-)
lib/et/Android.bp +0 -3
@@ -31,9 +31,6 @@ cc_library { target: { windows: { enabled: true, - cflags: [ - "-Wno-unused-variable", - ], }, },
lib/et/error_message.c +5 -5
@@ -235,7 +235,6 @@ static FILE *debug_f = 0;static void init_debug (void ) {char *dstr, *fn, *tmp; -int fd, flags;if (debug_mask &DEBUG_INIT )return ;
@@ -257,10 +256,12 @@ static void init_debug(void)if (!debug_f) debug_f =fopen ("/dev/tty" ,"a" );if (debug_f) { - fd =fileno (debug_f); -#if defined(HAVE_FCNTL ) +#ifdef HAVE_FCNTL +int fd =fileno (debug_f); +if (fd >=0 ) { - flags =fcntl (fd,F_GETFD ); +int flags =fcntl (fd,F_GETFD ); +if (flags >=0 ) flags =fcntl (fd,F_SETFD , flags |FD_CLOEXEC );if (flags <0 ) {
@@ -274,7 +275,6 @@ static void init_debug(void)#endif }else debug_mask =DEBUG_INIT ; - }/*
Signature · 1 line
2.39.0
PATCH 15/38 lib/ext2fs: remove 32-bit x86 bitops assembly
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
The EXT2FS_ADDR() macro is causing -Warray-bounds warnings because it (sort of) dereferences past the end of the input array. It's not a "real" dereference, since the result is passed as a memory operand to inline asm. But in the C language sense, it is a dereference.
Instead of trying to fix this code, let's consider that libext2fs *only* implements the bit operations in assembly for 32-bit x86, which is rarely used anymore. The fact that compilers have also improved, and no one has implemented these for another architecture, even x86_64, suggests it's not useful either. So, let's just remove this outdated code, which was maybe useful in the 90s, but now just causes problems.
--- lib/ext2fs/bitops.c | 14 +------ lib/ext2fs/bitops.h | 97 --------------------------------------------- 2 files changed, 2 insertions(+), 109 deletions(-)
lib/ext2fs/bitops.c +2 -12
@@ -19,14 +19,8 @@#include "ext2_fs.h" #include "ext2fs.h" -#ifndef _EXT2_HAVE_ASM_BITOPS_ -/* -* For the benefit of those who are trying to port Linux to another -* architecture, here are some C-language equivalents. You should -* recode these in the native assembly language, if at all possible. -* -* C language equivalents written by Theodore Ts'o, 9/26/92. +* C language bitmap functions written by Theodore Ts'o, 9/26/92. * Modified by Pete A. Zaitcev 7/14/95 to be portable to big endian * systems, as well as non-32 bit systems. */
@@ -65,8 +59,6 @@ int ext2fs_test_bit(unsigned int nr, const void * addr)return (mask & *ADDR ); } -#endif /* !_EXT2_HAVE_ASM_BITOPS_ */ -void ext2fs_warn_bitmap (errcode_t errcode,unsigned long arg,const char *description) {
@@ -78,9 +70,7 @@ void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,#endif } -/* -* C-only 64 bit ops. -*/ +/* Bitmap functions that take a 64-bit offset */ int ext2fs_set_bit64 (__u64 nr,void * addr) {
lib/ext2fs/bitops.h +0 -97
124 lines not on this page · raw message
Signature · 1 line
2.39.0
PATCH 16/38 lib/ext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Since the 'now' variable is only used to calculate 'inuse', and 'inuse' is only used when defined(ENABLE_BMAP_STATS_OPS), it makes sense to guard the declaration and initialization of 'now' and 'inuse' by the same condition, just like the '*_perc' variables in the same function.
This addresses the following compiler warning with clang -Wall:
gen_bitmap64.c:187:9: warning: variable 'inuse' set but not used [-Wunused-but-set-variable]
double inuse;
^--- lib/ext2fs/gen_bitmap64.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/ext2fs/gen_bitmap64.c +2 -4
@@ -183,11 +183,9 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap)#ifdef ENABLE_BMAP_STATS_OPS float mark_seq_perc =0.0 , test_seq_perc =0.0 ;float mark_back_perc =0.0 , test_back_perc =0.0 ; -#endif -double inuse;struct timeval now; +double inuse; -#ifdef ENABLE_BMAP_STATS_OPS if (stats->test_count) { test_seq_perc = ((float )stats->test_seq / stats->test_count) *100 ;
@@ -201,7 +199,6 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap) mark_back_perc = ((float )stats->mark_back / stats->mark_count) *100 ; } -#endif if (gettimeofday (&now, (struct timezone *)NULL ) ==-1 ) {perror ("gettimeofday" );
@@ -212,6 +209,7 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap) (((double ) now.tv_usec) *0.000001 ); inuse -= (double ) stats->created.tv_sec + \ (((double ) stats->created.tv_usec) *0.000001 ); +#endif /* ENABLE_BMAP_STATS_OPS */ fprintf (stderr,"\n[+] %s bitmap (type %d)\n" , bitmap->description, stats->type);
Signature · 1 line
2.39.0
PATCH 17/38 lib/ext2fs: remove unused variable in ext2fs_xattrs_read_inode()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Address the following compiler warning with gcc -Wall:
ext_attr.c: In function ‘ext2fs_xattrs_read_inode’:
ext_attr.c:1000:16: warning: unused variable ‘i’ [-Wunused-variable]
1000 | size_t i;
| ^
--- lib/ext2fs/ext_attr.c | 2 -- 1 file changed, 2 deletions(-)
lib/ext2fs/ext_attr.c +0 -2
@@ -991,13 +991,11 @@ static void xattrs_free_keys(struct ext2_xattr_handle *h)errcode_t ext2fs_xattrs_read_inode (struct ext2_xattr_handle *handle,struct ext2_inode_large *inode) { -struct ext2_ext_attr_header *header;__u32 ea_inode_magic;unsigned int storage_size;char *start, *block_buf =NULL ;blk64_t blk; -size_t i;errcode_t err =0 ;EXT2_CHECK_MAGIC (handle,EXT2_ET_MAGIC_EA_HANDLE );
Signature · 1 line
2.39.0
PATCH 18/38 lib/ext2fs: fix a printf format specifier in file_test()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
size_t should be matched by %zu, not %lu. This fixes a -Wformat warning when building for 32-bit x86.
--- lib/ext2fs/inline_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ext2fs/inline_data.c +1 -1
@@ -653,7 +653,7 @@ static errcode_t file_test(ext2_filsys fs)if (size !=BUFF_SIZE ) {fprintf (stderr, -"tst_inline_data: size %lu != buflen %u\n" , +"tst_inline_data: size %zu != buflen %u\n" , size,BUFF_SIZE ); retval =1 ; goto err;
Signature · 1 line
2.39.0
PATCH 19/38 lib/ext2fs: fix two compiler warnings in windows_io.c
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
init_private_data() triggers a -Wstringop-truncation warning, due to a real bug. Fix it.
windows_open() has a -Wunused-variable warning because some macOS-specific code was copied there for no reason. Remove it.
--- lib/ext2fs/windows_io.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
lib/ext2fs/windows_io.c +1 -11
@@ -499,9 +499,6 @@ static errcode_t windows_open_channel(struct windows_private_data *data,#if defined(O_DIRECT )if (flags &IO_FLAG_DIRECT_IO ) io->align =ext2fs_get_dio_alignment (data->dev); -#elif defined(F_NOCACHE ) -if (flags &IO_FLAG_DIRECT_IO ) - io->align =4096 ;#endif /*
@@ -609,7 +606,7 @@ static struct windows_private_data *init_private_data(const char *name, int flagreturn NULL ;memset (data,0 ,sizeof (struct windows_private_data )); -strncpy (data->name, name,sizeof (data->name)); +strncpy (data->name, name,sizeof (data->name) -1 ); data->magic =EXT2_ET_MAGIC_WINDOWS_IO_CHANNEL ; data->io_stats.num_fields =2 ; data->flags = flags;
@@ -620,7 +617,6 @@ static struct windows_private_data *init_private_data(const char *name, int flagstatic errcode_t windows_open (const char *name,int flags,io_channel *channel) { -int fd =-1 ;int open_flags;struct windows_private_data *data;
@@ -644,12 +640,6 @@ static errcode_t windows_open(const char *name, int flags, io_channel *channel)return EXT2_ET_BAD_DEVICE_NAME ; } -#if defined(F_NOCACHE ) && !defined(IO_DIRECT ) -if (flags &IO_FLAG_DIRECT_IO ) { -if (fcntl (fd,F_NOCACHE ,1 ) <0 ) -return errno; - } -#endif return windows_open_channel (data, flags, channel, windows_io_manager); }
Signature · 1 line
2.39.0
PATCH 20/38 lib/ext2fs: fix a -Wpointer-sign warning in ext2fs_mmp_start()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
This showed up when building for Windows.
--- lib/ext2fs/mmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ext2fs/mmp.c +1 -1
@@ -356,7 +356,7 @@ clean_seq:#ifdef HAVE_GETHOSTNAME gethostname ((char *) mmp_s->mmp_nodename,sizeof (mmp_s->mmp_nodename));#else -strcpy (mmp_s->mmp_nodename,"unknown host" ); +strcpy ((char *) mmp_s->mmp_nodename,"unknown host" );#endif strncpy ((char *) mmp_s->mmp_bdevname, fs->device_name,sizeof (mmp_s->mmp_bdevname));
Signature · 1 line
2.39.0
PATCH 21/38 lib/{ext2fs,support}: fix 32-bit Windows build
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
_WIN32 is the standard macro to detect (native) Windows, regardless of 32-bit or 64-bit. _WIN64 is for 64-bit Windows only. Use _WIN32 where _WIN64 was incorrectly being used.
This fixes several 32-bit Windows build errors, for example this one:
plausible.c: In function ‘print_ext2_info’:
plausible.c:109:31: error: ‘unix_io_manager’ undeclared (first use in this function); did you mean ‘undo_io_manager’?
109 | unix_io_manager,
| ^~~~~~~~~~~~~~~
| undo_io_manager--- lib/ext2fs/getsectsize.c | 12 ++++++------ lib/support/plausible.c | 2 +- util/subst.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
lib/ext2fs/getsectsize.c +6 -6
@@ -51,10 +51,10 @@*/ errcode_t ext2fs_get_device_sectsize (const char *file,int *sectsize) { -#ifdef _WIN64 +#ifdef _WIN32 *sectsize =512 ;// just guessing return 0 ; -#else // not _WIN64 +#else // not _WIN32 int fd;
@@ -78,7 +78,7 @@ errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)close (fd);return 0 ; -#endif // ifdef _WIN64 +#endif // ifdef _WIN32 }/*
@@ -117,11 +117,11 @@ int ext2fs_get_dio_alignment(int fd)*/ errcode_t ext2fs_get_device_phys_sectsize (const char *file,int *sectsize) { -#ifdef _WIN64 +#ifdef _WIN32return ext2fs_get_device_sectsize (file, sectsize); -#else // not _WIN64 +#else // not _WIN32 int fd;
@@ -147,5 +147,5 @@ errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize)close (fd);return 0 ; -#endif // ifdef _WIN64 +#endif // ifdef _WIN32 }
lib/support/plausible.c +1 -1
@@ -103,7 +103,7 @@ static void print_ext2_info(const char *device)time_t tm; retval = ext2fs_open2(device, 0, EXT2_FLAG_64BITS, 0, 0, -#ifdef _WIN64 +#ifdef _WIN32 windows_io_manager, #else unix_io_manager,
util/subst.c +2 -2
@@ -434,7 +434,7 @@ int main(int argc, char **argv)printf ("Using original atime\n" );set_utimes (outfn,fileno (old), tv); } -#ifndef _WIN64 +#ifndef _WIN32if (ofd >=0 ) (void )fchmod (ofd,0444 );#endif
@@ -444,7 +444,7 @@ int main(int argc, char **argv) }else {if (verbose)printf ("Creating or replacing %s.\n" , outfn); -#ifndef _WIN64 +#ifndef _WIN32if (ofd >=0 ) (void )fchmod (ofd,0444 );#endif
Signature · 1 line
2.39.0
PATCH 22/38 lib/ss: fix 'make install' by creating man1dir
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
'make install' does not work because libss tries to install a man page without creating the directory first. Fix this.
--- lib/ss/Makefile.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/ss/Makefile.in +3 -2
@@ -125,10 +125,11 @@ ss.pc: $(srcdir)/ss.pc.in $(top_builddir)/config.status $(Q) cd $(top_builddir); CONFIG_FILES=lib/ss/ss.pc ./config.status installdirs:: - $(E) " MKDIR_P $(libdir) $(includedir)/ss $(datadir)/ss $(bindir)" + $(E) " MKDIR_P $(libdir) $(includedir)/ss $(datadir)/ss $(bindir) $(pkgconfigdir) $(man1dir)" $(Q) $(MKDIR_P) $(DESTDIR)$(libdir) \ $(DESTDIR)$(includedir)/ss $(DESTDIR)$(datadir)/ss \ - $(DESTDIR)$(bindir) $(DESTDIR)$(pkgconfigdir) + $(DESTDIR)$(bindir) $(DESTDIR)$(pkgconfigdir) \ + $(DESTDIR)$(man1dir) install:: libss.a $(INSTALL_HFILES) installdirs ss_err.h mk_cmds ss.pc $(E) " INSTALL_DATA $(DESTDIR)$(libdir)/libss.a"
Signature · 1 line
2.39.0
PATCH 23/38 lib/support: remove unused label in get_devname()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Address the following compiler warning with gcc -Wall:
devname.c: In function ‘get_devname’:
devname.c:61:1: warning: label ‘out_strdup’ defined but not used [-Wunused-label]
61 | out_strdup:
| ^~~~~~~~~~
--- lib/support/devname.c | 1 - 1 file changed, 1 deletion(-)
lib/support/devname.c +0 -1
@@ -58,7 +58,6 @@ char *get_devname(blkid_cache cache, const char *token, const char *value) goto out; } -out_strdup:if (is_file) ret =strdup (token); out:
Signature · 1 line
2.39.0
PATCH 24/38 lib/support: clean up definition of flags_array
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Add braces to address the following compiler warning with gcc -Wall:
print_fs_flags.c:24:42: warning: missing braces around initializer [-Wmissing-braces]
24 | static struct flags_name flags_array[] = {
| ^
Also add 'const', and add an explicit NULL in the last entry.
--- lib/support/print_fs_flags.c | 60 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-)
lib/support/print_fs_flags.c +30 -30
@@ -21,40 +21,40 @@ struct flags_name {const char *name; }; -static struct flags_name flags_array[] = { -EXT2_FLAG_RW ,"EXT2_FLAG_RW" , -EXT2_FLAG_CHANGED ,"EXT2_FLAG_CHANGED" , -EXT2_FLAG_DIRTY ,"EXT2_FLAG_DIRTY" , -EXT2_FLAG_VALID ,"EXT2_FLAG_VALID" , -EXT2_FLAG_IB_DIRTY ,"EXT2_FLAG_IB_DIRTY" , -EXT2_FLAG_BB_DIRTY ,"EXT2_FLAG_BB_DIRTY" , -EXT2_FLAG_SWAP_BYTES ,"EXT2_FLAG_SWAP_BYTES" , -EXT2_FLAG_SWAP_BYTES_READ ,"EXT2_FLAG_SWAP_BYTES_READ" , -EXT2_FLAG_SWAP_BYTES_WRITE ,"EXT2_FLAG_SWAP_BYTES_WRITE" , -EXT2_FLAG_MASTER_SB_ONLY ,"EXT2_FLAG_MASTER_SB_ONLY" , -EXT2_FLAG_FORCE ,"EXT2_FLAG_FORCE" , -EXT2_FLAG_SUPER_ONLY ,"EXT2_FLAG_SUPER_ONLY" , -EXT2_FLAG_JOURNAL_DEV_OK ,"EXT2_FLAG_JOURNAL_DEV_OK" , -EXT2_FLAG_IMAGE_FILE ,"EXT2_FLAG_IMAGE_FILE" , -EXT2_FLAG_EXCLUSIVE ,"EXT2_FLAG_EXCLUSIVE" , -EXT2_FLAG_SOFTSUPP_FEATURES ,"EXT2_FLAG_SOFTSUPP_FEATURES" , -EXT2_FLAG_NOFREE_ON_ERROR ,"EXT2_FLAG_NOFREE_ON_ERROR" , -EXT2_FLAG_64BITS ,"EXT2_FLAG_64BITS" , -EXT2_FLAG_PRINT_PROGRESS ,"EXT2_FLAG_PRINT_PROGRESS" , -EXT2_FLAG_DIRECT_IO ,"EXT2_FLAG_DIRECT_IO" , -EXT2_FLAG_SKIP_MMP ,"EXT2_FLAG_SKIP_MMP" , -EXT2_FLAG_IGNORE_CSUM_ERRORS ,"EXT2_FLAG_IGNORE_CSUM_ERRORS" , -EXT2_FLAG_SHARE_DUP ,"EXT2_FLAG_SHARE_DUP" , -EXT2_FLAG_IGNORE_SB_ERRORS ,"EXT2_FLAG_IGNORE_SB_ERRORS" , -EXT2_FLAG_BBITMAP_TAIL_PROBLEM ,"EXT2_FLAG_BBITMAP_TAIL_PROBLEM" , -EXT2_FLAG_IBITMAP_TAIL_PROBLEM ,"EXT2_FLAG_IBITMAP_TAIL_PROBLEM" , -EXT2_FLAG_THREADS ,"EXT2_FLAG_THREADS" , -0 +static const struct flags_name flags_array[] = { + {EXT2_FLAG_RW ,"EXT2_FLAG_RW" }, + {EXT2_FLAG_CHANGED ,"EXT2_FLAG_CHANGED" }, + {EXT2_FLAG_DIRTY ,"EXT2_FLAG_DIRTY" }, + {EXT2_FLAG_VALID ,"EXT2_FLAG_VALID" }, + {EXT2_FLAG_IB_DIRTY ,"EXT2_FLAG_IB_DIRTY" }, + {EXT2_FLAG_BB_DIRTY ,"EXT2_FLAG_BB_DIRTY" }, + {EXT2_FLAG_SWAP_BYTES ,"EXT2_FLAG_SWAP_BYTES" }, + {EXT2_FLAG_SWAP_BYTES_READ ,"EXT2_FLAG_SWAP_BYTES_READ" }, + {EXT2_FLAG_SWAP_BYTES_WRITE ,"EXT2_FLAG_SWAP_BYTES_WRITE" }, + {EXT2_FLAG_MASTER_SB_ONLY ,"EXT2_FLAG_MASTER_SB_ONLY" }, + {EXT2_FLAG_FORCE ,"EXT2_FLAG_FORCE" }, + {EXT2_FLAG_SUPER_ONLY ,"EXT2_FLAG_SUPER_ONLY" }, + {EXT2_FLAG_JOURNAL_DEV_OK ,"EXT2_FLAG_JOURNAL_DEV_OK" }, + {EXT2_FLAG_IMAGE_FILE ,"EXT2_FLAG_IMAGE_FILE" }, + {EXT2_FLAG_EXCLUSIVE ,"EXT2_FLAG_EXCLUSIVE" }, + {EXT2_FLAG_SOFTSUPP_FEATURES ,"EXT2_FLAG_SOFTSUPP_FEATURES" }, + {EXT2_FLAG_NOFREE_ON_ERROR ,"EXT2_FLAG_NOFREE_ON_ERROR" }, + {EXT2_FLAG_64BITS ,"EXT2_FLAG_64BITS" }, + {EXT2_FLAG_PRINT_PROGRESS ,"EXT2_FLAG_PRINT_PROGRESS" }, + {EXT2_FLAG_DIRECT_IO ,"EXT2_FLAG_DIRECT_IO" }, + {EXT2_FLAG_SKIP_MMP ,"EXT2_FLAG_SKIP_MMP" }, + {EXT2_FLAG_IGNORE_CSUM_ERRORS ,"EXT2_FLAG_IGNORE_CSUM_ERRORS" }, + {EXT2_FLAG_SHARE_DUP ,"EXT2_FLAG_SHARE_DUP" }, + {EXT2_FLAG_IGNORE_SB_ERRORS ,"EXT2_FLAG_IGNORE_SB_ERRORS" }, + {EXT2_FLAG_BBITMAP_TAIL_PROBLEM ,"EXT2_FLAG_BBITMAP_TAIL_PROBLEM" }, + {EXT2_FLAG_IBITMAP_TAIL_PROBLEM ,"EXT2_FLAG_IBITMAP_TAIL_PROBLEM" }, + {EXT2_FLAG_THREADS ,"EXT2_FLAG_THREADS" }, + {0 ,NULL }, };void print_fs_flags (FILE * f,unsigned long flags) { -struct flags_name *fp; +const struct flags_name *fp;int first =1 , pos =16 ;for (fp = flags_array; fp->flag !=0 ; fp++) {
Signature · 1 line
2.39.0
PATCH 25/38 lib/uuid: remove conflicting Windows implementation of gettimeofday()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
When building libuuid for Windows with MinGW with the default settings, there is a build error in lib/uuid/gen_uuid.c because the explicit definition of gettimeofday() conflicts with MinGW's declaration of gettimeofday(). gen_uuid.c apparently expects USE_MINGW to be defined to avoid that, but the build system doesn't actually do that.
Since native Windows builds of e2fsprogs are currently only supported via MinGW anyway (in particular, Visual Studio is not supported), let's fix this by just removing our own definition of gettimeofday().
--- lib/uuid/gen_uuid.c | 21 --------------------- 1 file changed, 21 deletions(-)
lib/uuid/gen_uuid.c +0 -21
@@ -117,27 +117,6 @@THREAD_LOCAL unsigned short jrand_seed[3 ];#endif -#ifdef _WIN32 -#ifndef USE_MINGW -static void gettimeofday (struct timeval *tv,void *dummy) -{ -FILETIME ftime; -uint64_t n; - -GetSystemTimeAsFileTime (&ftime); - n = (((uint64_t ) ftime.dwHighDateTime <<32 ) - + (uint64_t ) ftime.dwLowDateTime); -if (n) { - n /=10 ; - n -= ((369 *365 +89 ) * (uint64_t )86400 ) *1000000 ; - } - - tv->tv_sec = n /1000000 ; - tv->tv_usec = n %1000000 ; -} -#endif -#endif -static int get_random_fd (void ) {struct timeval tv;
Signature · 1 line
2.39.0
PATCH 26/38 e2fsck: use real functions for kernel slab functions
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
The macros that e2fsck uses to implement kmalloc et al. use only some of their arguments, so unlike standard function calls, they can cause compiler warnings like:
./../e2fsck/revoke.c:141:8: warning: variable 'gfp_mask' set but not used [-Wunused-but-set-variable]
Fix this by providing a proper definition for each function, making sure to match the function prototypes used in the kernel.
Remove the kmem_cache_t typedef, as it doesn't exist in the kernel.
--- e2fsck/jfs_user.h | 62 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 17 deletions(-)
e2fsck/jfs_user.h +45 -17
@@ -82,16 +82,9 @@ struct kdev_s {#define buffer_req (bh) 1#define do_readahead (journal, start) do {} while (0) -typedef struct kmem_cache { -int object_length; -}kmem_cache_t ; - -#define kmem_cache_alloc (cache, flags) malloc((cache)->object_length) -#define kmem_cache_free (cache, obj) free(obj) -#define kmem_cache_create (name, len, a, b, c) do_cache_create(len) -#define kmem_cache_destroy (cache) do_cache_destroy(cache) -#define kmalloc (len, flags) malloc(len) -#define kfree (p) free(p) +struct kmem_cache { +unsigned int object_size; +};#define cond_resched () do { } while (0)
@@ -107,8 +100,16 @@ typedef struct kmem_cache {* functions. */ #ifdef NO_INLINE_FUNCS -extern kmem_cache_t *do_cache_create (int len); -extern void do_cache_destroy (kmem_cache_t *cache); +extern struct kmem_cache *kmem_cache_create (const char *name, +unsigned int size, +unsigned int align, +unsigned int flags, +void (*ctor)(void *)); +extern void kmem_cache_destroy (struct kmem_cache *s); +extern void *kmem_cache_alloc (struct kmem_cache *cachep,gfp_t flags); +extern void kmem_cache_free (struct kmem_cache *s,void *objp); +extern void *kmalloc (size_t size,gfp_t flags); +extern void kfree (const void *objp);extern size_t journal_tag_bytes (journal_t *journal);extern __u32 __hash_32 (__u32 val);extern __u32 hash_32 (__u32 val,unsigned int bits);
@@ -139,19 +140,46 @@ extern void jbd2_descriptor_block_csum_set(journal_t *j,#endif /* __STDC_VERSION__ >= 199901L */ #endif /* E2FSCK_INCLUDE_INLINE_FUNCS */ -_INLINE_ kmem_cache_t *do_cache_create(int len) +_INLINE_ struct kmem_cache * +kmem_cache_create(const char *name EXT2FS_ATTR((unused)), + unsigned int size, + unsigned int align EXT2FS_ATTR((unused)), + unsigned int flags EXT2FS_ATTR((unused)), + void (*ctor)(void *) EXT2FS_ATTR((unused))) { -kmem_cache_t *new_cache; + struct kmem_cache *new_cache; new_cache =malloc (sizeof (*new_cache));if (new_cache) - new_cache->object_length = len; + new_cache->object_size = size;return new_cache; } -_INLINE_ void do_cache_destroy(kmem_cache_t *cache) +_INLINE_ void kmem_cache_destroy(struct kmem_cache *s) +{ +free (s); +} + +_INLINE_ void *kmem_cache_alloc(struct kmem_cache *cachep, + gfp_t flags EXT2FS_ATTR((unused))) +{ +return malloc (cachep->object_size); +} + +_INLINE_ void kmem_cache_free(struct kmem_cache *s EXT2FS_ATTR((unused)), + void *objp) +{ +free (objp); +} + +_INLINE_ void *kmalloc(size_t size, gfp_t flags EXT2FS_ATTR((unused))) +{ +return malloc (size); +} + +_INLINE_ void kfree(const void *objp) { -free (cache); +free ((void *)objp); }/* generic hashing taken from the Linux kernel */
Signature · 1 line
2.39.0
PATCH 27/38 misc/create_inode: fix -Wunused-variable warnings in __populate_fs()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
These showed up when building for Windows.
--- misc/create_inode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
misc/create_inode.c +6 -4
@@ -813,11 +813,9 @@ static errcode_t __populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,const char *name;struct dirent **dent;struct stat st; -char *ln_target =NULL ;unsigned int save_inode;ext2_ino_t ino;errcode_t retval =0 ; -int read_cnt;int hdlink;size_t cur_dir_path_len;int i, num_dents;
@@ -900,7 +898,10 @@ static errcode_t __populate_fs(ext2_filsys fs, ext2_ino_t parent_ino, goto out; }break ; -case S_IFLNK : +case S_IFLNK : { +char *ln_target; +int read_cnt; + ln_target =malloc (st.st_size +1 );if (ln_target ==NULL ) { com_err(__func__, retval,
@@ -935,7 +936,8 @@ static errcode_t __populate_fs(ext2_filsys fs, ext2_ino_t parent_ino, goto out; }break ; -#endif + } +#endif /* !_WIN32 */ case S_IFREG : retval =do_write_internal (fs, parent_ino, name, name, root);
Signature · 1 line
2.39.0
PATCH 28/38 misc/create_inode: simplify logic in scandir()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
The control flow in scandir() (only used on Windows) confuses gcc into thinking that *name_list is not always set on success, which causes a -Wmaybe-uninitialized warning in __populate_fs(). As far as I can tell it's a false positive; however, avoid it by cleanly separating the success and failure cases in scandir().
--- misc/create_inode.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
misc/create_inode.c +10 -16
@@ -763,39 +763,33 @@ static int scandir(const char *dir_name, struct dirent ***name_list,size_t new_list_size = temp_list_size +32 ;struct dirent **new_list = (struct dirent **)realloc ( temp_list, new_list_size *sizeof (struct dirent *)); -if (new_list ==NULL ) { - goto out; - } +if (new_list ==NULL ) + goto out_err; temp_list_size = new_list_size; temp_list = new_list; }// add the copy of dirent to the list temp_list[num_dent] = (struct dirent *)malloc ((dent->d_reclen +3 ) & ~3 );if (!temp_list[num_dent]) - goto out; + goto out_err;memcpy (temp_list[num_dent], dent, dent->d_reclen); num_dent++; } +closedir (dir);if (compar !=NULL ) {qsort (temp_list, num_dent,sizeof (struct dirent *), (int (*)(const void *,const void *))compar); } - -// release the temp list *name_list = temp_list; - temp_list =NULL ; +return num_dent; -out: -if (temp_list !=NULL ) { -while (num_dent >0 ) { -free (temp_list[--num_dent]); - } -free (temp_list); - num_dent =-1 ; - } +out_err:closedir (dir); -return num_dent; +while (num_dent >0 ) +free (temp_list[--num_dent]); +free (temp_list); +return -1 ; }static int alphasort (const struct dirent **a,const struct dirent **b) {
Signature · 1 line
2.39.0
PATCH 29/38 misc/e4defrag: fix -Wstringop-truncation warnings
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Fix two -Wstringop-truncation warnings in is_ext4() by simplifying how how mnt_type is handled and by using the correct bound for mnt_fsname.
Fix a -Wstringop-truncation warning in main() by replacing the fragile pattern 'strncpy(dst, src, strnlen(src, N))', which doesn't null-terminate the destination string, with a standard string copy. (It happened to work anyway because dst happens to be zero-initialized.)
These warnings showed up when building with -Wall with gcc 8 or later.
--- misc/e4defrag.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-)
misc/e4defrag.c +9 -21
@@ -258,12 +258,12 @@ static int get_mount_point(const char *devname, char *mount_point,* * @file: the file's name. */ -static int is_ext4 (const char *file,char *devname) +static int is_ext4 (const char *file,char devname[PATH_MAX +1 ]) {int maxlen =0 ;int len, ret; +int type_is_ext4 =0 ;FILE *fp =NULL ; -char *mnt_type =NULL ;/* Refer to /etc/mtab */ const char *mtab =MOUNTED ;char file_path[PATH_MAX +1 ];
@@ -307,26 +307,16 @@ static int is_ext4(const char *file, char *devname) maxlen = len; - mnt_type =realloc (mnt_type,strlen (mnt->mnt_type) +1 ); -if (mnt_type ==NULL ) { -endmntent (fp); -return -1 ; - } -memset (mnt_type,0 ,strlen (mnt->mnt_type) +1 ); -strncpy (mnt_type, mnt->mnt_type,strlen (mnt->mnt_type)); + type_is_ext4 = !strcmp (mnt->mnt_type,FS_EXT4 );strncpy (lost_found_dir, mnt->mnt_dir,PATH_MAX ); -strncpy (devname, mnt->mnt_fsname,strlen (mnt->mnt_fsname) +1 ); +strncpy (devname, mnt->mnt_fsname,PATH_MAX ); }endmntent (fp); -if (mnt_type &&strcmp (mnt_type,FS_EXT4 ) ==0 ) { -FREE (mnt_type); +if (type_is_ext4)return 0 ; - }else { -FREE (mnt_type); -PRINT_ERR_MSG (NGMSG_EXT4 ); -return -1 ; - } +PRINT_ERR_MSG (NGMSG_EXT4 ); +return -1 ; }/*
@@ -1865,11 +1855,9 @@ int main(int argc, char *argv[])/* fall through */ case DEVNAME :if (arg_type ==DEVNAME ) { -strncpy (lost_found_dir, dir_name, -strnlen (dir_name,PATH_MAX )); +strcpy (lost_found_dir, dir_name);strncat (lost_found_dir,"/lost+found/" , -PATH_MAX -strnlen (lost_found_dir, -PATH_MAX )); +PATH_MAX -strlen (lost_found_dir)); }nftw64 (dir_name, calc_entry_counts,FTW_OPEN_FD , flags);
Signature · 1 line
2.39.0
PATCH 30/38 misc/fuse2fs: avoid error-prone strncpy() pattern
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
'strncpy(dst, src, strlen(src))' is usually wrong, as it doesn't copy the null terminator. For this reason, it causes a -Wstringop-truncation warning with gcc 8 and later.
The code happens to be correct anyway, since the destination buffer is zero-initialized. But to avoid relying on this, let's just copy the terminating null.
--- misc/fuse2fs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
misc/fuse2fs.c +3 -2
@@ -2508,9 +2508,10 @@ static int copy_names(char *name, char *value EXT2FS_ATTR((unused)), size_t value_len EXT2FS_ATTR((unused)), void *data) {char **b = data; +size_t name_len =strlen (name); -strncpy (*b, name,strlen (name)); - *b = *b +strlen (name) +1 ; +memcpy (*b, name, name_len +1 ); + *b = *b + name_len +1 ;return 0 ; }
Signature · 1 line
2.39.0
PATCH 31/38 misc/mk_hugefiles: simplify get_partition_start()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
search_sysfs_block() is causing -Wformat-truncation warnings. These could be fixed by checking the return value of snprintf(), instead of doing buggy checks like 'strlen(p_de->d_name) > SYSFS_PATH_LEN - strlen(path) - 32', which has an integer underflow bug.
However, the only purpose of search_sysfs_block() is to find the sysfs directory for a block device by device number. That can trivially be done using /sys/dev/block/$major:$minor. So just do that instead. Also make get_partition_start() explicitly Linux-only, as it has never worked anywhere else.
--- include/mingw/sys/sysmacros.h | 8 +- misc/mk_hugefiles.c | 134 +++------------------------------- 2 files changed, 10 insertions(+), 132 deletions(-)
include/mingw/sys/sysmacros.h +1 -7
@@ -1,11 +1,5 @@ -#pragma once -/* -* Fall back to Linux's definitions of makedev and major are needed. -* The search_sysfs_block() function is highly unlikely to work on -* non-Linux systems anyway. -*/ #ifndef makedev#define makedev (maj, min) (((maj) << 8) + (min)) -#endif +#endif
misc/mk_hugefiles.c +9 -125
163 lines not on this page · raw message
Signature · 1 line
2.39.0
PATCH 32/38 misc/mke2fs: fix Windows build
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
unix_io_manager is no longer available on Windows. windows_io_manager must be used instead.
--- lib/ext2fs/ext2_io.h | 2 ++ lib/support/plausible.c | 7 +------ misc/mke2fs.c | 12 ++++++------ 3 files changed, 9 insertions(+), 12 deletions(-)
lib/ext2fs/ext2_io.h +2 -0
@@ -145,10 +145,12 @@ extern errcode_t io_channel_cache_readahead(io_channel io,#ifdef _WIN32/* windows_io.c */ extern io_manager windows_io_manager; +#define default_io_manager windows_io_manager#else /* unix_io.c */ extern io_manager unix_io_manager;extern io_manager unixfd_io_manager; +#define default_io_manager unix_io_manager#endif /* sparse_io.c */
lib/support/plausible.c +1 -6
@@ -103,12 +103,7 @@ static void print_ext2_info(const char *device)time_t tm; retval =ext2fs_open2 (device,0 ,EXT2_FLAG_64BITS ,0 ,0 , -#ifdef _WIN32 - windows_io_manager, -#else - unix_io_manager, -#endif - &fs); + default_io_manager, &fs);if (retval)return ; sb = fs->super;
misc/mke2fs.c +6 -6
@@ -1950,10 +1950,10 @@ profile_error:#ifdef CONFIG_TESTIO_DEBUG if (getenv ("TEST_IO_FLAGS" ) ||getenv ("TEST_IO_BLOCK" )) { io_ptr = test_io_manager; - test_io_backing_manager = unix_io_manager; + test_io_backing_manager = default_io_manager; } else#endif - io_ptr = unix_io_manager; + io_ptr = default_io_manager; retval =ext2fs_open (journal_device,EXT2_FLAG_JOURNAL_DEV_OK ,0 ,0 , io_ptr, &jfs);
@@ -2736,7 +2736,7 @@ static int should_do_undo(const char *name)io_channel channel;__u16 s_magic;struct ext2_super_block super; -io_manager manager = unix_io_manager; +io_manager manager = default_io_manager;int csum_flag, force_undo; csum_flag = ext2fs_has_feature_metadata_csum(&fs_param) ||
@@ -3041,10 +3041,10 @@ int main (int argc, char *argv[])#ifdef CONFIG_TESTIO_DEBUG if (getenv ("TEST_IO_FLAGS" ) ||getenv ("TEST_IO_BLOCK" )) { io_ptr = test_io_manager; - test_io_backing_manager = unix_io_manager; + test_io_backing_manager = default_io_manager; } else#endif - io_ptr = unix_io_manager; + io_ptr = default_io_manager;if (undo_file !=NULL ||should_do_undo (device_name)) { retval =mke2fs_setup_tdb (device_name, &io_ptr);
@@ -3449,7 +3449,7 @@ int main (int argc, char *argv[]) retval =ext2fs_open (journal_device,EXT2_FLAG_RW |EXT2_FLAG_JOURNAL_DEV_OK ,0 , - fs->blocksize, unix_io_manager, &jfs); + fs->blocksize, default_io_manager, &jfs);if (retval) { com_err(program_name, retval, _("while trying to open journal device %s\n"),
Signature · 1 line
2.39.0
PATCH 33/38 misc/mke2fs: fix a -Wunused-variable warning in PRS()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
This showed up when building for Windows.
--- misc/mke2fs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
misc/mke2fs.c +6 -4
@@ -1598,7 +1598,6 @@ static void PRS(int argc, char *argv[])* Finally, we complain about fs_blocks_count > 2^32 on a non-64bit fs. */ blk64_t fs_blocks_count =0 ; -long sysval;int s_opt =-1 , r_opt =-1 ;char *fs_features =0 ;int fs_features_size =0 ;
@@ -1632,9 +1631,12 @@ static void PRS(int argc, char *argv[])#define _SC_PAGESIZE _SC_PAGE_SIZE#endif #ifdef _SC_PAGESIZE - sysval =sysconf (_SC_PAGESIZE); -if (sysval >0 ) - sys_page_size = sysval; + { +long sysval =sysconf (_SC_PAGESIZE); + +if (sysval >0 ) + sys_page_size = sysval; + }#endif /* _SC_PAGESIZE */ #endif /* HAVE_SYSCONF */
Signature · 1 line
2.39.0
PATCH 34/38 misc/tune2fs: fix setting fsuuid::fsu_len
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Minus does not mean equals.
Besides fixing an obvious bug, this avoids the following compiler warning with clang -Wall:
tune2fs.c:3625:20: warning: expression result unused [-Wunused-value]
fsuuid->fsu_len - UUID_SIZE;
~~~~~~~~~~~~~~~ ^ ~~~~~~~~~--- misc/tune2fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
misc/tune2fs.c +1 -1
@@ -3622,7 +3622,7 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n" ret =-1 ;#ifdef __linux__if (fsuuid) { - fsuuid->fsu_len -UUID_SIZE ; + fsuuid->fsu_len =UUID_SIZE ; fsuuid->fsu_flags =0 ;memcpy (&fsuuid->fsu_uuid, new_uuid,UUID_SIZE ); ret =ioctl (fd,EXT4_IOC_SETFSUUID , fsuuid);
Signature · 1 line
2.39.0
PATCH 35/38 misc/tune2fs: fix -Wunused-variable warnings in handle_fslabel()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
These warnings show up in non-Linux builds. To fix them, only declare local variables when they are needed.
While we're here, also make handle_fslabel() static.
--- misc/tune2fs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
misc/tune2fs.c +3 -2
@@ -3082,14 +3082,15 @@ fs_update_journal_user(struct ext2_super_block *sb, __u8 old_uuid[UUID_SIZE])* 1 on error * -1 when the old method should be used */ -int handle_fslabel (int setlabel) { +static int handle_fslabel (int setlabel) +{ +#ifdef __linux__errcode_t ret;int mnt_flags, fd;char label[FSLABEL_MAX ];int maxlen =FSLABEL_MAX -1 ;char mntpt[PATH_MAX +1 ]; -#ifdef __linux__ ret =ext2fs_check_mount_point (device_name, &mnt_flags, mntpt,sizeof (mntpt));if (ret) {
Signature · 1 line
2.39.0
PATCH 36/38 misc/util.c: enable MinGW alarm() when building for Windows
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
To compile for Windows, this file needs MinGW's implementation of alarm(). To expose that definition, some macros must be defined before including the system headers. This was done in Android.bp, but it was not done in the autotools-based build system. Define these macros in the source file itself so that all build systems work.
--- misc/Android.bp | 2 -- misc/util.c | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-)
misc/Android.bp +0 -2
@@ -83,8 +83,6 @@ cc_binary { windows: { include_dirs: [ "external/e2fsprogs/include/mingw" ], cflags: [ - "-D_POSIX", - "-D__USE_MINGW_ALARM", // mke2fs.c has a warning from gcc which cannot be suppressed: // passing argument 3 of 'ext2fs_get_device_size' from // incompatible pointer type
misc/util.c +5 -0
@@ -16,6 +16,11 @@#define _LARGEFILE64_SOURCE#endif +#ifdef _WIN32 +#define _POSIX +#define __USE_MINGW_ALARM +#endif +#include "config.h" #include <fcntl.h> #include <setjmp.h>
Signature · 1 line
2.39.0
PATCH 37/38 resize2fs: remove unused variable from adjust_superblock()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
In adjust_superblock(), the 'group_block' variable is declared and set, but it is never actually used. Remove it.
This addresses the following compiler warning with clang -Wall:
resize2fs.c:1119:11: warning: variable 'group_block' set but not used [-Wunused-but-set-variable]
blk64_t group_block;
^--- resize/resize2fs.c | 4 ---- 1 file changed, 4 deletions(-)
resize/resize2fs.c +0 -4
@@ -1116,7 +1116,6 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk64_t new_size)ext2_filsys fs = rfs->new_fs;int adj =0 ;errcode_t retval; -blk64_t group_block;unsigned long i;unsigned long max_group;
@@ -1181,8 +1180,6 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk64_t new_size) goto errout;memset (rfs->itable_buf,0 , fs->blocksize * fs->inode_blocks_per_group); - group_block =ext2fs_group_first_block2 (fs, - rfs->old_fs->group_desc_count); adj = rfs->old_fs->group_desc_count; max_group = fs->group_desc_count - adj;if (rfs->progress) {
@@ -1209,7 +1206,6 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk64_t new_size)if (retval) goto errout; } - group_block += fs->super->s_blocks_per_group; }io_channel_flush (fs->io); retval =0 ;
Signature · 1 line
2.39.0
PATCH 38/38 Add a configuration file for GitHub Actions
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Add a workflow file for GitHub Actions, with jobs that build and test e2fsprogs on various platforms with various options.
The workflow is configured to run on pushes only, since e2fsprogs does not use GitHub pull requests.
This will work on any e2fsprogs fork on Github that has GitHub Actions enabled. For example, the results for the testing I've been doing are at https://github.com/ebiggers/e2fsprogs/actions.
--- .github/workflows/ci.yml | 116 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/ci.yml
.github/workflows/ci.yml new file +116 -0
@@ -0,0 +1,116 @@ +name: CI +on: [push] +env: + DEF_CFLAGS: -O2 -g -Wall + +jobs: + gcc-build-and-test: + name: Build and test with gcc + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: ./configure CC=gcc CFLAGS="$DEF_CFLAGS" + - run: make -j8 check V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: make -j8 install V=1 DESTDIR=$PWD/installdir + - run: make -j8 uninstall V=1 DESTDIR=$PWD/installdir + + clang-build-and-test: + name: Build and test with clang + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y clang + - run: ./configure CC=clang CFLAGS="$DEF_CFLAGS" + - run: make -j8 check V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: make -j8 install V=1 DESTDIR=$PWD/installdir + - run: make -j8 uninstall V=1 DESTDIR=$PWD/installdir + + i386-build-and-test: + name: Build and test with gcc -m32 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y gcc-multilib + - run: ./configure CC=gcc CFLAGS="$DEF_CFLAGS -m32" LDFLAGS="-m32" + - run: make -j8 check V=1 CFLAGS="$DEF_CFLAGS -m32 -Werror" + - run: make -j8 install V=1 DESTDIR=$PWD/installdir + - run: make -j8 uninstall V=1 DESTDIR=$PWD/installdir + + asan-build-and-test: + name: Build and test with ASAN enabled + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y clang + - run: echo "ASAN_CFLAGS=$DEF_CFLAGS -fsanitize=address -fno-sanitize-recover=address" >> $GITHUB_ENV + - run: ./configure CC=clang CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" + - run: make -j8 check V=1 CFLAGS="$ASAN_CFLAGS -Werror" + + ubsan-build-and-test: + name: Build and test with UBSAN enabled + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y clang + - run: echo "UBSAN_CFLAGS=$DEF_CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" >> $GITHUB_ENV + - run: ./configure CC=clang CFLAGS="$UBSAN_CFLAGS" LDFLAGS="$UBSAN_CFLAGS" + - run: make -j8 check V=1 CFLAGS="$UBSAN_CFLAGS -Werror" + + macos-build-and-test: + name: Build and test on macOS + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - run: ./configure CFLAGS="$DEF_CFLAGS" + # -Wno-error=deprecated-declarations is needed to suppress known warnings + # due to e2fsprogs' use of sbrk(0) and daemon(). + - run: make -j8 check V=1 CFLAGS="$DEF_CFLAGS -Werror -Wno-error=deprecated-declarations" + - run: make -j8 install DESTDIR=$PWD/installdir + - run: make -j8 uninstall DESTDIR=$PWD/installdir + + windows-msys2-build: + name: Build mke2fs on Windows with ${{matrix.sys}} + runs-on: windows-latest + strategy: + matrix: + include: + - { sys: mingw32, env: i686 } + - { sys: mingw64, env: x86_64 } + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v2 + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + update: true + install: > + make + mingw-w64-${{matrix.env}}-cc + # For now the only parts that actually build for Windows are mke2fs and its + # dependencies: all libraries except libss. The build system doesn't want + # to build just those parts, though, so do it one step at a time... + - run: ./configure CFLAGS="$DEF_CFLAGS" + - run: make -j8 subs V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: make -j8 -C lib/et/ all V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: make -j8 -C lib/uuid/ all V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: make -j8 -C lib/blkid/ all V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: make -j8 -C lib/ext2fs/ all V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: make -j8 -C lib/support/ all V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: make -j8 -C lib/e2p/ all V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: make -j8 -C misc/ mke2fs V=1 CFLAGS="$DEF_CFLAGS -Werror" + - run: touch image.ext4 + - run: misc/mke2fs.exe -T ext4 image.ext4 128M
Signature · 1 line
2.39.0
Quoted 14 lines · Eric Biggers
The last patch of this series adds a workflow file for GitHub Actions that builds and tests e2fsprogs on Ubuntu, macOS, and Windows. It's enforced that the build does not produce warnings with -Wall.
(For now, the Windows build is much more basic than the others; only mke2fs is built, and the unit tests are not run.)
The workflow will run on pushes to any fork of e2fsprogs that has GitHub Actions enabled. I'm hoping that Ted will enable it for the "official" fork at https://github.com/tytso/e2fsprogs, but anyone can use it in their own fork too. The results for this patch series are at
https://github.com/ebiggers/e2fsprogs/actions/runs/3976382057
Quoted 3 lines
As a prerequisite to actually getting everything to pass, patches 1-37 of this series fix a large number of miscellaneous issues, mainly pertaining to warnings with -Wall or to the Windows build.
Thanks in advance for this patch series. I have a kick at the cat for e2fsprogs build/test warnings occasionally, but getting this into a Github CI setup should keep them out of the woodwork.
I'll try to have a pass through all of the patches, but most of them seem pretty straight forward.
Cheers, Andreas
Quoted 97 lines
Some patches in this series I've already sent out individually. This series supersedes all my previous patches.
Eric Biggers (38):
configure.ac: only use Windows I/O manager on native Windows configure.ac: disable tdb by default on Windows configure.ac: automatically addinclude/mingw/headers
configure: regenerate
config/install-sh: update to latest version
lib, misc: eliminate dependency on Winsock
lib/blkid: remove 32-bit x86 byteswap assembly
lib/blkid: fix unaligned access tohfs_mdb
lib/blkid: fix -Wunused-variable warning inblkid_get_dev_size()lib/blkid: suppress -Wunused-result warning inblkid_flush_cache()lib/blkid: suppress -Wstringop-truncation warning inblkid_strndup()lib/e2p: fix a -Wunused-variable warning ingetflags()lib/{e2p,ss}: remove manual declarations of errno
lib/et: fix "unused variable" warnings when !HAVE_FCNTL lib/ext2fs: remove 32-bit x86 bitops assembly
lib/ext2fs: consistently use #ifdefs inext2fs_print_bmap_statistics()lib/ext2fs: remove unused variable inext2fs_xattrs_read_inode()lib/ext2fs: fix a printf format specifier infile_test()lib/ext2fs: fix two compiler warnings inwindows_io.clib/ext2fs: fix a -Wpointer-sign warning inext2fs_mmp_start()lib/{ext2fs,support}: fix 32-bit Windows build
lib/ss: fix 'make install' by creating man1dir
lib/support: remove unused label inget_devname()lib/support: clean up definition offlags_array
lib/uuid: remove conflicting Windows implementation ofgettimeofday()
e2fsck: use real functions for kernel slab functions misc/create_inode: fix -Wunused-variable warnings in__populate_fs()misc/create_inode: simplify logic inscandir()misc/e4defrag: fix -Wstringop-truncation warnings misc/fuse2fs: avoid error-pronestrncpy()pattern misc/mk_hugefiles: simplifyget_partition_start()misc/mke2fs: fix Windows build
misc/mke2fs: fix a -Wunused-variable warning inPRS()misc/tune2fs: fix settingfsuuid::fsu_len
misc/tune2fs: fix -Wunused-variable warnings inhandle_fslabel()misc/util.c: enable MinGWalarm()when building for Windows
resize2fs: remove unused variable fromadjust_superblock()Add a configuration file for GitHub Actions.github/workflows/ci.yml | 116 ++++++ aclocal.m4 | 180 +++++---- config/install-sh | 683 ++++++++++++++++++++++++---------- configure | 105 ++++-- configure.ac | 50 ++- e2fsck/jfs_user.h | 62 ++- include/mingw/arpa/inet.h | 5 + include/mingw/sys/sysmacros.h | 8 +- lib/blkid/Android.bp | 1 - lib/blkid/devno.c | 10 + lib/blkid/getsize.c | 2 +- lib/blkid/probe.c | 10 +- lib/blkid/probe.h | 43 --- lib/blkid/save.c | 8 + lib/config.h.in | 100 ++++- lib/e2p/Android.bp | 4 - lib/e2p/fgetversion.c | 2 - lib/e2p/fsetversion.c | 1 - lib/e2p/getflags.c | 3 +- lib/e2p/getversion.c | 1 - lib/e2p/setversion.c | 1 - lib/et/Android.bp | 3 - lib/et/error_message.c | 10 +- lib/ext2fs/Android.bp | 2 - lib/ext2fs/bitops.c | 14 +- lib/ext2fs/bitops.h | 97 ----- lib/ext2fs/ext2_io.h | 2 + lib/ext2fs/ext_attr.c | 2 - lib/ext2fs/gen_bitmap64.c | 6 +- lib/ext2fs/getsectsize.c | 12 +- lib/ext2fs/inline_data.c | 2 +- lib/ext2fs/jfs_compat.h | 4 - lib/ext2fs/mmp.c | 2 +- lib/ext2fs/windows_io.c | 12 +- lib/ss/Makefile.in | 5 +- lib/ss/execute_cmd.c | 2 - lib/ss/help.c | 2 - lib/ss/pager.c | 2 - lib/support/devname.c | 1 - lib/support/plausible.c | 7 +- lib/support/print_fs_flags.c | 60 +-- lib/uuid/gen_uuid.c | 21 -- misc/Android.bp | 3 - misc/create_inode.c | 36 +- misc/e4defrag.c | 30 +- misc/fuse2fs.c | 5 +- misc/mk_hugefiles.c | 134 +------ misc/mke2fs.c | 22 +- misc/tune2fs.c | 7 +- misc/util.c | 5 + resize/resize2fs.c | 4 - util/android_config.h | 1 - util/subst.c | 4 +- 53 files changed, 1102 insertions(+), 812 deletions(-)
Quoted 8 lines
create mode 100644
.github/workflows/ci.yml
create mode 100644include/mingw/arpa/inet.hbase-commit:
aad34909b6648579f42dade5af5b46821aa4d845--
2.39.0
Cheers, Andreas