linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain
@ 2022-04-21 22:18 Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 01/31] configure.ac: Stop using obsolete macros Bart Van Assche
                   ` (30 more replies)
  0 siblings, 31 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Hi Jaegeuk,

This patch series should make f2fs-tools easier to maintain and fixes a few
smaller bugs. Although these patches have been compile-tested only, please
consider these patches for the upstream f2fs-tools repository.

Thanks,

Bart.

Bart Van Assche (31):
  configure.ac: Stop using obsolete macros
  configure.ac: Remove two prototype tests
  configure.ac: Enable the automake -Wall option
  configure.ac: Sort header file names alphabetically
  configure.ac: Enable cross-compilation
  Switch from the u_int to the uint types
  Change the ANDROID_WINDOWS_HOST macro into _WIN32
  ci: Build f2fstools upon push and pull requests
  Change one array member into a flexible array member
  Verify structure sizes at compile time
  Suppress a compiler warning
  f2fs_fs.h: Use standard fixed width integer types
  Remove unnecessary __attribute__((packed)) annotations
  Move the be32_to_cpu() definition
  Include <stddef.h> instead of defining offsetof()
  Use %zu to format size_t
  Fix the MinGW build
  configure.ac: Detect the sparse/sparse.h header
  configure.ac: Detect selinux/android.h
  mkfs/f2fs_format.c: Suppress a compiler warning
  fsck: Remove a superfluous include directive
  tools/f2fscrypt.c: Fix build without uuid/uuid.h header file
  fsck/main.c: Suppress a compiler warning
  Change #ifdef _WIN32 checks into #ifdef HAVE_.*
  fsck/segment.c: Remove dead code
  tools/f2fs_io: Fix the type of 'ret'
  Annotate switch/case fallthrough
  Suppress a compiler warning about integer truncation
  Support cross-compiliation for PowerPC
  Fix PowerPC format string warnings
  ci: Enable -Wall, -Wextra and -Werror

 .github/workflows/ci.yml |  70 ++++++++++
 README                   |   1 -
 configure.ac             | 131 +++++++++++--------
 fsck/Makefile.am         |   2 +-
 fsck/dir.c               |   8 ++
 fsck/f2fs.h              |  14 +-
 fsck/fsck.c              |   5 +-
 fsck/main.c              |  21 ++-
 fsck/mount.c             |  54 ++++----
 fsck/quotaio.c           |   4 +-
 fsck/quotaio.h           |   3 -
 fsck/quotaio_tree.h      |   4 +-
 fsck/quotaio_v2.h        |  12 +-
 fsck/resize.c            |  28 ++--
 fsck/segment.c           |   3 +-
 fsck/sload.c             |  15 ++-
 fsck/xattr.h             |   4 +-
 include/f2fs_fs.h        | 276 +++++++++++++++++++++++----------------
 include/quota.h          |  30 +++--
 lib/libf2fs.c            |  34 ++---
 lib/libf2fs_io.c         |  24 ++--
 lib/libf2fs_zoned.c      |  18 +--
 mkfs/f2fs_format.c       |  95 ++++++++------
 mkfs/f2fs_format_main.c  |  12 +-
 mkfs/f2fs_format_utils.c |   9 +-
 mkfs/f2fs_format_utils.h |   2 +-
 tools/Makefile.am        |   5 +-
 tools/f2fs_io/f2fs_io.c  |  26 +++-
 tools/f2fs_io/f2fs_io.h  |   8 +-
 tools/f2fscrypt.c        |  19 ++-
 tools/fibmap.c           |   2 +
 31 files changed, 586 insertions(+), 353 deletions(-)
 create mode 100644 .github/workflows/ci.yml



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 01/31] configure.ac: Stop using obsolete macros
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 02/31] configure.ac: Remove two prototype tests Bart Van Assche
                   ` (29 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Run autoupdate v2.71 to fix the following autogen.sh warnings:

configure.ac:33: warning: The macro `AC_CONFIG_HEADER' is obsolete.
configure.ac:33: You should run autoupdate.
./lib/autoconf/status.m4:719: AC_CONFIG_HEADER is expanded from...
configure.ac:33: the top level
configure.ac:49: warning: The macro `AC_PROG_LIBTOOL' is obsolete.
configure.ac:49: You should run autoupdate.
m4/libtool.m4:100: AC_PROG_LIBTOOL is expanded from...
configure.ac:49: the top level

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 32e97a25053e..f906be780eb2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,7 +30,7 @@ AS_IF([test -d .git],[
 		[f2fs-tools date based on Source releases])])
 
 AC_CONFIG_SRCDIR([config.h.in])
-AC_CONFIG_HEADER([config.h])
+AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([foreign tar-pax dist-xz])
@@ -46,7 +46,7 @@ AC_ARG_WITH([blkid],
 
 # Checks for programs.
 AC_PROG_CC
-AC_PROG_LIBTOOL
+LT_INIT
 AC_PATH_PROG([LDCONFIG], [ldconfig],
        [AC_MSG_ERROR([ldconfig not found])],
        [$PATH:/sbin])


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 02/31] configure.ac: Remove two prototype tests
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 01/31] configure.ac: Stop using obsolete macros Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 03/31] configure.ac: Enable the automake -Wall option Bart Van Assche
                   ` (28 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Since no code uses the HAVE_.*_PROTOTYPE macros, remove the code that
sets these macros.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 configure.ac | 25 -------------------------
 1 file changed, 25 deletions(-)

diff --git a/configure.ac b/configure.ac
index f906be780eb2..c908c9394613 100644
--- a/configure.ac
+++ b/configure.ac
@@ -146,31 +146,6 @@ AC_CHECK_FUNCS_ONCE([
 AS_IF([test "$ac_cv_header_byteswap_h" = "yes"],
       [AC_CHECK_DECLS([bswap_64],,,[#include <byteswap.h>])])
 
-dnl
-dnl Check to see if llseek() is declared in unistd.h.  On some libc's
-dnl it is, and on others it isn't..... Thank you glibc developers....
-dnl
-AC_CHECK_DECL(llseek,[AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1,
-			[Define to 1 if llseek declared in unistd.h])],,
-			[#include <unistd.h>])
-dnl
-dnl Check to see if lseek64() is declared in unistd.h.  Glibc's header files
-dnl are so convoluted that I can't tell whether it will always be defined,
-dnl and if it isn't defined while lseek64 is defined in the library,
-dnl disaster will strike.
-dnl
-dnl Warning!  Use of --enable-gcc-wall may throw off this test.
-dnl
-dnl
-AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
-		[Define to 1 if lseek64 declared in unistd.h])],,
-		[#define _LARGEFILE_SOURCE
-		#define _LARGEFILE64_SOURCE
-		#include <unistd.h>])
-dnl
-dnl Word sizes...
-dnl
-
 # AC_CANONICAL_HOST is needed to access the 'host_os' variable
 AC_CANONICAL_HOST
 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 03/31] configure.ac: Enable the automake -Wall option
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 01/31] configure.ac: Stop using obsolete macros Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 02/31] configure.ac: Remove two prototype tests Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 04/31] configure.ac: Sort header file names alphabetically Bart Van Assche
                   ` (27 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

This patch fixes the following automake warnings:

/usr/share/automake-1.16/am/ltlibrary.am: warning: 'libf2fs.la': linking libtool libraries using a non-POSIX
/usr/share/automake-1.16/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
lib/Makefile.am:3:   while processing Libtool library 'libf2fs.la'
/usr/share/automake-1.16/am/ltlibrary.am: warning: 'libf2fs_format.la': linking libtool libraries using a non-POSIX
/usr/share/automake-1.16/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
mkfs/Makefile.am:11:   while processing Libtool library 'libf2fs_format.la'

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 configure.ac | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index c908c9394613..b40012bd8745 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,7 @@ AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([build-aux])
-AM_INIT_AUTOMAKE([foreign tar-pax dist-xz])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign tar-pax dist-xz])
 
 # Test configure options.
 AC_ARG_WITH([selinux],
@@ -46,6 +46,7 @@ AC_ARG_WITH([blkid],
 
 # Checks for programs.
 AC_PROG_CC
+AM_PROG_AR
 LT_INIT
 AC_PATH_PROG([LDCONFIG], [ldconfig],
        [AC_MSG_ERROR([ldconfig not found])],


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 04/31] configure.ac: Sort header file names alphabetically
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (2 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 03/31] configure.ac: Enable the automake -Wall option Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 05/31] configure.ac: Enable cross-compilation Bart Van Assche
                   ` (26 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index b40012bd8745..0d7872abde19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -100,13 +100,13 @@ AC_CHECK_HEADERS(m4_flatten([
 	fcntl.h
 	linux/blkzoned.h
 	linux/falloc.h
+	linux/fiemap.h
 	linux/fs.h
 	linux/hdreg.h
 	linux/limits.h
 	linux/posix_acl.h
 	linux/types.h
 	linux/xattr.h
-	linux/fiemap.h
 	mach/mach_time.h
 	mntent.h
 	scsi/sg.h
@@ -114,8 +114,8 @@ AC_CHECK_HEADERS(m4_flatten([
 	string.h
 	sys/acl.h
 	sys/ioctl.h
-	sys/syscall.h
 	sys/mount.h
+	sys/syscall.h
 	sys/sysmacros.h
 	sys/utsname.h
 	sys/xattr.h


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 05/31] configure.ac: Enable cross-compilation
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (3 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 04/31] configure.ac: Sort header file names alphabetically Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 06/31] Switch from the u_int to the uint types Bart Van Assche
                   ` (25 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Stop using PKG_CHECK_MODULES() since that macro is not compatible with
cross-compilation.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 README                  |  1 -
 configure.ac            | 47 ++++++++++++++++++-----------------------
 mkfs/f2fs_format.c      |  2 +-
 mkfs/f2fs_format_main.c |  4 ++--
 tools/f2fscrypt.c       |  2 +-
 5 files changed, 24 insertions(+), 32 deletions(-)

diff --git a/README b/README
index afe334fc6170..c9b0c1f6f721 100644
--- a/README
+++ b/README
@@ -9,7 +9,6 @@ Before compilation
 
 You should install the following packages.
  - libuuid-devel or uuid-dev
- - pkg-config
  - autoconf
  - libtool
  - libselinux1-dev
diff --git a/configure.ac b/configure.ac
index 0d7872abde19..4a3afa4853eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,6 +53,12 @@ AC_PATH_PROG([LDCONFIG], [ldconfig],
        [$PATH:/sbin])
 
 # Checks for libraries.
+AC_CHECK_LIB([blkid], [blkid_probe_all],
+	[AC_SUBST([libblkid_LIBS], ["-lblkid"])
+		AC_DEFINE([HAVE_LIBBLKID], [1],
+		[Define if you have libblkid])
+	], [], [])
+
 AC_CHECK_LIB([lzo2], [main],
 	[AC_SUBST([liblzo2_LIBS], ["-llzo2"])
 		AC_DEFINE([HAVE_LIBLZO2], [1],
@@ -65,37 +71,22 @@ AC_CHECK_LIB([lz4], [main],
 		[Define if you have liblz4])
 	], [], [])
 
-PKG_CHECK_MODULES([libuuid], [uuid])
-
-AS_IF([test "x$with_selinux" != "xno"],
-	[PKG_CHECK_MODULES([libselinux], [libselinux],
-	                   [have_selinux=yes], [have_selinux=no])],
-	[have_selinux=no]
-)
-
-AS_IF([test "x$have_selinux" = "xyes"],
-	[AC_DEFINE([HAVE_LIBSELINUX], [1], [Use libselinux])],
-	[AS_IF([test "x$with_selinux" = "xyes"],
-		[AC_MSG_ERROR([selinux support requested but libselinux not found])]
-	)]
-)
-
-AS_IF([test "x$with_blkid" != "xno"],
-	[PKG_CHECK_MODULES([libblkid], [blkid],
-	                   [have_blkid=yes], [have_blkid=no])],
-	[have_blkid=no]
-)
-
-AS_IF([test "x$have_blkid" = "xyes"],
-	[AC_DEFINE([HAVE_LIBBLKID], [1], [Use blkid])],
-	[AS_IF([test "x$with_blkid" = "xyes"],
-		[AC_MSG_ERROR([blkid support requested but libblkid not found])]
-	)]
-)
+AC_CHECK_LIB([selinux], [getcon],
+	[AC_SUBST([libselinux_LIBS], ["-lselinux"])
+		AC_DEFINE([HAVE_LIBSELINUX], [1],
+		[Define if you have libselinux])
+	], [], [])
+
+AC_CHECK_LIB([uuid], [uuid_clear],
+	[AC_SUBST([libuuid_LIBS], ["-luuid"])
+		AC_DEFINE([HAVE_LIBUUID], [1],
+		[Define if you have libuuid])
+	], [], [])
 
 # Checks for header files.
 AC_CHECK_HEADERS(m4_flatten([
 	attr/xattr.h
+	blkid/blkid.h
 	byteswap.h
 	fcntl.h
 	linux/blkzoned.h
@@ -110,6 +101,7 @@ AC_CHECK_HEADERS(m4_flatten([
 	mach/mach_time.h
 	mntent.h
 	scsi/sg.h
+	selinux/selinux.h
 	stdlib.h
 	string.h
 	sys/acl.h
@@ -120,6 +112,7 @@ AC_CHECK_HEADERS(m4_flatten([
 	sys/utsname.h
 	sys/xattr.h
 	unistd.h
+	uuid/uuid.h
 ]))
 
 # Checks for typedefs, structures, and compiler characteristics.
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index dba0cec61e60..d237d1a8c12e 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -18,7 +18,7 @@
 #include <sys/mount.h>
 #endif
 #include <time.h>
-#include <uuid.h>
+#include <uuid/uuid.h>
 
 #include "f2fs_fs.h"
 #include "quota.h"
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index bf78756ed374..797e90a948f5 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -19,13 +19,13 @@
 #include <sys/mount.h>
 #endif
 #include <time.h>
-#include <uuid.h>
+#include <uuid/uuid.h>
 #include <errno.h>
 #include <getopt.h>
 
 #include "config.h"
 #ifdef HAVE_LIBBLKID
-#include <blkid.h>
+#include <blkid/blkid.h>
 #endif
 
 #include "f2fs_fs.h"
diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c
index d5bc3c5ff50b..fe3e0ff3c1a9 100644
--- a/tools/f2fscrypt.c
+++ b/tools/f2fscrypt.c
@@ -43,7 +43,7 @@
 #ifdef __KERNEL__
 #include <linux/fs.h>
 #endif
-#include <uuid.h>
+#include <uuid/uuid.h>
 
 #if !defined(HAVE_ADD_KEY) || !defined(HAVE_KEYCTL)
 #include <sys/syscall.h>


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 06/31] Switch from the u_int to the uint types
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (4 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 05/31] configure.ac: Enable cross-compilation Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 07/31] Change the ANDROID_WINDOWS_HOST macro into _WIN32 Bart Van Assche
                   ` (24 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Many format strings use one of the PRI* macros. These macros are compatible
with the uint types but not with the u_int types. Hence this patch
that switches from the u_int to the uint types.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/fsck.c              |   4 +-
 fsck/mount.c             |  44 ++++++++--------
 fsck/resize.c            |  28 +++++-----
 include/f2fs_fs.h        | 110 +++++++++++++++++++--------------------
 include/quota.h          |  16 +++---
 lib/libf2fs.c            |  22 ++++----
 lib/libf2fs_io.c         |   4 +-
 lib/libf2fs_zoned.c      |  16 +++---
 mkfs/f2fs_format.c       |  80 ++++++++++++++--------------
 mkfs/f2fs_format_main.c  |   2 +-
 mkfs/f2fs_format_utils.c |   2 +-
 mkfs/f2fs_format_utils.h |   2 +-
 tools/f2fs_io/f2fs_io.h  |   8 +--
 13 files changed, 167 insertions(+), 171 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index ddcede32b4cb..798779cfaf8a 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -2312,7 +2312,7 @@ static void fix_checkpoint(struct f2fs_sb_info *sbi)
 	block_t cp_blocks;
 	u32 i;
 	int ret;
-	u_int32_t crc = 0;
+	uint32_t crc = 0;
 
 	/* should call from fsck */
 	ASSERT(c.func == FSCK);
@@ -2438,7 +2438,7 @@ static int check_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
 	struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
 	struct blk_zone blkz;
 	block_t cs_block, wp_block, zone_last_vblock;
-	u_int64_t cs_sector, wp_sector;
+	uint64_t cs_sector, wp_sector;
 	int i, ret;
 	unsigned int zone_segno;
 	int log_sectors_per_block = sbi->log_blocksize - SECTOR_SHIFT;
diff --git a/fsck/mount.c b/fsck/mount.c
index c928a1516597..f15260e02cab 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -31,7 +31,7 @@
 #define ACL_OTHER		(0x20)
 #endif
 
-static int get_device_idx(struct f2fs_sb_info *sbi, u_int32_t segno)
+static int get_device_idx(struct f2fs_sb_info *sbi, uint32_t segno)
 {
 	block_t seg_start_blkaddr;
 	int i;
@@ -48,7 +48,7 @@ static int get_device_idx(struct f2fs_sb_info *sbi, u_int32_t segno)
 #ifdef HAVE_LINUX_BLKZONED_H
 
 static int get_zone_idx_from_dev(struct f2fs_sb_info *sbi,
-					u_int32_t segno, u_int32_t dev_idx)
+					uint32_t segno, uint32_t dev_idx)
 {
 	block_t seg_start_blkaddr = START_BLOCK(sbi, segno);
 
@@ -365,7 +365,7 @@ void print_node_info(struct f2fs_sb_info *sbi,
 	}
 }
 
-static void DISP_label(u_int16_t *name)
+static void DISP_label(uint16_t *name)
 {
 	char buffer[MAX_VOLUME_NAME];
 
@@ -674,7 +674,7 @@ out:
 void update_superblock(struct f2fs_super_block *sb, int sb_mask)
 {
 	int addr, ret;
-	u_int8_t *buf;
+	uint8_t *buf;
 	u32 old_crc, new_crc;
 
 	buf = calloc(BLOCK_SZ, 1);
@@ -1498,7 +1498,7 @@ static int f2fs_late_init_nid_bitmap(struct f2fs_sb_info *sbi)
 u32 update_nat_bits_flags(struct f2fs_super_block *sb,
 				struct f2fs_checkpoint *cp, u32 flags)
 {
-	u_int32_t nat_bits_bytes, nat_bits_blocks;
+	uint32_t nat_bits_bytes, nat_bits_blocks;
 
 	nat_bits_bytes = get_sb(segment_count_nat) << 5;
 	nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) + 8 +
@@ -1517,14 +1517,14 @@ void write_nat_bits(struct f2fs_sb_info *sbi,
 	struct f2fs_super_block *sb, struct f2fs_checkpoint *cp, int set)
 {
 	struct f2fs_nm_info *nm_i = NM_I(sbi);
-	u_int32_t nat_blocks = get_sb(segment_count_nat) <<
+	uint32_t nat_blocks = get_sb(segment_count_nat) <<
 				(get_sb(log_blocks_per_seg) - 1);
-	u_int32_t nat_bits_bytes = nat_blocks >> 3;
-	u_int32_t nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) +
+	uint32_t nat_bits_bytes = nat_blocks >> 3;
+	uint32_t nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) +
 					8 + F2FS_BLKSIZE - 1);
 	unsigned char *nat_bits, *full_nat_bits, *empty_nat_bits;
 	struct f2fs_nat_block *nat_block;
-	u_int32_t i, j;
+	uint32_t i, j;
 	block_t blkaddr;
 	int ret;
 
@@ -1590,15 +1590,15 @@ static int check_nat_bits(struct f2fs_sb_info *sbi,
 	struct f2fs_super_block *sb, struct f2fs_checkpoint *cp)
 {
 	struct f2fs_nm_info *nm_i = NM_I(sbi);
-	u_int32_t nat_blocks = get_sb(segment_count_nat) <<
+	uint32_t nat_blocks = get_sb(segment_count_nat) <<
 				(get_sb(log_blocks_per_seg) - 1);
-	u_int32_t nat_bits_bytes = nat_blocks >> 3;
-	u_int32_t nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) +
+	uint32_t nat_bits_bytes = nat_blocks >> 3;
+	uint32_t nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) +
 					8 + F2FS_BLKSIZE - 1);
 	unsigned char *nat_bits, *full_nat_bits, *empty_nat_bits;
 	struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
 	struct f2fs_journal *journal = &curseg->sum_blk->journal;
-	u_int32_t i, j;
+	uint32_t i, j;
 	block_t blkaddr;
 	int err = 0;
 
@@ -1628,8 +1628,8 @@ static int check_nat_bits(struct f2fs_sb_info *sbi,
 	}
 
 	for (i = 0; i < nat_blocks; i++) {
-		u_int32_t start_nid = i * NAT_ENTRY_PER_BLOCK;
-		u_int32_t valid = 0;
+		uint32_t start_nid = i * NAT_ENTRY_PER_BLOCK;
+		uint32_t valid = 0;
 		int empty = test_bit_le(i, empty_nat_bits);
 		int full = test_bit_le(i, full_nat_bits);
 
@@ -2702,7 +2702,7 @@ void set_section_type(struct f2fs_sb_info *sbi, unsigned int segno, int type)
 static bool write_pointer_at_zone_start(struct f2fs_sb_info *sbi,
 					unsigned int zone_segno)
 {
-	u_int64_t sector;
+	uint64_t sector;
 	struct blk_zone blkz;
 	block_t block = START_BLOCK(sbi, zone_segno);
 	int log_sectors_per_block = sbi->log_blocksize - SECTOR_SHIFT;
@@ -3011,7 +3011,7 @@ void write_checkpoint(struct f2fs_sb_info *sbi)
 	unsigned long long cp_blk_no;
 	u32 flags = CP_UMOUNT_FLAG;
 	int i, ret;
-	u_int32_t crc = 0;
+	uint32_t crc = 0;
 
 	if (is_set_ckpt_flags(cp, CP_ORPHAN_PRESENT_FLAG)) {
 		orphan_blks = __start_sum_addr(sbi) - 1;
@@ -3242,7 +3242,7 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi)
 
 static int check_sector_size(struct f2fs_super_block *sb)
 {
-	u_int32_t log_sectorsize, log_sectors_per_block;
+	uint32_t log_sectorsize, log_sectors_per_block;
 
 	log_sectorsize = log_base_2(c.sector_size);
 	log_sectors_per_block = log_base_2(c.sectors_per_blk);
@@ -3679,10 +3679,10 @@ void f2fs_do_umount(struct f2fs_sb_info *sbi)
 int f2fs_sparse_initialize_meta(struct f2fs_sb_info *sbi)
 {
 	struct f2fs_super_block *sb = sbi->raw_super;
-	u_int32_t sit_seg_count, sit_size;
-	u_int32_t nat_seg_count, nat_size;
-	u_int64_t sit_seg_addr, nat_seg_addr, payload_addr;
-	u_int32_t seg_size = 1 << get_sb(log_blocks_per_seg);
+	uint32_t sit_seg_count, sit_size;
+	uint32_t nat_seg_count, nat_size;
+	uint64_t sit_seg_addr, nat_seg_addr, payload_addr;
+	uint32_t seg_size = 1 << get_sb(log_blocks_per_seg);
 	int ret;
 
 	if (!c.sparse_mode)
diff --git a/fsck/resize.c b/fsck/resize.c
index 78d578ec2cc1..f1b770123428 100644
--- a/fsck/resize.c
+++ b/fsck/resize.c
@@ -11,27 +11,27 @@
 
 static int get_new_sb(struct f2fs_super_block *sb)
 {
-	u_int32_t zone_size_bytes;
-	u_int64_t zone_align_start_offset;
-	u_int32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa;
-	u_int32_t sit_segments, nat_segments, diff, total_meta_segments;
-	u_int32_t total_valid_blks_available;
-	u_int32_t sit_bitmap_size, max_sit_bitmap_size;
-	u_int32_t max_nat_bitmap_size, max_nat_segments;
-	u_int32_t segment_size_bytes = 1 << (get_sb(log_blocksize) +
+	uint32_t zone_size_bytes;
+	uint64_t zone_align_start_offset;
+	uint32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa;
+	uint32_t sit_segments, nat_segments, diff, total_meta_segments;
+	uint32_t total_valid_blks_available;
+	uint32_t sit_bitmap_size, max_sit_bitmap_size;
+	uint32_t max_nat_bitmap_size, max_nat_segments;
+	uint32_t segment_size_bytes = 1 << (get_sb(log_blocksize) +
 					get_sb(log_blocks_per_seg));
-	u_int32_t blks_per_seg = 1 << get_sb(log_blocks_per_seg);
-	u_int32_t segs_per_zone = get_sb(segs_per_sec) * get_sb(secs_per_zone);
+	uint32_t blks_per_seg = 1 << get_sb(log_blocks_per_seg);
+	uint32_t segs_per_zone = get_sb(segs_per_sec) * get_sb(secs_per_zone);
 
 	set_sb(block_count, c.target_sectors >>
 				get_sb(log_sectors_per_block));
 
 	zone_size_bytes = segment_size_bytes * segs_per_zone;
 	zone_align_start_offset =
-		((u_int64_t) c.start_sector * DEFAULT_SECTOR_SIZE +
+		((uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE +
 		2 * F2FS_BLKSIZE + zone_size_bytes - 1) /
 		zone_size_bytes * zone_size_bytes -
-		(u_int64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
+		(uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
 
 	set_sb(segment_count, (c.target_sectors * c.sector_size -
 				zone_align_start_offset) / segment_size_bytes /
@@ -76,7 +76,7 @@ static int get_new_sb(struct f2fs_super_block *sb)
 		/* use cp_payload if free space of f2fs_checkpoint is not enough */
 		if (max_sit_bitmap_size + max_nat_bitmap_size >
 						MAX_BITMAP_SIZE_IN_CKPT) {
-			u_int32_t diff =  max_sit_bitmap_size +
+			uint32_t diff =  max_sit_bitmap_size +
 						max_nat_bitmap_size -
 						MAX_BITMAP_SIZE_IN_CKPT;
 			set_sb(cp_payload, F2FS_BLK_ALIGN(diff));
@@ -457,7 +457,7 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,
 	block_t new_cp_blks = 1 + get_newsb(cp_payload);
 	block_t orphan_blks = 0;
 	block_t new_cp_blk_no, old_cp_blk_no;
-	u_int32_t crc = 0;
+	uint32_t crc = 0;
 	u32 flags;
 	void *buf;
 	int i, ret;
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 412130f5b5ab..1e38d93ff40d 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -70,20 +70,16 @@
 
 #ifdef ANDROID_WINDOWS_HOST
 #undef HAVE_LINUX_TYPES_H
-typedef uint64_t u_int64_t;
-typedef uint32_t u_int32_t;
-typedef uint16_t u_int16_t;
-typedef uint8_t u_int8_t;
 #endif
 
 /* codes from kernel's f2fs.h, GPL-v2.0 */
 #define MIN_COMPRESS_LOG_SIZE	2
 #define MAX_COMPRESS_LOG_SIZE	8
 
-typedef u_int64_t	u64;
-typedef u_int32_t	u32;
-typedef u_int16_t	u16;
-typedef u_int8_t	u8;
+typedef uint64_t	u64;
+typedef uint32_t	u32;
+typedef uint16_t	u16;
+typedef uint8_t		u8;
 typedef u32		block_t;
 typedef u32		nid_t;
 #ifndef bool
@@ -378,16 +374,16 @@ enum default_set {
 struct device_info {
 	char *path;
 	int32_t fd;
-	u_int32_t sector_size;
-	u_int64_t total_sectors;	/* got by get_device_info */
-	u_int64_t start_blkaddr;
-	u_int64_t end_blkaddr;
-	u_int32_t total_segments;
+	uint32_t sector_size;
+	uint64_t total_sectors;	/* got by get_device_info */
+	uint64_t start_blkaddr;
+	uint64_t end_blkaddr;
+	uint32_t total_segments;
 
 	/* to handle zone block devices */
 	int zoned_model;
-	u_int32_t nr_zones;
-	u_int32_t nr_rnd_zones;
+	uint32_t nr_zones;
+	uint32_t nr_rnd_zones;
 	size_t zone_blocks;
 	size_t *zone_cap_blocks;
 };
@@ -444,36 +440,36 @@ typedef struct {
 #define ALIGN_UP(addrs, size)	ALIGN_DOWN(((addrs) + (size) - 1), (size))
 
 struct f2fs_configuration {
-	u_int32_t reserved_segments;
-	u_int32_t new_reserved_segments;
+	uint32_t reserved_segments;
+	uint32_t new_reserved_segments;
 	int sparse_mode;
 	int zoned_mode;
 	int zoned_model;
 	size_t zone_blocks;
 	double overprovision;
 	double new_overprovision;
-	u_int32_t cur_seg[6];
-	u_int32_t segs_per_sec;
-	u_int32_t secs_per_zone;
-	u_int32_t segs_per_zone;
-	u_int32_t start_sector;
-	u_int32_t total_segments;
-	u_int32_t sector_size;
-	u_int64_t device_size;
-	u_int64_t total_sectors;
-	u_int64_t wanted_total_sectors;
-	u_int64_t wanted_sector_size;
-	u_int64_t target_sectors;
-	u_int64_t max_size;
-	u_int32_t sectors_per_blk;
-	u_int32_t blks_per_seg;
+	uint32_t cur_seg[6];
+	uint32_t segs_per_sec;
+	uint32_t secs_per_zone;
+	uint32_t segs_per_zone;
+	uint32_t start_sector;
+	uint32_t total_segments;
+	uint32_t sector_size;
+	uint64_t device_size;
+	uint64_t total_sectors;
+	uint64_t wanted_total_sectors;
+	uint64_t wanted_sector_size;
+	uint64_t target_sectors;
+	uint64_t max_size;
+	uint32_t sectors_per_blk;
+	uint32_t blks_per_seg;
 	__u8 init_version[VERSION_LEN + 1];
 	__u8 sb_version[VERSION_LEN + 1];
 	__u8 version[VERSION_LEN + 1];
 	char *vol_label;
 	char *vol_uuid;
-	u_int16_t s_encoding;
-	u_int16_t s_encoding_flags;
+	uint16_t s_encoding;
+	uint16_t s_encoding_flags;
 	int heap;
 	int32_t kd;
 	int32_t dump_fd;
@@ -512,20 +508,20 @@ struct f2fs_configuration {
 
 	/* mkfs parameters */
 	int fake_seed;
-	u_int32_t next_free_nid;
-	u_int32_t quota_inum;
-	u_int32_t quota_dnum;
-	u_int32_t lpf_inum;
-	u_int32_t lpf_dnum;
-	u_int32_t lpf_ino;
-	u_int32_t root_uid;
-	u_int32_t root_gid;
+	uint32_t next_free_nid;
+	uint32_t quota_inum;
+	uint32_t quota_dnum;
+	uint32_t lpf_inum;
+	uint32_t lpf_dnum;
+	uint32_t lpf_ino;
+	uint32_t root_uid;
+	uint32_t root_gid;
 
 	/* defragmentation parameters */
 	int defrag_shrink;
-	u_int64_t defrag_start;
-	u_int64_t defrag_len;
-	u_int64_t defrag_target;
+	uint64_t defrag_start;
+	uint64_t defrag_len;
+	uint64_t defrag_target;
 
 	/* sload parameters */
 	char *from_dir;
@@ -542,7 +538,7 @@ struct f2fs_configuration {
 	int safe_resize;
 
 	/* precomputed fs UUID checksum for seeding other checksums */
-	u_int32_t chksum_seed;
+	uint32_t chksum_seed;
 
 	/* cache parameters */
 	dev_cache_config_t cache_config;
@@ -1318,9 +1314,9 @@ enum {
 	SSR
 };
 
-extern int utf8_to_utf16(u_int16_t *, const char *, size_t, size_t);
-extern int utf16_to_utf8(char *, const u_int16_t *, size_t, size_t);
-extern int log_base_2(u_int32_t);
+extern int utf8_to_utf16(uint16_t *, const char *, size_t, size_t);
+extern int utf16_to_utf8(char *, const uint16_t *, size_t, size_t);
+extern int log_base_2(uint32_t);
 extern unsigned int addrs_per_inode(struct f2fs_inode *);
 extern unsigned int addrs_per_block(struct f2fs_inode *);
 extern unsigned int f2fs_max_file_offset(struct f2fs_inode *);
@@ -1338,8 +1334,8 @@ extern int f2fs_clear_bit(unsigned int, char *);
 extern u64 find_next_bit_le(const u8 *, u64, u64);
 extern u64 find_next_zero_bit_le(const u8 *, u64, u64);
 
-extern u_int32_t f2fs_cal_crc32(u_int32_t, void *, int);
-extern int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len);
+extern uint32_t f2fs_cal_crc32(uint32_t, void *, int);
+extern int f2fs_crc_valid(uint32_t blk_crc, void *buf, int len);
 
 extern void f2fs_init_configuration(void);
 extern int f2fs_devs_are_umounted(void);
@@ -1496,7 +1492,7 @@ blk_zone_cond_str(struct blk_zone *blkz)
 
 extern int f2fs_get_zoned_model(int);
 extern int f2fs_get_zone_blocks(int);
-extern int f2fs_report_zone(int, u_int64_t, void *);
+extern int f2fs_report_zone(int, uint64_t, void *);
 typedef int (report_zones_cb_t)(int i, void *, void *);
 extern int f2fs_report_zones(int, report_zones_cb_t *, void *);
 extern int f2fs_check_zones(int);
@@ -1513,7 +1509,7 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb)
 {
 	double reserved, ovp, candidate, end, diff, space;
 	double max_ovp = 0, max_space = 0;
-	u_int32_t usable_main_segs = f2fs_get_usable_segments(sb);
+	uint32_t usable_main_segs = f2fs_get_usable_segments(sb);
 
 	if (get_sb(segment_count_main) < 256) {
 		candidate = 10;
@@ -1540,12 +1536,12 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb)
 
 static inline __le64 get_cp_crc(struct f2fs_checkpoint *cp)
 {
-	u_int64_t cp_ver = get_cp(checkpoint_ver);
+	uint64_t cp_ver = get_cp(checkpoint_ver);
 	size_t crc_offset = get_cp(checksum_offset);
-	u_int32_t crc = le32_to_cpu(*(__le32 *)((unsigned char *)cp +
+	uint32_t crc = le32_to_cpu(*(__le32 *)((unsigned char *)cp +
 							crc_offset));
 
-	cp_ver |= ((u_int64_t)crc << 32);
+	cp_ver |= ((uint64_t)crc << 32);
 	return cpu_to_le64(cp_ver);
 }
 
@@ -1692,7 +1688,7 @@ static inline int parse_feature(struct feature *table, const char *features)
 }
 
 static inline int parse_root_owner(char *ids,
-			u_int32_t *root_uid, u_int32_t *root_gid)
+			uint32_t *root_uid, uint32_t *root_gid)
 {
 	char *uid = ids;
 	char *gid = NULL;
diff --git a/include/quota.h b/include/quota.h
index f578621fa2b4..627a86f6421f 100644
--- a/include/quota.h
+++ b/include/quota.h
@@ -46,18 +46,18 @@ enum quota_type {
 
 #pragma pack(push, 1)
 struct v2_disk_dqheader {
-	u_int32_t dqh_magic;	/* Magic number identifying file */
-	u_int32_t dqh_version;	/* File version */
+	uint32_t dqh_magic;	/* Magic number identifying file */
+	uint32_t dqh_version;	/* File version */
 } __attribute__ ((packed));
 
 /* Header with type and version specific information */
 struct v2_disk_dqinfo {
-	u_int32_t dqi_bgrace;	/* Time before block soft limit becomes hard limit */
-	u_int32_t dqi_igrace;	/* Time before inode soft limit becomes hard limit */
-	u_int32_t dqi_flags;	/* Flags for quotafile (DQF_*) */
-	u_int32_t dqi_blocks;	/* Number of blocks in file */
-	u_int32_t dqi_free_blk;	/* Number of first free block in the list */
-	u_int32_t dqi_free_entry;	/* Number of block with at least one free entry */
+	uint32_t dqi_bgrace;	/* Time before block soft limit becomes hard limit */
+	uint32_t dqi_igrace;	/* Time before inode soft limit becomes hard limit */
+	uint32_t dqi_flags;	/* Flags for quotafile (DQF_*) */
+	uint32_t dqi_blocks;	/* Number of blocks in file */
+	uint32_t dqi_free_blk;	/* Number of first free block in the list */
+	uint32_t dqi_free_entry;	/* Number of block with at least one free entry */
 } __attribute__ ((packed));
 
 struct v2r1_disk_dqblk {
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 94fb91d46d28..b0a892772de1 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -104,7 +104,7 @@ static const char *utf8_to_wchar(const char *input, wchar_t *wc,
 	return NULL;
 }
 
-static u_int16_t *wchar_to_utf16(u_int16_t *output, wchar_t wc, size_t outsize)
+static uint16_t *wchar_to_utf16(uint16_t *output, wchar_t wc, size_t outsize)
 {
 	if (wc <= 0xffff) {
 		if (outsize == 0)
@@ -120,11 +120,11 @@ static u_int16_t *wchar_to_utf16(u_int16_t *output, wchar_t wc, size_t outsize)
 	return output + 2;
 }
 
-int utf8_to_utf16(u_int16_t *output, const char *input, size_t outsize,
+int utf8_to_utf16(uint16_t *output, const char *input, size_t outsize,
 		size_t insize)
 {
 	const char *inp = input;
-	u_int16_t *outp = output;
+	uint16_t *outp = output;
 	wchar_t wc;
 
 	while ((size_t)(inp - input) < insize && *inp) {
@@ -143,7 +143,7 @@ int utf8_to_utf16(u_int16_t *output, const char *input, size_t outsize,
 	return 0;
 }
 
-static const u_int16_t *utf16_to_wchar(const u_int16_t *input, wchar_t *wc,
+static const uint16_t *utf16_to_wchar(const uint16_t *input, wchar_t *wc,
 		size_t insize)
 {
 	if ((le16_to_cpu(input[0]) & 0xfc00) == 0xd800) {
@@ -206,10 +206,10 @@ static char *wchar_to_utf8(char *output, wchar_t wc, size_t outsize)
 	return output;
 }
 
-int utf16_to_utf8(char *output, const u_int16_t *input, size_t outsize,
+int utf16_to_utf8(char *output, const uint16_t *input, size_t outsize,
 		size_t insize)
 {
-	const u_int16_t *inp = input;
+	const uint16_t *inp = input;
 	char *outp = output;
 	wchar_t wc;
 
@@ -229,7 +229,7 @@ int utf16_to_utf8(char *output, const u_int16_t *input, size_t outsize,
 	return 0;
 }
 
-int log_base_2(u_int32_t num)
+int log_base_2(uint32_t num)
 {
 	int ret = 0;
 	if (num <= 0 || (num & (num - 1)) != 0)
@@ -530,7 +530,7 @@ unsigned int f2fs_max_file_offset(struct f2fs_inode *i)
  */
 #define CRCPOLY_LE 0xedb88320
 
-u_int32_t f2fs_cal_crc32(u_int32_t crc, void *buf, int len)
+uint32_t f2fs_cal_crc32(uint32_t crc, void *buf, int len)
 {
 	int i;
 	unsigned char *p = (unsigned char *)buf;
@@ -542,9 +542,9 @@ u_int32_t f2fs_cal_crc32(u_int32_t crc, void *buf, int len)
 	return crc;
 }
 
-int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len)
+int f2fs_crc_valid(uint32_t blk_crc, void *buf, int len)
 {
-	u_int32_t cal_crc = 0;
+	uint32_t cal_crc = 0;
 
 	cal_crc = f2fs_cal_crc32(F2FS_SUPER_MAGIC, buf, len);
 
@@ -1197,7 +1197,7 @@ int f2fs_get_f2fs_info(void)
 		c.devices[0].total_sectors = c.total_sectors;
 	}
 	if (c.total_sectors * c.sector_size >
-		(u_int64_t)F2FS_MAX_SEGMENT * 2 * 1024 * 1024) {
+		(uint64_t)F2FS_MAX_SEGMENT * 2 * 1024 * 1024) {
 		MSG(0, "\tError: F2FS can support 16TB at most!!!\n");
 		return -1;
 	}
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index 320ee6c431f0..b985e6f37a0a 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -43,7 +43,7 @@ struct f2fs_configuration c;
 #include <sparse/sparse.h>
 struct sparse_file *f2fs_sparse_file;
 static char **blocks;
-u_int64_t blocks_count;
+uint64_t blocks_count;
 static char *zeroed_block;
 #endif
 
@@ -661,7 +661,7 @@ int f2fs_init_sparse_file(void)
 			return -1;
 
 		c.device_size = sparse_file_len(f2fs_sparse_file, 0, 0);
-		c.device_size &= (~((u_int64_t)(F2FS_BLKSIZE - 1)));
+		c.device_size &= (~((uint64_t)(F2FS_BLKSIZE - 1)));
 	}
 
 	if (sparse_file_block_size(f2fs_sparse_file) != F2FS_BLKSIZE) {
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index ce73b9af66ec..c408a4991fa1 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -192,7 +192,7 @@ int f2fs_get_zone_blocks(int i)
 	return 0;
 }
 
-int f2fs_report_zone(int i, u_int64_t sector, void *blkzone)
+int f2fs_report_zone(int i, uint64_t sector, void *blkzone)
 {
 	struct blk_zone *blkz = (struct blk_zone *)blkzone;
 	struct blk_zone_report *rep;
@@ -227,9 +227,9 @@ int f2fs_report_zones(int j, report_zones_cb_t *report_zones_cb, void *opaque)
 	struct blk_zone_report *rep;
 	struct blk_zone *blkz;
 	unsigned int i, n = 0;
-	u_int64_t total_sectors = (dev->total_sectors * c.sector_size)
+	uint64_t total_sectors = (dev->total_sectors * c.sector_size)
 		>> SECTOR_SHIFT;
-	u_int64_t sector = 0;
+	uint64_t sector = 0;
 	int ret = -1;
 
 	rep = malloc(F2FS_REPORT_ZONES_BUFSZ);
@@ -280,8 +280,8 @@ int f2fs_check_zones(int j)
 	struct blk_zone_report *rep;
 	struct blk_zone *blkz;
 	unsigned int i, n = 0;
-	u_int64_t total_sectors;
-	u_int64_t sector;
+	uint64_t total_sectors;
+	uint64_t sector;
 	int last_is_conv = 1;
 	int ret = -1;
 
@@ -433,8 +433,8 @@ int f2fs_reset_zones(int j)
 	struct blk_zone_report *rep;
 	struct blk_zone *blkz;
 	struct blk_zone_range range;
-	u_int64_t total_sectors;
-	u_int64_t sector;
+	uint64_t total_sectors;
+	uint64_t sector;
 	unsigned int i;
 	int ret = -1;
 
@@ -522,7 +522,7 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
 
 #else
 
-int f2fs_report_zone(int i, u_int64_t UNUSED(sector), void *UNUSED(blkzone))
+int f2fs_report_zone(int i, uint64_t UNUSED(sector), void *UNUSED(blkzone))
 {
 	ERR_MSG("%d: Unsupported zoned block device\n", i);
 	return -1;
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index d237d1a8c12e..8bd33ac003c5 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -199,18 +199,18 @@ static void verify_cur_segs(void)
 
 static int f2fs_prepare_super_block(void)
 {
-	u_int32_t blk_size_bytes;
-	u_int32_t log_sectorsize, log_sectors_per_block;
-	u_int32_t log_blocksize, log_blks_per_seg;
-	u_int32_t segment_size_bytes, zone_size_bytes;
-	u_int32_t sit_segments, nat_segments;
-	u_int32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa;
-	u_int32_t total_valid_blks_available;
-	u_int64_t zone_align_start_offset, diff;
-	u_int64_t total_meta_zones, total_meta_segments;
-	u_int32_t sit_bitmap_size, max_sit_bitmap_size;
-	u_int32_t max_nat_bitmap_size, max_nat_segments;
-	u_int32_t total_zones, avail_zones;
+	uint32_t blk_size_bytes;
+	uint32_t log_sectorsize, log_sectors_per_block;
+	uint32_t log_blocksize, log_blks_per_seg;
+	uint32_t segment_size_bytes, zone_size_bytes;
+	uint32_t sit_segments, nat_segments;
+	uint32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa;
+	uint32_t total_valid_blks_available;
+	uint64_t zone_align_start_offset, diff;
+	uint64_t total_meta_zones, total_meta_segments;
+	uint32_t sit_bitmap_size, max_sit_bitmap_size;
+	uint32_t max_nat_bitmap_size, max_nat_segments;
+	uint32_t total_zones, avail_zones;
 	enum quota_type qtype;
 	int i;
 
@@ -243,10 +243,10 @@ static int f2fs_prepare_super_block(void)
 	set_sb(block_count, c.total_sectors >> log_sectors_per_block);
 
 	zone_align_start_offset =
-		((u_int64_t) c.start_sector * DEFAULT_SECTOR_SIZE +
+		((uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE +
 		2 * F2FS_BLKSIZE + zone_size_bytes - 1) /
 		zone_size_bytes * zone_size_bytes -
-		(u_int64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
+		(uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO))
 		zone_align_start_offset = 8192;
@@ -363,7 +363,7 @@ static int f2fs_prepare_super_block(void)
 		/* use cp_payload if free space of f2fs_checkpoint is not enough */
 		if (max_sit_bitmap_size + max_nat_bitmap_size >
 						MAX_BITMAP_SIZE_IN_CKPT) {
-			u_int32_t diff =  max_sit_bitmap_size +
+			uint32_t diff =  max_sit_bitmap_size +
 						max_nat_bitmap_size -
 						MAX_BITMAP_SIZE_IN_CKPT;
 			set_sb(cp_payload, F2FS_BLK_ALIGN(diff));
@@ -606,15 +606,15 @@ static int f2fs_prepare_super_block(void)
 
 static int f2fs_init_sit_area(void)
 {
-	u_int32_t blk_size, seg_size;
-	u_int32_t index = 0;
-	u_int64_t sit_seg_addr = 0;
-	u_int8_t *zero_buf = NULL;
+	uint32_t blk_size, seg_size;
+	uint32_t index = 0;
+	uint64_t sit_seg_addr = 0;
+	uint8_t *zero_buf = NULL;
 
 	blk_size = 1 << get_sb(log_blocksize);
 	seg_size = (1 << get_sb(log_blocks_per_seg)) * blk_size;
 
-	zero_buf = calloc(sizeof(u_int8_t), seg_size);
+	zero_buf = calloc(sizeof(uint8_t), seg_size);
 	if(zero_buf == NULL) {
 		MSG(1, "\tError: Calloc Failed for sit_zero_buf!!!\n");
 		return -1;
@@ -640,15 +640,15 @@ static int f2fs_init_sit_area(void)
 
 static int f2fs_init_nat_area(void)
 {
-	u_int32_t blk_size, seg_size;
-	u_int32_t index = 0;
-	u_int64_t nat_seg_addr = 0;
-	u_int8_t *nat_buf = NULL;
+	uint32_t blk_size, seg_size;
+	uint32_t index = 0;
+	uint64_t nat_seg_addr = 0;
+	uint8_t *nat_buf = NULL;
 
 	blk_size = 1 << get_sb(log_blocksize);
 	seg_size = (1 << get_sb(log_blocks_per_seg)) * blk_size;
 
-	nat_buf = calloc(sizeof(u_int8_t), seg_size);
+	nat_buf = calloc(sizeof(uint8_t), seg_size);
 	if (nat_buf == NULL) {
 		MSG(1, "\tError: Calloc Failed for nat_zero_blk!!!\n");
 		return -1;
@@ -676,11 +676,11 @@ static int f2fs_write_check_point_pack(void)
 {
 	struct f2fs_summary_block *sum = NULL;
 	struct f2fs_journal *journal;
-	u_int32_t blk_size_bytes;
-	u_int32_t nat_bits_bytes, nat_bits_blocks;
+	uint32_t blk_size_bytes;
+	uint32_t nat_bits_bytes, nat_bits_blocks;
 	unsigned char *nat_bits = NULL, *empty_nat_bits;
-	u_int64_t cp_seg_blk = 0;
-	u_int32_t crc = 0, flags;
+	uint64_t cp_seg_blk = 0;
+	uint32_t crc = 0, flags;
 	unsigned int i;
 	char *cp_payload = NULL;
 	char *sum_compact, *sum_compact_p;
@@ -1114,7 +1114,7 @@ free_cp:
 static int f2fs_write_super_block(void)
 {
 	int index;
-	u_int8_t *zero_buff;
+	uint8_t *zero_buff;
 
 	zero_buff = calloc(F2FS_BLKSIZE, 1);
 	if (zero_buff == NULL) {
@@ -1141,11 +1141,11 @@ static int f2fs_write_super_block(void)
 static int f2fs_discard_obsolete_dnode(void)
 {
 	struct f2fs_node *raw_node;
-	u_int64_t next_blkaddr = 0, offset;
+	uint64_t next_blkaddr = 0, offset;
 	u64 end_blkaddr = (get_sb(segment_count_main) <<
 			get_sb(log_blocks_per_seg)) + get_sb(main_blkaddr);
-	u_int64_t start_inode_pos = get_sb(main_blkaddr);
-	u_int64_t last_inode_pos;
+	uint64_t start_inode_pos = get_sb(main_blkaddr);
+	uint64_t last_inode_pos;
 
 	if (c.zoned_mode || c.feature & cpu_to_le32(F2FS_FEATURE_RO))
 		return 0;
@@ -1196,8 +1196,8 @@ static int f2fs_discard_obsolete_dnode(void)
 static int f2fs_write_root_inode(void)
 {
 	struct f2fs_node *raw_node = NULL;
-	u_int64_t blk_size_bytes, data_blk_nor;
-	u_int64_t main_area_node_seg_blk_offset = 0;
+	uint64_t blk_size_bytes, data_blk_nor;
+	uint64_t main_area_node_seg_blk_offset = 0;
 
 	raw_node = calloc(F2FS_BLKSIZE, 1);
 	if (raw_node == NULL) {
@@ -1356,8 +1356,8 @@ static int f2fs_write_default_quota(int qtype, unsigned int blkaddr,
 static int f2fs_write_qf_inode(int qtype, int offset)
 {
 	struct f2fs_node *raw_node = NULL;
-	u_int64_t data_blk_nor;
-	u_int64_t main_area_node_seg_blk_offset = 0;
+	uint64_t data_blk_nor;
+	uint64_t main_area_node_seg_blk_offset = 0;
 	__le32 raw_id;
 	int i;
 
@@ -1419,7 +1419,7 @@ static int f2fs_write_qf_inode(int qtype, int offset)
 static int f2fs_update_nat_root(void)
 {
 	struct f2fs_nat_block *nat_blk = NULL;
-	u_int64_t nat_seg_blk_offset = 0;
+	uint64_t nat_seg_blk_offset = 0;
 	enum quota_type qtype;
 	int i;
 
@@ -1515,7 +1515,7 @@ static block_t f2fs_add_default_dentry_lpf(void)
 static int f2fs_write_lpf_inode(void)
 {
 	struct f2fs_node *raw_node;
-	u_int64_t blk_size_bytes, main_area_node_seg_blk_offset;
+	uint64_t blk_size_bytes, main_area_node_seg_blk_offset;
 	block_t data_blk_nor;
 	int err = 0;
 
@@ -1609,7 +1609,7 @@ exit:
 static int f2fs_add_default_dentry_root(void)
 {
 	struct f2fs_dentry_block *dent_blk = NULL;
-	u_int64_t data_blk_offset = 0;
+	uint64_t data_blk_offset = 0;
 
 	dent_blk = calloc(F2FS_BLKSIZE, 1);
 	if(dent_blk == NULL) {
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 797e90a948f5..d05d4e2cb4e5 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -253,7 +253,7 @@ static void f2fs_parse_options(int argc, char *argv[])
 			break;
 		case 'S':
 			c.device_size = atoll(optarg);
-			c.device_size &= (~((u_int64_t)(F2FS_BLKSIZE - 1)));
+			c.device_size &= (~((uint64_t)(F2FS_BLKSIZE - 1)));
 			c.sparse_mode = 1;
 			break;
 		case 'z':
diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c
index f2d55adb7e4b..e84311ae1287 100644
--- a/mkfs/f2fs_format_utils.c
+++ b/mkfs/f2fs_format_utils.c
@@ -52,7 +52,7 @@ static int trim_device(int i)
 	unsigned long long range[2];
 	struct stat *stat_buf;
 	struct device_info *dev = c.devices + i;
-	u_int64_t bytes = dev->total_sectors * dev->sector_size;
+	uint64_t bytes = dev->total_sectors * dev->sector_size;
 	int fd = dev->fd;
 
 	stat_buf = malloc(sizeof(struct stat));
diff --git a/mkfs/f2fs_format_utils.h b/mkfs/f2fs_format_utils.h
index 274db7bff5db..807e7c327601 100644
--- a/mkfs/f2fs_format_utils.h
+++ b/mkfs/f2fs_format_utils.h
@@ -12,6 +12,6 @@
 
 extern struct f2fs_configuration c;
 
-int f2fs_trim_device(int, u_int64_t);
+int f2fs_trim_device(int, uint64_t);
 int f2fs_trim_devices(void);
 int f2fs_format_device(void);
diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h
index cdaf00f421fe..bd8db0b724e5 100644
--- a/tools/f2fs_io/f2fs_io.h
+++ b/tools/f2fs_io/f2fs_io.h
@@ -30,10 +30,10 @@
 # define UNUSED(x) x
 #endif
 
-typedef u_int64_t	u64;
-typedef u_int32_t	u32;
-typedef u_int16_t	u16;
-typedef u_int8_t	u8;
+typedef uint64_t	u64;
+typedef uint32_t	u32;
+typedef uint16_t	u16;
+typedef uint8_t		u8;
 
 #ifndef HAVE_LINUX_TYPES_H
 typedef u8	__u8;


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 07/31] Change the ANDROID_WINDOWS_HOST macro into _WIN32
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (5 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 06/31] Switch from the u_int to the uint types Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-22 17:53   ` Jaegeuk Kim
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 08/31] ci: Build f2fstools upon push and pull requests Bart Van Assche
                   ` (23 subsequent siblings)
  30 siblings, 1 reply; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

This makes it easier to build f2fs-tools for Windows.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 lib/libf2fs.c            | 10 +++++-----
 lib/libf2fs_io.c         |  6 +++---
 lib/libf2fs_zoned.c      |  2 +-
 mkfs/f2fs_format.c       |  2 +-
 mkfs/f2fs_format_main.c  |  2 +-
 mkfs/f2fs_format_utils.c |  4 ++--
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index b0a892772de1..c7102528f2f4 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -22,7 +22,7 @@
 #endif
 #include <time.h>
 #include <sys/stat.h>
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #endif
@@ -49,7 +49,7 @@
 #define MODELINQUIRY	0x12,0x00,0x00,0x00,0x4A,0x00
 #endif
 
-#ifndef ANDROID_WINDOWS_HOST /* O_BINARY is windows-specific flag */
+#ifndef _WIN32 /* O_BINARY is windows-specific flag */
 #define O_BINARY 0
 #else
 /* On Windows, wchar_t is 8 bit sized and it causes compilation errors. */
@@ -606,7 +606,7 @@ int write_inode(struct f2fs_node *inode, u64 blkaddr)
  */
 char *get_rootdev()
 {
-#if defined(ANDROID_WINDOWS_HOST) || defined(WITH_ANDROID)
+#if defined(_WIN32) || defined(WITH_ANDROID)
 	return NULL;
 #else
 	struct stat sb;
@@ -740,7 +740,7 @@ static int is_mounted(const char *mpt, const char *device)
 
 int f2fs_dev_is_umounted(char *path)
 {
-#ifdef ANDROID_WINDOWS_HOST
+#ifdef _WIN32
 	return 0;
 #else
 	struct stat *st_buf;
@@ -872,7 +872,7 @@ void get_kernel_uname_version(__u8 *version)
 #define BLKSSZGET	DKIOCGETBLOCKCOUNT
 #endif /* APPLE_DARWIN */
 
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 static int open_check_fs(char *path, int flag)
 {
 	if (c.func != DUMP && (c.func != FSCK || c.fix_on || c.auto_fix))
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index b985e6f37a0a..bf6dfe240bb7 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -23,7 +23,7 @@
 #include <mntent.h>
 #endif
 #include <time.h>
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 #include <sys/stat.h>
 #include <sys/mount.h>
 #include <sys/ioctl.h>
@@ -634,7 +634,7 @@ int dev_reada_block(__u64 blk_addr)
 
 int f2fs_fsync_device(void)
 {
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 	int i;
 
 	for (i = 0; i < c.ndevs; i++) {
@@ -783,7 +783,7 @@ int f2fs_finalize_device(void)
 	 * in the block device page cache.
 	 */
 	for (i = 0; i < c.ndevs; i++) {
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 		ret = fsync(c.devices[i].fd);
 		if (ret < 0) {
 			MSG(0, "\tError: Could not conduct fsync!!!\n");
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index c408a4991fa1..cb954feabe61 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -22,7 +22,7 @@
 #ifdef HAVE_LINUX_LIMITS_H
 #include <linux/limits.h>
 #endif
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 #include <sys/ioctl.h>
 #endif
 #include <libgen.h>
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 8bd33ac003c5..332abf60d0d9 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -13,7 +13,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 #include <sys/stat.h>
 #include <sys/mount.h>
 #endif
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index d05d4e2cb4e5..ecc942b61d63 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -15,7 +15,7 @@
 #include <stdbool.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 #include <sys/mount.h>
 #endif
 #include <time.h>
diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c
index e84311ae1287..53101d1bd790 100644
--- a/mkfs/f2fs_format_utils.c
+++ b/mkfs/f2fs_format_utils.c
@@ -26,7 +26,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdbool.h>
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 #include <sys/ioctl.h>
 #endif
 #include <sys/stat.h>
@@ -48,7 +48,7 @@
 
 static int trim_device(int i)
 {
-#ifndef ANDROID_WINDOWS_HOST
+#ifndef _WIN32
 	unsigned long long range[2];
 	struct stat *stat_buf;
 	struct device_info *dev = c.devices + i;


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 08/31] ci: Build f2fstools upon push and pull requests
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (6 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 07/31] Change the ANDROID_WINDOWS_HOST macro into _WIN32 Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 09/31] Change one array member into a flexible array member Bart Van Assche
                   ` (22 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

For those who use Github to contribute f2fs-tools patches, let the
github servers build the f2fs-tools source code upon every push and pull
requests. This change does not affect users who do not use Github.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 .github/workflows/ci.yml | 70 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 .github/workflows/ci.yml

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000000..0c774f92fac8
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,70 @@
+# See also https://docs.github.com/en/actions/learn-github-actions/expressions
+# See also https://github.com/marketplace/actions/setup-android-ndk
+
+name: CI
+
+on: [push, pull_request]
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        build:
+        - android
+        - linux-gcc
+        - linux-clang
+        - linux-x86-gcc
+        - linux-powerpc64-gcc
+        - linux-mingw64-gcc
+        - macos
+        include:
+        - build: android
+          cc: clang
+          host: aarch64-linux-android32
+        - build: linux-gcc
+          cc: gcc
+        - build: linux-clang
+          cc: clang
+        - build: linux-x86-gcc
+          cc: gcc
+          arch: x86
+        - build: linux-powerpc64-gcc
+          cc: gcc
+          host: powerpc64-linux-gnu
+        - build: linux-mingw64-gcc
+          cc: gcc
+          host: x86_64-w64-mingw32
+          cflags: -D__USE_MINGW_ANSI_STDIO
+        - build: macos
+          cc: clang
+          os: macos-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Install Android NDK
+        run: |
+          if [ ${{matrix.build}} = android ]; then \
+              wget --quiet https://dl.google.com/android/repository/android-ndk-r24-linux.zip; \
+              unzip -q android-ndk-r24-linux.zip;  \
+          fi
+      - name: Install Ubuntu packages
+        run: |
+          sudo apt-get -q update
+          case "${{matrix.host}}" in                                        \
+            x86_64-w64-mingw32)                                             \
+              sudo apt-get -q install -y binutils-mingw-w64 gcc-mingw-w64;; \
+            powerpc64-linux-gnu)                                            \
+              sudo apt-get -q install -y binutils-powerpc64-linux-gnu       \
+              gcc-powerpc64-linux-gnu;;                                     \
+          esac
+      - name: Build
+        run: |
+          echo "HOST=${{matrix.host}}"
+          NDK=$PWD/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin
+          export PATH="$NDK:$PATH"
+          ./autogen.sh
+          ./configure --host=${{matrix.host}} \
+              CC=${{ matrix.host && format('{0}-{1}', matrix.host, matrix.cc) || matrix.cc }} \
+              CFLAGS="${{matrix.cflags}}"
+          make -j$(nproc)


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 09/31] Change one array member into a flexible array member
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (7 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 08/31] ci: Build f2fstools upon push and pull requests Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 10/31] Verify structure sizes at compile time Bart Van Assche
                   ` (21 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Prepare for verifying structure sizes with static_assert().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/f2fs.h       | 4 ++--
 include/f2fs_fs.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fsck/f2fs.h b/fsck/f2fs.h
index 7fb328ff8861..eacfd42478b8 100644
--- a/fsck/f2fs.h
+++ b/fsck/f2fs.h
@@ -381,7 +381,7 @@ static inline void *__bitmap_ptr(struct f2fs_sb_info *sbi, int flag)
 					CP_MIN_CHKSUM_OFFSET)
 			chksum_size = sizeof(__le32);
 
-		return &ckpt->sit_nat_version_bitmap + offset + chksum_size;
+		return &ckpt->sit_nat_version_bitmap[offset + chksum_size];
 	}
 
 	if (le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_payload) > 0) {
@@ -392,7 +392,7 @@ static inline void *__bitmap_ptr(struct f2fs_sb_info *sbi, int flag)
 	} else {
 		offset = (flag == NAT_BITMAP) ?
 			le32_to_cpu(ckpt->sit_ver_bitmap_bytesize) : 0;
-		return &ckpt->sit_nat_version_bitmap + offset;
+		return &ckpt->sit_nat_version_bitmap[offset];
 	}
 }
 
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 1e38d93ff40d..e6fc8a0e08f6 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -832,7 +832,7 @@ struct f2fs_checkpoint {
 	unsigned char alloc_type[MAX_ACTIVE_LOGS];
 
 	/* SIT and NAT version bitmap */
-	unsigned char sit_nat_version_bitmap[1];
+	unsigned char sit_nat_version_bitmap[];
 } __attribute__((packed));
 
 #define CP_BITMAP_OFFSET	\


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 10/31] Verify structure sizes at compile time
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (8 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 09/31] Change one array member into a flexible array member Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-06-10  2:05   ` Peter Collingbourne via Linux-f2fs-devel
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 11/31] Suppress a compiler warning Bart Van Assche
                   ` (20 subsequent siblings)
  30 siblings, 1 reply; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Before modifying the __attribute__((packed)) annotations, let the
compiler verify the sizes of on-disk data structures.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/quotaio.c      |  2 ++
 fsck/quotaio_tree.h |  2 ++
 fsck/quotaio_v2.h   |  6 +++++
 fsck/xattr.h        |  2 ++
 include/f2fs_fs.h   | 54 +++++++++++++++++++++++++++++++++++++++++++++
 include/quota.h     |  7 ++++++
 tools/f2fscrypt.c   |  4 ++++
 7 files changed, 77 insertions(+)

diff --git a/fsck/quotaio.c b/fsck/quotaio.c
index 51abbb7b2c57..52e962432c72 100644
--- a/fsck/quotaio.c
+++ b/fsck/quotaio.c
@@ -33,6 +33,8 @@ struct disk_dqheader {
 	__le32 dqh_version;
 } __attribute__ ((packed));
 
+static_assert(sizeof(struct disk_dqheader) == 8, "");
+
 int cur_qtype = -1;
 u32 qf_last_blkofs[MAXQUOTAS] = {0, 0, 0};
 enum qf_szchk_type_t qf_szchk_type[MAXQUOTAS] =
diff --git a/fsck/quotaio_tree.h b/fsck/quotaio_tree.h
index 8f4dae054691..b88c55c01d5c 100644
--- a/fsck/quotaio_tree.h
+++ b/fsck/quotaio_tree.h
@@ -35,6 +35,8 @@ struct qt_disk_dqdbheader {
 	__le32 dqdh_pad2;
 } __attribute__ ((packed));
 
+static_assert(sizeof(struct qt_disk_dqdbheader) == 16, "");
+
 struct dquot;
 struct quota_handle;
 
diff --git a/fsck/quotaio_v2.h b/fsck/quotaio_v2.h
index de2db2785cb0..a37300d78bd0 100644
--- a/fsck/quotaio_v2.h
+++ b/fsck/quotaio_v2.h
@@ -20,6 +20,8 @@ struct v2_disk_dqheader {
 	__le32 dqh_version;	/* File version */
 } __attribute__ ((packed));
 
+static_assert(sizeof(struct v2_disk_dqheader) == 8, "");
+
 /* Flags for version specific files */
 #define V2_DQF_MASK  0x0000	/* Mask for all valid ondisk flags */
 
@@ -36,6 +38,8 @@ struct v2_disk_dqinfo {
 					 * free entry */
 } __attribute__ ((packed));
 
+static_assert(sizeof(struct v2_disk_dqinfo) == 24, "");
+
 struct v2r1_disk_dqblk {
 	__le32 dqb_id;	/* id this quota applies to */
 	__le32 dqb_pad;
@@ -51,4 +55,6 @@ struct v2r1_disk_dqblk {
 	__le64 dqb_itime;	/* time limit for excessive inode use */
 } __attribute__ ((packed));
 
+static_assert(sizeof(struct v2r1_disk_dqblk) == 72, "");
+
 #endif
diff --git a/fsck/xattr.h b/fsck/xattr.h
index 579ab6c42585..5709a7df7adb 100644
--- a/fsck/xattr.h
+++ b/fsck/xattr.h
@@ -47,6 +47,8 @@ struct fscrypt_context {
 	u8 nonce[FS_KEY_DERIVATION_NONCE_SIZE];
 } __attribute__((packed));
 
+static_assert(sizeof(struct fscrypt_context) == 28, "");
+
 #define F2FS_ACL_VERSION	0x0001
 
 struct f2fs_acl_entry {
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index e6fc8a0e08f6..7804dd158de4 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -68,6 +68,10 @@
 # define UNUSED(x) x
 #endif
 
+#ifndef static_assert
+#define static_assert _Static_assert
+#endif
+
 #ifdef ANDROID_WINDOWS_HOST
 #undef HAVE_LINUX_TYPES_H
 #endif
@@ -737,6 +741,8 @@ struct f2fs_device {
 	__le32 total_segments;
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_device) == 68, "");
+
 struct f2fs_super_block {
 	__le32 magic;			/* Magic Number */
 	__le16 major_ver;		/* Major Version */
@@ -784,6 +790,8 @@ struct f2fs_super_block {
 	__le32 crc;			/* checksum of superblock */
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_super_block) == 3072, "");
+
 /*
  * For checkpoint
  */
@@ -835,6 +843,8 @@ struct f2fs_checkpoint {
 	unsigned char sit_nat_version_bitmap[];
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_checkpoint) == 192, "");
+
 #define CP_BITMAP_OFFSET	\
 	(offsetof(struct f2fs_checkpoint, sit_nat_version_bitmap))
 #define CP_MIN_CHKSUM_OFFSET	CP_BITMAP_OFFSET
@@ -859,6 +869,8 @@ struct f2fs_orphan_block {
 	__le32 check_sum;	/* CRC32 for orphan inode block */
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_orphan_block) == 4096, "");
+
 /*
  * For NODE structure
  */
@@ -868,6 +880,8 @@ struct f2fs_extent {
 	__le32 len;		/* lengh of the extent */
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_extent) == 12, "");
+
 #define F2FS_NAME_LEN		255
 
 /* max output length of pretty_print_filename() including null terminator */
@@ -1013,15 +1027,20 @@ struct f2fs_inode {
 						double_indirect(1) node id */
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_inode) == 4072, "");
 
 struct direct_node {
 	__le32 addr[DEF_ADDRS_PER_BLOCK];	/* array of data block address */
 } __attribute__((packed));
 
+static_assert(sizeof(struct direct_node) == 4072, "");
+
 struct indirect_node {
 	__le32 nid[NIDS_PER_BLOCK];	/* array of data block address */
 } __attribute__((packed));
 
+static_assert(sizeof(struct indirect_node) == 4072, "");
+
 enum {
 	COLD_BIT_SHIFT = 0,
 	FSYNC_BIT_SHIFT,
@@ -1039,6 +1058,8 @@ struct node_footer {
 	__le32 next_blkaddr;	/* next node page block address */
 } __attribute__((packed));
 
+static_assert(sizeof(struct node_footer) == 24, "");
+
 struct f2fs_node {
 	/* can be one of three types: inode, direct, and indirect types */
 	union {
@@ -1049,6 +1070,8 @@ struct f2fs_node {
 	struct node_footer footer;
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_node) == 4096, "");
+
 /*
  * For NAT entries
  */
@@ -1063,10 +1086,14 @@ struct f2fs_nat_entry {
 	__le32 block_addr;	/* block address */
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_nat_entry) == 9, "");
+
 struct f2fs_nat_block {
 	struct f2fs_nat_entry entries[NAT_ENTRY_PER_BLOCK];
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_nat_block) == 4095, "");
+
 /*
  * For SIT entries
  *
@@ -1106,10 +1133,14 @@ struct f2fs_sit_entry {
 	__le64 mtime;				/* segment age for cleaning */
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_sit_entry) == 74, "");
+
 struct f2fs_sit_block {
 	struct f2fs_sit_entry entries[SIT_ENTRY_PER_BLOCK];
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_sit_block) == 4070, "");
+
 /*
  * For segment summary
  *
@@ -1142,6 +1173,8 @@ struct f2fs_summary {
 	};
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_summary) == 7, "");
+
 /* summary block type, node or data, is stored to the summary_footer */
 #define SUM_TYPE_NODE		(1)
 #define SUM_TYPE_DATA		(0)
@@ -1151,6 +1184,8 @@ struct summary_footer {
 	__le32 check_sum;		/* summary checksum */
 } __attribute__((packed));
 
+static_assert(sizeof(struct summary_footer) == 5, "");
+
 #define SUM_JOURNAL_SIZE	(F2FS_BLKSIZE - SUM_FOOTER_SIZE -\
 				SUM_ENTRIES_SIZE)
 #define NAT_JOURNAL_ENTRIES	((SUM_JOURNAL_SIZE - 2) /\
@@ -1182,26 +1217,36 @@ struct nat_journal_entry {
 	struct f2fs_nat_entry ne;
 } __attribute__((packed));
 
+static_assert(sizeof(struct nat_journal_entry) == 13, "");
+
 struct nat_journal {
 	struct nat_journal_entry entries[NAT_JOURNAL_ENTRIES];
 	__u8 reserved[NAT_JOURNAL_RESERVED];
 } __attribute__((packed));
 
+static_assert(sizeof(struct nat_journal) == 505, "");
+
 struct sit_journal_entry {
 	__le32 segno;
 	struct f2fs_sit_entry se;
 } __attribute__((packed));
 
+static_assert(sizeof(struct sit_journal_entry) == 78, "");
+
 struct sit_journal {
 	struct sit_journal_entry entries[SIT_JOURNAL_ENTRIES];
 	__u8 reserved[SIT_JOURNAL_RESERVED];
 } __attribute__((packed));
 
+static_assert(sizeof(struct sit_journal) == 505, "");
+
 struct f2fs_extra_info {
 	__le64 kbytes_written;
 	__u8 reserved[EXTRA_INFO_RESERVED];
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_extra_info) == 505, "");
+
 struct f2fs_journal {
 	union {
 		__le16 n_nats;
@@ -1215,6 +1260,8 @@ struct f2fs_journal {
 	};
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_journal) == 507, "");
+
 /* 4KB-sized summary block structure */
 struct f2fs_summary_block {
 	struct f2fs_summary entries[ENTRIES_IN_SUM];
@@ -1222,6 +1269,8 @@ struct f2fs_summary_block {
 	struct summary_footer footer;
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_summary_block) == 4096, "");
+
 /*
  * For directory operations
  */
@@ -1263,6 +1312,8 @@ struct f2fs_dir_entry {
 	__u8 file_type;		/* file type */
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_dir_entry) == 11, "");
+
 /* 4KB-sized directory entry block */
 struct f2fs_dentry_block {
 	/* validity bitmap for directory entries in each block */
@@ -1271,6 +1322,9 @@ struct f2fs_dentry_block {
 	struct f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK];
 	__u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN];
 } __attribute__((packed));
+
+static_assert(sizeof(struct f2fs_dentry_block) == 4096, "");
+
 #pragma pack(pop)
 
 /* for inline stuff */
diff --git a/include/quota.h b/include/quota.h
index 627a86f6421f..5b7aaa891d28 100644
--- a/include/quota.h
+++ b/include/quota.h
@@ -50,6 +50,8 @@ struct v2_disk_dqheader {
 	uint32_t dqh_version;	/* File version */
 } __attribute__ ((packed));
 
+static_assert(sizeof(struct v2_disk_dqheader) == 8, "");
+
 /* Header with type and version specific information */
 struct v2_disk_dqinfo {
 	uint32_t dqi_bgrace;	/* Time before block soft limit becomes hard limit */
@@ -60,6 +62,8 @@ struct v2_disk_dqinfo {
 	uint32_t dqi_free_entry;	/* Number of block with at least one free entry */
 } __attribute__ ((packed));
 
+static_assert(sizeof(struct v2_disk_dqinfo) == 24, "");
+
 struct v2r1_disk_dqblk {
 	__le32 dqb_id;  	/* id this quota applies to */
 	__le32 dqb_pad;
@@ -74,6 +78,9 @@ struct v2r1_disk_dqblk {
 	__le64 dqb_btime;       /* time limit for excessive disk use */
 	__le64 dqb_itime;       /* time limit for excessive inode use */
 } __attribute__ ((packed));
+
+static_assert(sizeof(struct v2r1_disk_dqblk) == 72, "");
+
 #pragma pack(pop)
 
 #endif
diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c
index fe3e0ff3c1a9..97624ba5e185 100644
--- a/tools/f2fscrypt.c
+++ b/tools/f2fscrypt.c
@@ -104,6 +104,8 @@ struct f2fs_fscrypt_policy {
 	__u8 master_key_descriptor[F2FS_KEY_DESCRIPTOR_SIZE];
 } __attribute__((packed));
 
+static_assert(sizeof(struct f2fs_fscrypt_policy) == 12, "");
+
 #define F2FS_IOC_SET_ENCRYPTION_POLICY	_IOR('f', 19, struct f2fs_fscrypt_policy)
 #define F2FS_IOC_GET_ENCRYPTION_PWSALT	_IOW('f', 20, __u8[16])
 #define F2FS_IOC_GET_ENCRYPTION_POLICY	_IOW('f', 21, struct f2fs_fscrypt_policy)
@@ -121,6 +123,8 @@ struct f2fs_encryption_key {
         __u32 size;
 } __attribute__((__packed__));
 
+static_assert(sizeof(struct f2fs_encryption_key) == 72, "");
+
 int options;
 
 extern void f2fs_sha512(const unsigned char *in, unsigned long in_size,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 11/31] Suppress a compiler warning
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (9 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 10/31] Verify structure sizes at compile time Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 12/31] f2fs_fs.h: Use standard fixed width integer types Bart Van Assche
                   ` (19 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Suppress the following compiler warning:

segment.c:698:12: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  698 |         if (n < 0)
      |            ^

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fsck/segment.c b/fsck/segment.c
index fe63615423f7..254a0d1425e9 100644
--- a/fsck/segment.c
+++ b/fsck/segment.c
@@ -555,7 +555,7 @@ exit:
 
 int f2fs_build_file(struct f2fs_sb_info *sbi, struct dentry *de)
 {
-	int fd, n;
+	int fd, n = -1;
 	pgoff_t off = 0;
 	u8 buffer[BLOCK_SZ];
 	struct node_info ni;


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 12/31] f2fs_fs.h: Use standard fixed width integer types
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (10 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 11/31] Suppress a compiler warning Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 13/31] Remove unnecessary __attribute__((packed)) annotations Bart Van Assche
                   ` (18 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Use uint64_t instead of __u64 in the definitions of the endianness
conversion macros. This patch fixes the following compiler warning:

dir.c: In function ‘f2fs_create’:
dir.c:785:16: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 12 has type ‘long long unsigned int’ [-Wformat=]
  785 |         MSG(1, "Info: Create %s -> %s\n"
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~
../include/f2fs_fs.h:252:32: note: in definition of macro ‘MSG’
  252 |                         printf(fmt, ##__VA_ARGS__);                     \
      |                                ^~~

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/mount.c      |  2 +-
 include/f2fs_fs.h | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index f15260e02cab..e075d3184f83 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -250,7 +250,7 @@ void print_inode_info(struct f2fs_sb_info *sbi,
 		MSG(0, " - File name         : %s%s\n", en,
 				enc_name ? " <encrypted>" : "");
 		setlocale(LC_ALL, "");
-		MSG(0, " - File size         : %'llu (bytes)\n",
+		MSG(0, " - File size         : %'" PRIu64 " (bytes)\n",
 				le64_to_cpu(inode->i_size));
 		return;
 	}
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 7804dd158de4..cfd3b711f288 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -188,12 +188,12 @@ static inline uint64_t bswap_64(uint64_t val)
 #endif
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
-#define le16_to_cpu(x)	((__u16)(x))
-#define le32_to_cpu(x)	((__u32)(x))
-#define le64_to_cpu(x)	((__u64)(x))
-#define cpu_to_le16(x)	((__u16)(x))
-#define cpu_to_le32(x)	((__u32)(x))
-#define cpu_to_le64(x)	((__u64)(x))
+#define le16_to_cpu(x)	((uint16_t)(x))
+#define le32_to_cpu(x)	((uint32_t)(x))
+#define le64_to_cpu(x)	((uint64_t)(x))
+#define cpu_to_le16(x)	((uint16_t)(x))
+#define cpu_to_le32(x)	((uint32_t)(x))
+#define cpu_to_le64(x)	((uint64_t)(x))
 #elif __BYTE_ORDER == __BIG_ENDIAN
 #define le16_to_cpu(x)	bswap_16(x)
 #define le32_to_cpu(x)	bswap_32(x)
@@ -291,10 +291,10 @@ static inline uint64_t bswap_64(uint64_t val)
 	do {								\
 		assert(sizeof((ptr)->member) == 8);			\
 		if (c.layout)						\
-			printf("%-30s %llu\n",				\
+			printf("%-30s %" PRIu64 "\n",			\
 			#member":", le64_to_cpu(((ptr)->member)));	\
 		else							\
-			printf("%-30s" "\t\t[0x%8llx : %llu]\n",	\
+			printf("%-30s" "\t\t[0x%8" PRIx64 " : %" PRIu64 "]\n",	\
 			#member, le64_to_cpu(((ptr)->member)),		\
 			le64_to_cpu(((ptr)->member)));			\
 	} while (0)


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 13/31] Remove unnecessary __attribute__((packed)) annotations
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (11 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 12/31] f2fs_fs.h: Use standard fixed width integer types Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 14/31] Move the be32_to_cpu() definition Bart Van Assche
                   ` (17 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Applying the __attribute__((packed)) annotation to members that do not
need it impacts performance negatively on architectures that do not
support efficient unaligned accesses (e.g. ARMv7). Hence minimize the
__attribute__((packed)) annotations.

See also CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS in the Linux kernel.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/quotaio.c      |  2 +-
 fsck/quotaio_tree.h |  2 +-
 fsck/quotaio_v2.h   |  6 +++---
 fsck/xattr.h        |  2 +-
 include/f2fs_fs.h   | 52 ++++++++++++++++++++++-----------------------
 include/quota.h     |  9 +++-----
 tools/f2fscrypt.c   |  4 ++--
 7 files changed, 37 insertions(+), 40 deletions(-)

diff --git a/fsck/quotaio.c b/fsck/quotaio.c
index 52e962432c72..a3815b0c8835 100644
--- a/fsck/quotaio.c
+++ b/fsck/quotaio.c
@@ -31,7 +31,7 @@ static const char * const extensions[MAXQUOTAS] = {
 struct disk_dqheader {
 	__le32 dqh_magic;
 	__le32 dqh_version;
-} __attribute__ ((packed));
+};
 
 static_assert(sizeof(struct disk_dqheader) == 8, "");
 
diff --git a/fsck/quotaio_tree.h b/fsck/quotaio_tree.h
index b88c55c01d5c..8072c6e188fd 100644
--- a/fsck/quotaio_tree.h
+++ b/fsck/quotaio_tree.h
@@ -33,7 +33,7 @@ struct qt_disk_dqdbheader {
 	__le16 dqdh_entries; /* Number of valid entries in block */
 	__le16 dqdh_pad1;
 	__le32 dqdh_pad2;
-} __attribute__ ((packed));
+};
 
 static_assert(sizeof(struct qt_disk_dqdbheader) == 16, "");
 
diff --git a/fsck/quotaio_v2.h b/fsck/quotaio_v2.h
index a37300d78bd0..b054422f5a6e 100644
--- a/fsck/quotaio_v2.h
+++ b/fsck/quotaio_v2.h
@@ -18,7 +18,7 @@
 struct v2_disk_dqheader {
 	__le32 dqh_magic;	/* Magic number identifying file */
 	__le32 dqh_version;	/* File version */
-} __attribute__ ((packed));
+};
 
 static_assert(sizeof(struct v2_disk_dqheader) == 8, "");
 
@@ -36,7 +36,7 @@ struct v2_disk_dqinfo {
 	__le32 dqi_free_blk;	/* Number of first free block in the list */
 	__le32 dqi_free_entry;	/* Number of block with at least one
 					 * free entry */
-} __attribute__ ((packed));
+};
 
 static_assert(sizeof(struct v2_disk_dqinfo) == 24, "");
 
@@ -53,7 +53,7 @@ struct v2r1_disk_dqblk {
 	__le64 dqb_curspace;	/* current space occupied (in bytes) */
 	__le64 dqb_btime;	/* time limit for excessive disk use */
 	__le64 dqb_itime;	/* time limit for excessive inode use */
-} __attribute__ ((packed));
+};
 
 static_assert(sizeof(struct v2r1_disk_dqblk) == 72, "");
 
diff --git a/fsck/xattr.h b/fsck/xattr.h
index 5709a7df7adb..4e4b50d47bd7 100644
--- a/fsck/xattr.h
+++ b/fsck/xattr.h
@@ -45,7 +45,7 @@ struct fscrypt_context {
 	u8 flags;
 	u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE];
 	u8 nonce[FS_KEY_DERIVATION_NONCE_SIZE];
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct fscrypt_context) == 28, "");
 
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index cfd3b711f288..49438eb2e6f2 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -735,11 +735,10 @@ enum {
 /*
  * For superblock
  */
-#pragma pack(push, 1)
 struct f2fs_device {
 	__u8 path[MAX_PATH_LEN];
 	__le32 total_segments;
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_device) == 68, "");
 
@@ -754,7 +753,8 @@ struct f2fs_super_block {
 	__le32 segs_per_sec;		/* # of segments per section */
 	__le32 secs_per_zone;		/* # of sections per zone */
 	__le32 checksum_offset;		/* checksum offset inside super block */
-	__le64 block_count;		/* total # of user blocks */
+	__le64 block_count __attribute__((packed));
+					/* total # of user blocks */
 	__le32 section_count;		/* total # of sections */
 	__le32 segment_count;		/* total # of segments */
 	__le32 segment_count_ckpt;	/* # of segments for checkpoint */
@@ -781,14 +781,14 @@ struct f2fs_super_block {
 	__le32 feature;			/* defined features */
 	__u8 encryption_level;		/* versioning level for encryption */
 	__u8 encrypt_pw_salt[16];	/* Salt used for string2key algorithm */
-	struct f2fs_device devs[MAX_DEVICES];	/* device list */
-	__le32 qf_ino[F2FS_MAX_QUOTAS];	/* quota inode numbers */
+	struct f2fs_device devs[MAX_DEVICES] __attribute__((packed));	/* device list */
+	__le32 qf_ino[F2FS_MAX_QUOTAS] __attribute__((packed));	/* quota inode numbers */
 	__u8 hot_ext_count;		/* # of hot file extension */
 	__le16  s_encoding;		/* Filename charset encoding */
 	__le16  s_encoding_flags;	/* Filename charset encoding flags */
 	__u8 reserved[306];		/* valid reserved region */
 	__le32 crc;			/* checksum of superblock */
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_super_block) == 3072, "");
 
@@ -841,7 +841,7 @@ struct f2fs_checkpoint {
 
 	/* SIT and NAT version bitmap */
 	unsigned char sit_nat_version_bitmap[];
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_checkpoint) == 192, "");
 
@@ -867,7 +867,7 @@ struct f2fs_orphan_block {
 	__le16 blk_count;	/* Number of orphan inode blocks in CP */
 	__le32 entry_count;	/* Total number of orphan nodes in current CP */
 	__le32 check_sum;	/* CRC32 for orphan inode block */
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_orphan_block) == 4096, "");
 
@@ -878,7 +878,7 @@ struct f2fs_extent {
 	__le32 fofs;		/* start file offset of the extent */
 	__le32 blk_addr;	/* start block address of the extent */
 	__le32 len;		/* lengh of the extent */
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_extent) == 12, "");
 
@@ -1005,7 +1005,7 @@ struct f2fs_inode {
 	__u8 i_name[F2FS_NAME_LEN];	/* file name for SPOR */
 	__u8 i_dir_level;		/* dentry_level for large dir */
 
-	struct f2fs_extent i_ext;	/* caching a largest extent */
+	struct f2fs_extent i_ext __attribute__((packed));	/* caching a largest extent */
 
 	union {
 		struct {
@@ -1025,19 +1025,21 @@ struct f2fs_inode {
 	};
 	__le32 i_nid[5];		/* direct(2), indirect(2),
 						double_indirect(1) node id */
-} __attribute__((packed));
+};
 
+static_assert(offsetof(struct f2fs_inode, i_extra_end) -
+	      offsetof(struct f2fs_inode, i_extra_isize) == 36, "");
 static_assert(sizeof(struct f2fs_inode) == 4072, "");
 
 struct direct_node {
 	__le32 addr[DEF_ADDRS_PER_BLOCK];	/* array of data block address */
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct direct_node) == 4072, "");
 
 struct indirect_node {
 	__le32 nid[NIDS_PER_BLOCK];	/* array of data block address */
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct indirect_node) == 4072, "");
 
@@ -1054,9 +1056,9 @@ struct node_footer {
 	__le32 nid;		/* node id */
 	__le32 ino;		/* inode nunmber */
 	__le32 flag;		/* include cold/fsync/dentry marks and offset */
-	__le64 cp_ver;		/* checkpoint version */
+	__le64 cp_ver __attribute__((packed));		/* checkpoint version */
 	__le32 next_blkaddr;	/* next node page block address */
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct node_footer) == 24, "");
 
@@ -1068,7 +1070,7 @@ struct f2fs_node {
 		struct indirect_node in;
 	};
 	struct node_footer footer;
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_node) == 4096, "");
 
@@ -1090,7 +1092,7 @@ static_assert(sizeof(struct f2fs_nat_entry) == 9, "");
 
 struct f2fs_nat_block {
 	struct f2fs_nat_entry entries[NAT_ENTRY_PER_BLOCK];
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_nat_block) == 4095, "");
 
@@ -1137,7 +1139,7 @@ static_assert(sizeof(struct f2fs_sit_entry) == 74, "");
 
 struct f2fs_sit_block {
 	struct f2fs_sit_entry entries[SIT_ENTRY_PER_BLOCK];
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_sit_block) == 4070, "");
 
@@ -1181,8 +1183,8 @@ static_assert(sizeof(struct f2fs_summary) == 7, "");
 
 struct summary_footer {
 	unsigned char entry_type;	/* SUM_TYPE_XXX */
-	__le32 check_sum;		/* summary checksum */
-} __attribute__((packed));
+	__le32 check_sum __attribute__((packed)); /* summary checksum */
+};
 
 static_assert(sizeof(struct summary_footer) == 5, "");
 
@@ -1222,7 +1224,7 @@ static_assert(sizeof(struct nat_journal_entry) == 13, "");
 struct nat_journal {
 	struct nat_journal_entry entries[NAT_JOURNAL_ENTRIES];
 	__u8 reserved[NAT_JOURNAL_RESERVED];
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct nat_journal) == 505, "");
 
@@ -1236,7 +1238,7 @@ static_assert(sizeof(struct sit_journal_entry) == 78, "");
 struct sit_journal {
 	struct sit_journal_entry entries[SIT_JOURNAL_ENTRIES];
 	__u8 reserved[SIT_JOURNAL_RESERVED];
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct sit_journal) == 505, "");
 
@@ -1267,7 +1269,7 @@ struct f2fs_summary_block {
 	struct f2fs_summary entries[ENTRIES_IN_SUM];
 	struct f2fs_journal journal;
 	struct summary_footer footer;
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_summary_block) == 4096, "");
 
@@ -1321,12 +1323,10 @@ struct f2fs_dentry_block {
 	__u8 reserved[SIZE_OF_RESERVED];
 	struct f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK];
 	__u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN];
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_dentry_block) == 4096, "");
 
-#pragma pack(pop)
-
 /* for inline stuff */
 #define DEF_INLINE_RESERVED_SIZE	1
 
diff --git a/include/quota.h b/include/quota.h
index 5b7aaa891d28..f0eff71a9a26 100644
--- a/include/quota.h
+++ b/include/quota.h
@@ -44,11 +44,10 @@ enum quota_type {
 
 #define QT_TREEOFF	1	/* Offset of tree in file in blocks */
 
-#pragma pack(push, 1)
 struct v2_disk_dqheader {
 	uint32_t dqh_magic;	/* Magic number identifying file */
 	uint32_t dqh_version;	/* File version */
-} __attribute__ ((packed));
+};
 
 static_assert(sizeof(struct v2_disk_dqheader) == 8, "");
 
@@ -60,7 +59,7 @@ struct v2_disk_dqinfo {
 	uint32_t dqi_blocks;	/* Number of blocks in file */
 	uint32_t dqi_free_blk;	/* Number of first free block in the list */
 	uint32_t dqi_free_entry;	/* Number of block with at least one free entry */
-} __attribute__ ((packed));
+};
 
 static_assert(sizeof(struct v2_disk_dqinfo) == 24, "");
 
@@ -77,10 +76,8 @@ struct v2r1_disk_dqblk {
 	__le64 dqb_curspace;    /* current space occupied (in bytes) */
 	__le64 dqb_btime;       /* time limit for excessive disk use */
 	__le64 dqb_itime;       /* time limit for excessive inode use */
-} __attribute__ ((packed));
+};
 
 static_assert(sizeof(struct v2r1_disk_dqblk) == 72, "");
 
-#pragma pack(pop)
-
 #endif
diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c
index 97624ba5e185..72bfb6467300 100644
--- a/tools/f2fscrypt.c
+++ b/tools/f2fscrypt.c
@@ -102,7 +102,7 @@ struct f2fs_fscrypt_policy {
 	__u8 filenames_encryption_mode;
 	__u8 flags;
 	__u8 master_key_descriptor[F2FS_KEY_DESCRIPTOR_SIZE];
-} __attribute__((packed));
+};
 
 static_assert(sizeof(struct f2fs_fscrypt_policy) == 12, "");
 
@@ -121,7 +121,7 @@ struct f2fs_encryption_key {
         __u32 mode;
         char raw[F2FS_MAX_KEY_SIZE];
         __u32 size;
-} __attribute__((__packed__));
+};
 
 static_assert(sizeof(struct f2fs_encryption_key) == 72, "");
 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 14/31] Move the be32_to_cpu() definition
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (12 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 13/31] Remove unnecessary __attribute__((packed)) annotations Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 15/31] Include <stddef.h> instead of defining offsetof() Bart Van Assche
                   ` (16 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Move the be32_to_cpu() definition next to the little endian conversion
functions. This patch improves portability since the MinGW ntohl()
function exists in another library than the C library.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/quotaio.h    | 2 --
 include/f2fs_fs.h | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fsck/quotaio.h b/fsck/quotaio.h
index 999e800f82c7..0024fe570727 100644
--- a/fsck/quotaio.h
+++ b/fsck/quotaio.h
@@ -197,8 +197,6 @@ struct quotafile_ops {
 #define __force
 #endif
 
-#define be32_to_cpu(n) ntohl(n)
-
 /* Open existing quotafile of given type (and verify its format) on given
  * filesystem. */
 errcode_t quota_file_open(struct f2fs_sb_info *sbi, struct quota_handle *h,
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 49438eb2e6f2..60b6dfced74b 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -194,6 +194,7 @@ static inline uint64_t bswap_64(uint64_t val)
 #define cpu_to_le16(x)	((uint16_t)(x))
 #define cpu_to_le32(x)	((uint32_t)(x))
 #define cpu_to_le64(x)	((uint64_t)(x))
+#define be32_to_cpu(x)	__builtin_bswap64(x)
 #elif __BYTE_ORDER == __BIG_ENDIAN
 #define le16_to_cpu(x)	bswap_16(x)
 #define le32_to_cpu(x)	bswap_32(x)
@@ -201,6 +202,7 @@ static inline uint64_t bswap_64(uint64_t val)
 #define cpu_to_le16(x)	bswap_16(x)
 #define cpu_to_le32(x)	bswap_32(x)
 #define cpu_to_le64(x)	bswap_64(x)
+#define be32_to_cpu(x)	((uint64_t)(x))
 #endif
 
 #define typecheck(type,x) \


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 15/31] Include <stddef.h> instead of defining offsetof()
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (13 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 14/31] Move the be32_to_cpu() definition Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 16/31] Use %zu to format size_t Bart Van Assche
                   ` (15 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Prepare for enabling -Wmacro-redefined.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/f2fs.h       | 2 +-
 include/f2fs_fs.h | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/fsck/f2fs.h b/fsck/f2fs.h
index eacfd42478b8..e5130ba19961 100644
--- a/fsck/f2fs.h
+++ b/fsck/f2fs.h
@@ -15,6 +15,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <string.h>
@@ -37,7 +38,6 @@
 		typecheck(unsigned long long, b) &&                     \
 		((long long)((a) - (b)) > 0))
 
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #define container_of(ptr, type, member) ({			\
 	const typeof(((type *)0)->member) * __mptr = (ptr);	\
 	(type *)((char *)__mptr - offsetof(type, member)); })
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 60b6dfced74b..dd62bc89a926 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -19,6 +19,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <string.h>
 #include <time.h>
 #ifdef HAVE_CONFIG_H
@@ -914,10 +915,6 @@ static_assert(sizeof(struct f2fs_extent) == 12, "");
 #define F2FS_PIN_FILE		0x40	/* file should not be gced */
 #define F2FS_COMPRESS_RELEASED	0x80	/* file released compressed blocks */
 
-#if !defined(offsetof)
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
 #define F2FS_EXTRA_ISIZE_OFFSET				\
 	offsetof(struct f2fs_inode, i_extra_isize)
 #define F2FS_TOTAL_EXTRA_ATTR_SIZE			\


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 16/31] Use %zu to format size_t
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (14 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 15/31] Include <stddef.h> instead of defining offsetof() Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 17/31] Fix the MinGW build Bart Van Assche
                   ` (14 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Use %zu to format size_t as required by the POSIX standards.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/mount.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index e075d3184f83..584385d682b5 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1429,7 +1429,7 @@ static int f2fs_early_init_nid_bitmap(struct f2fs_sb_info *sbi)
 
 	if (nats_in_cursum(journal) > NAT_JOURNAL_ENTRIES) {
 		MSG(0, "\tError: f2fs_init_nid_bitmap truncate n_nats(%u) to "
-			"NAT_JOURNAL_ENTRIES(%lu)\n",
+			"NAT_JOURNAL_ENTRIES(%zu)\n",
 			nats_in_cursum(journal), NAT_JOURNAL_ENTRIES);
 		journal->n_nats = cpu_to_le16(NAT_JOURNAL_ENTRIES);
 		c.fix_on = 1;
@@ -2381,7 +2381,7 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
 
 	if (sits_in_cursum(journal) > SIT_JOURNAL_ENTRIES) {
 		MSG(0, "\tError: build_sit_entries truncate n_sits(%u) to "
-			"SIT_JOURNAL_ENTRIES(%lu)\n",
+			"SIT_JOURNAL_ENTRIES(%zu)\n",
 			sits_in_cursum(journal), SIT_JOURNAL_ENTRIES);
 		journal->n_sits = cpu_to_le16(SIT_JOURNAL_ENTRIES);
 		c.fix_on = 1;


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 17/31] Fix the MinGW build
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (15 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 16/31] Use %zu to format size_t Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 18/31] configure.ac: Detect the sparse/sparse.h header Bart Van Assche
                   ` (13 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Fix multiple compiler warnings and build errors reported by the MinGW
cross-compiler.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 configure.ac            | 46 +++++++++++++++++++++++++++++++++++++++++
 fsck/Makefile.am        |  2 +-
 fsck/dir.c              |  8 +++++++
 fsck/f2fs.h             |  8 +++++++
 fsck/main.c             | 13 ++++++------
 fsck/mount.c            |  4 ++--
 fsck/quotaio.h          |  1 -
 fsck/sload.c            | 11 ++++++++++
 mkfs/f2fs_format.c      |  7 +++++++
 mkfs/f2fs_format_main.c |  4 +++-
 tools/Makefile.am       |  5 ++++-
 tools/f2fs_io/f2fs_io.c | 13 ++++++------
 tools/f2fscrypt.c       |  2 ++
 tools/fibmap.c          |  2 ++
 14 files changed, 108 insertions(+), 18 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4a3afa4853eb..06aaed9a57d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,12 @@ AC_CHECK_LIB([uuid], [uuid_clear],
 		[Define if you have libuuid])
 	], [], [])
 
+AC_CHECK_LIB([winpthread], [clock_gettime],
+	[AC_SUBST([libwinpthread_LIBS], ["-lwinpthread"])
+		AC_DEFINE([HAVE_LIBWINPTHREAD], [1],
+		[Define if you have libwinpthread])
+	], [], [])
+
 # Checks for header files.
 AC_CHECK_HEADERS(m4_flatten([
 	attr/xattr.h
@@ -100,6 +106,7 @@ AC_CHECK_HEADERS(m4_flatten([
 	linux/xattr.h
 	mach/mach_time.h
 	mntent.h
+	pthread_time.h
 	scsi/sg.h
 	selinux/selinux.h
 	stdlib.h
@@ -129,7 +136,9 @@ AC_CHECK_FUNCS_ONCE([
 	fsetxattr
 	fstat
 	fstat64
+	getgid
 	getmntent
+	getuid
 	keyctl
 	llseek
 	lseek64
@@ -140,6 +149,18 @@ AC_CHECK_FUNCS_ONCE([
 AS_IF([test "$ac_cv_header_byteswap_h" = "yes"],
       [AC_CHECK_DECLS([bswap_64],,,[#include <byteswap.h>])])
 
+AC_MSG_CHECKING([for CLOCK_BOOTIME])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
+#include <time.h>
+#ifdef HAVE_PTHREAD_TIME_H
+#include <pthread_time.h>
+#endif
+],[return CLOCK_BOOTTIME])],
+		  [AC_MSG_RESULT([yes])
+		  AC_DEFINE([HAVE_CLOCK_BOOTTIME], [1],
+		  [Define if CLOCK_BOOTTIME is available])],
+		  [AC_MSG_RESULT([no])])
+
 # AC_CANONICAL_HOST is needed to access the 'host_os' variable
 AC_CANONICAL_HOST
 
@@ -209,4 +230,29 @@ AC_SUBST(LIBF2FS_CURRENT, 8)
 AC_SUBST(LIBF2FS_REVISION, 0)
 AC_SUBST(LIBF2FS_AGE, 0)
 
+AH_BOTTOM([
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifndef HAVE_GETUID
+static inline unsigned int getuid(void) { return -1; }
+#endif
+#ifndef HAVE_GETGID
+static inline unsigned int getgid(void) { return -1; }
+#endif
+
+#ifndef S_ISLNK
+#define S_ISLNK(mode) false
+#endif
+#ifndef S_ISSOCK
+#define S_ISSOCK(mode) false
+#endif
+
+#endif
+])
+
 AC_OUTPUT
diff --git a/fsck/Makefile.am b/fsck/Makefile.am
index e31d4166e227..579dd26cd6c9 100644
--- a/fsck/Makefile.am
+++ b/fsck/Makefile.am
@@ -10,7 +10,7 @@ fsck_f2fs_SOURCES = main.c fsck.c dump.c mount.c defrag.c resize.c \
 		node.c segment.c dir.c sload.c xattr.c compress.c \
 		dict.c mkquota.c quotaio.c quotaio_tree.c quotaio_v2.c
 fsck_f2fs_LDADD = ${libselinux_LIBS} ${libuuid_LIBS} \
-	${liblzo2_LIBS} ${liblz4_LIBS} \
+	${liblzo2_LIBS} ${liblz4_LIBS} ${libwinpthread_LIBS} \
 	$(top_builddir)/lib/libf2fs.la
 
 install-data-hook:
diff --git a/fsck/dir.c b/fsck/dir.c
index f7491a778a30..4a3eb6ea7788 100644
--- a/fsck/dir.c
+++ b/fsck/dir.c
@@ -474,11 +474,19 @@ static void init_inode_block(struct f2fs_sb_info *sbi,
 		links++;
 		blocks++;
 	} else if (de->file_type == F2FS_FT_REG_FILE) {
+#ifdef S_IFREG
 		mode |= S_IFREG;
+#else
+		ASSERT(0);
+#endif
 		size = 0;
 	} else if (de->file_type == F2FS_FT_SYMLINK) {
 		ASSERT(de->link);
+#ifdef S_IFLNK
 		mode |= S_IFLNK;
+#else
+		ASSERT(0);
+#endif
 		size = strlen(de->link);
 		if (size + 1 > MAX_INLINE_DATA(node_blk))
 			blocks++;
diff --git a/fsck/f2fs.h b/fsck/f2fs.h
index e5130ba19961..875f953fb6cc 100644
--- a/fsck/f2fs.h
+++ b/fsck/f2fs.h
@@ -27,8 +27,12 @@
 #include <mach/mach_time.h>
 #endif
 #include <sys/stat.h>
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_MOUNT_H
 #include <sys/mount.h>
+#endif
 #include <assert.h>
 
 #include "f2fs_fs.h"
@@ -589,8 +593,12 @@ static unsigned char f2fs_type_by_mode[S_IFMT >> S_SHIFT] = {
 	[S_IFCHR >> S_SHIFT]    = F2FS_FT_CHRDEV,
 	[S_IFBLK >> S_SHIFT]    = F2FS_FT_BLKDEV,
 	[S_IFIFO >> S_SHIFT]    = F2FS_FT_FIFO,
+#ifdef S_IFSOCK
 	[S_IFSOCK >> S_SHIFT]   = F2FS_FT_SOCK,
+#endif
+#ifdef S_IFLNK
 	[S_IFLNK >> S_SHIFT]    = F2FS_FT_SYMLINK,
+#endif
 };
 
 static inline int map_de_type(umode_t mode)
diff --git a/fsck/main.c b/fsck/main.c
index e4cfdf443867..b555ff4dbee7 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -1065,16 +1065,12 @@ static int do_label(struct f2fs_sb_info *sbi)
 }
 #endif
 
-#if defined(__APPLE__)
+#ifdef HAVE_MACH_TIME_H
 static u64 get_boottime_ns()
 {
-#ifdef HAVE_MACH_TIME_H
 	return mach_absolute_time();
-#else
-	return 0;
-#endif
 }
-#else
+#elif defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CLOCK_BOOTTIME)
 static u64 get_boottime_ns()
 {
 	struct timespec t;
@@ -1082,6 +1078,11 @@ static u64 get_boottime_ns()
 	clock_gettime(CLOCK_BOOTTIME, &t);
 	return (u64)t.tv_sec * 1000000000LL + t.tv_nsec;
 }
+#else
+static u64 get_boottime_ns()
+{
+	return 0;
+}
 #endif
 
 int main(int argc, char **argv)
diff --git a/fsck/mount.c b/fsck/mount.c
index 584385d682b5..b1e318f099f0 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -31,6 +31,8 @@
 #define ACL_OTHER		(0x20)
 #endif
 
+#ifdef HAVE_LINUX_BLKZONED_H
+
 static int get_device_idx(struct f2fs_sb_info *sbi, uint32_t segno)
 {
 	block_t seg_start_blkaddr;
@@ -45,8 +47,6 @@ static int get_device_idx(struct f2fs_sb_info *sbi, uint32_t segno)
 	return 0;
 }
 
-#ifdef HAVE_LINUX_BLKZONED_H
-
 static int get_zone_idx_from_dev(struct f2fs_sb_info *sbi,
 					uint32_t segno, uint32_t dev_idx)
 {
diff --git a/fsck/quotaio.h b/fsck/quotaio.h
index 0024fe570727..fc40f98e8741 100644
--- a/fsck/quotaio.h
+++ b/fsck/quotaio.h
@@ -21,7 +21,6 @@
 #include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <arpa/inet.h>
 
 #include "dict.h"
 #include "f2fs_fs.h"
diff --git a/fsck/sload.c b/fsck/sload.c
index 692902344a55..475ea6dac5f6 100644
--- a/fsck/sload.c
+++ b/fsck/sload.c
@@ -28,6 +28,7 @@ typedef void (*fs_config_f)(const char *path, int dir,
 			    unsigned *uid, unsigned *gid,
 			    unsigned *mode, uint64_t *capabilities);
 
+#ifndef _WIN32
 static fs_config_f fs_config_func = NULL;
 
 #ifdef WITH_ANDROID
@@ -62,6 +63,7 @@ static int f2fs_make_directory(struct f2fs_sb_info *sbi,
 
 	return ret;
 }
+#endif
 
 #ifdef HAVE_LIBSELINUX
 static int set_selinux_xattr(struct f2fs_sb_info *sbi, const char *path,
@@ -99,6 +101,7 @@ static int set_selinux_xattr(struct f2fs_sb_info *sbi, const char *path,
 #define set_selinux_xattr(...)	0
 #endif
 
+#ifndef _WIN32
 static int set_perms_and_caps(struct dentry *de)
 {
 	uint64_t capabilities = 0;
@@ -291,6 +294,14 @@ out_free:
 	free(dentries);
 	return 0;
 }
+#else
+static int build_directory(struct f2fs_sb_info *sbi, const char *full_path,
+			const char *dir_path, const char *target_out_dir,
+			nid_t dir_ino)
+{
+	return -1;
+}
+#endif
 
 static int configure_files(void)
 {
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 332abf60d0d9..173f619585f3 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -18,7 +18,14 @@
 #include <sys/mount.h>
 #endif
 #include <time.h>
+
+#include "config.h"
+#ifdef HAVE_UUID_UUID_H
 #include <uuid/uuid.h>
+#else
+#define uuid_parse(a, b) -1
+#define uuid_generate(a)
+#endif
 
 #include "f2fs_fs.h"
 #include "quota.h"
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index ecc942b61d63..88b267492245 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -19,7 +19,6 @@
 #include <sys/mount.h>
 #endif
 #include <time.h>
-#include <uuid/uuid.h>
 #include <errno.h>
 #include <getopt.h>
 
@@ -27,6 +26,9 @@
 #ifdef HAVE_LIBBLKID
 #include <blkid/blkid.h>
 #endif
+#ifdef HAVE_UUID_UUID_H
+#include <uuid/uuid.h>
+#endif
 
 #include "f2fs_fs.h"
 #include "quota.h"
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 56bf2e4e8a99..8756a298fdcf 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -2,7 +2,10 @@
 
 AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include
 AM_CFLAGS = -Wall
-sbin_PROGRAMS = f2fstat fibmap.f2fs parse.f2fs
+sbin_PROGRAMS = f2fstat
+if !WINDOWS
+sbin_PROGRAMS += fibmap.f2fs parse.f2fs
+endif
 f2fstat_SOURCES = f2fstat.c
 fibmap_f2fs_SOURCES = fibmap.c
 parse_f2fs_SOURCES = f2fs_io_parse.c
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index af4a34b63471..e807177a4174 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -132,16 +132,12 @@ static void full_write(int fd, const void *buf, size_t count)
 	}
 }
 
-#if defined(__APPLE__)
+#ifdef HAVE_MACH_TIME_H
 static u64 get_current_us()
 {
-#ifdef HAVE_MACH_TIME_H
 	return mach_absolute_time() / 1000;
-#else
-	return 0;
-#endif
 }
-#else
+#elif defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CLOCK_BOOTTIME)
 static u64 get_current_us()
 {
 	struct timespec t;
@@ -149,6 +145,11 @@ static u64 get_current_us()
 	clock_gettime(CLOCK_BOOTTIME, &t);
 	return (u64)t.tv_sec * 1000000LL + t.tv_nsec / 1000;
 }
+#else
+static u64 get_current_us()
+{
+	return 0;
+}
 #endif
 
 #define fsync_desc "fsync"
diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c
index 72bfb6467300..0f0650f4dd63 100644
--- a/tools/f2fscrypt.c
+++ b/tools/f2fscrypt.c
@@ -43,7 +43,9 @@
 #ifdef __KERNEL__
 #include <linux/fs.h>
 #endif
+#ifdef HAVE_UUID_UUID_H
 #include <uuid/uuid.h>
+#endif
 
 #if !defined(HAVE_ADD_KEY) || !defined(HAVE_KEYCTL)
 #include <sys/syscall.h>
diff --git a/tools/fibmap.c b/tools/fibmap.c
index 9e96cb68cecc..3238f294e869 100644
--- a/tools/fibmap.c
+++ b/tools/fibmap.c
@@ -23,7 +23,9 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <sys/types.h>
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
+#endif
 #include <sys/stat.h>
 #ifdef HAVE_SYS_SYSMACROS_H
 #include <sys/sysmacros.h>


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 18/31] configure.ac: Detect the sparse/sparse.h header
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (16 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 17/31] Fix the MinGW build Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-22 19:01   ` Jaegeuk Kim
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 19/31] configure.ac: Detect selinux/android.h Bart Van Assche
                   ` (12 subsequent siblings)
  30 siblings, 1 reply; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

The <sparse/sparse.h> header is available in Android but not in the
Android NDK. Hence this patch that only includes the sparse header file
if it is available.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 configure.ac            |  1 +
 lib/libf2fs_io.c        | 10 +++++-----
 mkfs/f2fs_format_main.c |  2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 06aaed9a57d9..317030dad44f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,6 +109,7 @@ AC_CHECK_HEADERS(m4_flatten([
 	pthread_time.h
 	scsi/sg.h
 	selinux/selinux.h
+	sparse/sparse.h
 	stdlib.h
 	string.h
 	sys/acl.h
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index bf6dfe240bb7..287199314190 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -39,7 +39,7 @@
 
 struct f2fs_configuration c;
 
-#ifdef WITH_ANDROID
+#ifdef HAVE_SPARSE_SPARSE_H
 #include <sparse/sparse.h>
 struct sparse_file *f2fs_sparse_file;
 static char **blocks;
@@ -398,7 +398,7 @@ int dev_read_version(void *buf, __u64 offset, size_t len)
 	return 0;
 }
 
-#ifdef WITH_ANDROID
+#ifdef HAVE_SPARSE_SPARSE_H
 static int sparse_read_blk(__u64 block, int count, void *buf)
 {
 	int i;
@@ -649,7 +649,7 @@ int f2fs_fsync_device(void)
 
 int f2fs_init_sparse_file(void)
 {
-#ifdef WITH_ANDROID
+#ifdef HAVE_SPARSE_SPARSE_H
 	if (c.func == MKFS) {
 		f2fs_sparse_file = sparse_file_new(F2FS_BLKSIZE, c.device_size);
 		if (!f2fs_sparse_file)
@@ -691,7 +691,7 @@ int f2fs_init_sparse_file(void)
 
 void f2fs_release_sparse_resource(void)
 {
-#ifdef WITH_ANDROID
+#ifdef HAVE_SPARSE_SPARSE_H
 	int j;
 
 	if (c.sparse_mode) {
@@ -716,7 +716,7 @@ int f2fs_finalize_device(void)
 	int i;
 	int ret = 0;
 
-#ifdef WITH_ANDROID
+#ifdef HAVE_SPARSE_SPARSE_H
 	if (c.sparse_mode) {
 		int64_t chunk_start = (blocks[0] == NULL) ? -1 : 0;
 		uint64_t j;
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 88b267492245..4d4fad9ad86d 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -37,7 +37,7 @@
 #ifdef HAVE_SYS_UTSNAME_H
 #include <sys/utsname.h>
 #endif
-#ifdef WITH_ANDROID
+#ifdef HAVE_SPARSE_SPARSE_H
 #include <sparse/sparse.h>
 extern struct sparse_file *f2fs_sparse_file;
 #endif


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 19/31] configure.ac: Detect selinux/android.h
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (17 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 18/31] configure.ac: Detect the sparse/sparse.h header Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 20/31] mkfs/f2fs_format.c: Suppress a compiler warning Bart Van Assche
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

The selinux/android.h header file is available in Android but not in the
Android NDK. Hence this patch that detects presence of that header file
at configure time.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 configure.ac | 1 +
 fsck/sload.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 317030dad44f..fc094b72b583 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,6 +108,7 @@ AC_CHECK_HEADERS(m4_flatten([
 	mntent.h
 	pthread_time.h
 	scsi/sg.h
+	selinux/android.h
 	selinux/selinux.h
 	sparse/sparse.h
 	stdlib.h
diff --git a/fsck/sload.c b/fsck/sload.c
index 475ea6dac5f6..00c3403dace0 100644
--- a/fsck/sload.c
+++ b/fsck/sload.c
@@ -31,7 +31,7 @@ typedef void (*fs_config_f)(const char *path, int dir,
 #ifndef _WIN32
 static fs_config_f fs_config_func = NULL;
 
-#ifdef WITH_ANDROID
+#ifdef HAVE_SELINUX_ANDROID_H
 #include <selinux/android.h>
 #include <private/android_filesystem_config.h>
 #include <private/canned_fs_config.h>
@@ -324,7 +324,7 @@ static int configure_files(void)
 #endif
 skip:
 #endif
-#ifdef WITH_ANDROID
+#ifdef HAVE_SELINUX_ANDROID_H
 	/* Load the FS config */
 	if (c.fs_config_file) {
 		int ret = load_canned_fs_config(c.fs_config_file);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 20/31] mkfs/f2fs_format.c: Suppress a compiler warning
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (18 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 19/31] configure.ac: Detect selinux/android.h Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 21/31] fsck: Remove a superfluous include directive Bart Van Assche
                   ` (10 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Suppress the following compiler warning:

f2fs_format.c:1653:37: warning: adding 'int' to a string does not append to the
      string [-Wstring-plus-int]
                memcpy(dent_blk->filename[3], LPF + F2FS_SLOT_LEN,
                                              ~~~~^~~~~~~~~~~~~~~
f2fs_format.c:1653:37: note: use array indexing to silence this warning
                memcpy(dent_blk->filename[3], LPF + F2FS_SLOT_LEN,
                                                  ^
                                              &   [              ]

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 mkfs/f2fs_format.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 173f619585f3..6f2761cfdb75 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -1650,7 +1650,7 @@ static int f2fs_add_default_dentry_root(void)
 		dent_blk->dentry[2].file_type = F2FS_FT_DIR;
 		memcpy(dent_blk->filename[2], LPF, F2FS_SLOT_LEN);
 
-		memcpy(dent_blk->filename[3], LPF + F2FS_SLOT_LEN,
+		memcpy(dent_blk->filename[3], &LPF[F2FS_SLOT_LEN],
 				len - F2FS_SLOT_LEN);
 
 		test_and_set_bit_le(2, dent_blk->dentry_bitmap);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 21/31] fsck: Remove a superfluous include directive
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (19 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 20/31] mkfs/f2fs_format.c: Suppress a compiler warning Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 22/31] tools/f2fscrypt.c: Fix build without uuid/uuid.h header file Bart Van Assche
                   ` (9 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/main.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/fsck/main.c b/fsck/main.c
index b555ff4dbee7..fc776eb0af1f 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -32,11 +32,6 @@
 
 struct f2fs_fsck gfsck;
 
-#ifdef WITH_ANDROID
-#include <sparse/sparse.h>
-extern struct sparse_file *f2fs_sparse_file;
-#endif
-
 INIT_FEATURE_TABLE;
 
 static char *absolute_path(const char *file)


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 22/31] tools/f2fscrypt.c: Fix build without uuid/uuid.h header file
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (20 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 21/31] fsck: Remove a superfluous include directive Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 23/31] fsck/main.c: Suppress a compiler warning Bart Van Assche
                   ` (8 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 tools/f2fscrypt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c
index 0f0650f4dd63..293173fcb5b4 100644
--- a/tools/f2fscrypt.c
+++ b/tools/f2fscrypt.c
@@ -45,6 +45,8 @@
 #endif
 #ifdef HAVE_UUID_UUID_H
 #include <uuid/uuid.h>
+#else
+typedef unsigned char uuid_t[16];
 #endif
 
 #if !defined(HAVE_ADD_KEY) || !defined(HAVE_KEYCTL)
@@ -354,11 +356,13 @@ static void parse_salt(char *salt_str, int flags)
 			perror("F2FS_IOC_GET_ENCRYPTION_PWSALT");
 			exit(1);
 		}
+#ifdef HAVE_UUID_UUID_H
 		if (options & OPT_VERBOSE) {
 			char tmp[80];
 			uuid_unparse(buf, tmp);
 			printf("%s has pw salt %s\n", cp, tmp);
 		}
+#endif
 		salt_len = 16;
 	} else if (strncmp(cp, "f:", 2) == 0) {
 		cp += 2;
@@ -380,8 +384,10 @@ static void parse_salt(char *salt_str, int flags)
 				(((unsigned char)(h - hexchars) << 4) +
 				 (unsigned char)(l - hexchars));
 		}
+#ifdef HAVE_UUID_UUID_H
 	} else if (uuid_parse(cp, buf) == 0) {
 		salt_len = 16;
+#endif
 	} else {
 	invalid_salt:
 		fprintf(stderr, "Invalid salt: %s\n", salt_str);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 23/31] fsck/main.c: Suppress a compiler warning
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (21 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 22/31] tools/f2fscrypt.c: Fix build without uuid/uuid.h header file Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 24/31] Change #ifdef _WIN32 checks into #ifdef HAVE_.* Bart Van Assche
                   ` (7 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Suppress the following compiler warning:

main.c:37:14: warning: unused function 'absolute_path' [-Wunused-function]
static char *absolute_path(const char *file)
             ^

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fsck/main.c b/fsck/main.c
index fc776eb0af1f..8676f17555c5 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -34,6 +34,7 @@ struct f2fs_fsck gfsck;
 
 INIT_FEATURE_TABLE;
 
+#ifdef WITH_SLOAD
 static char *absolute_path(const char *file)
 {
 	char *ret;
@@ -51,6 +52,7 @@ static char *absolute_path(const char *file)
 		ret = strdup(file);
 	return ret;
 }
+#endif
 
 void fsck_usage()
 {


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 24/31] Change #ifdef _WIN32 checks into #ifdef HAVE_.*
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (22 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 23/31] fsck/main.c: Suppress a compiler warning Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 25/31] fsck/segment.c: Remove dead code Bart Van Assche
                   ` (6 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

It is recommended to test a HAVE_* macro instead of directly testing the
host type in source code. Hence this patch.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 configure.ac             |  2 ++
 lib/libf2fs.c            |  4 +++-
 lib/libf2fs_io.c         | 10 +++++++---
 lib/libf2fs_zoned.c      |  2 +-
 mkfs/f2fs_format.c       |  4 +++-
 mkfs/f2fs_format_main.c  |  2 +-
 mkfs/f2fs_format_utils.c |  7 +++++--
 7 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index fc094b72b583..f0ed5f6528d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,6 +116,7 @@ AC_CHECK_HEADERS(m4_flatten([
 	sys/acl.h
 	sys/ioctl.h
 	sys/mount.h
+	sys/stat.h
 	sys/syscall.h
 	sys/sysmacros.h
 	sys/utsname.h
@@ -138,6 +139,7 @@ AC_CHECK_FUNCS_ONCE([
 	fsetxattr
 	fstat
 	fstat64
+	fsync
 	getgid
 	getmntent
 	getuid
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index c7102528f2f4..aa4e854acc9d 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -22,8 +22,10 @@
 #endif
 #include <time.h>
 #include <sys/stat.h>
-#ifndef _WIN32
+#ifdef HAVE_SYS_MOUNT_H
 #include <sys/mount.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
 #ifdef HAVE_SYS_SYSMACROS_H
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index 287199314190..09a689293356 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -23,9 +23,13 @@
 #include <mntent.h>
 #endif
 #include <time.h>
-#ifndef _WIN32
+#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_MOUNT_H
 #include <sys/mount.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
 #ifdef HAVE_LINUX_HDREG_H
@@ -634,7 +638,7 @@ int dev_reada_block(__u64 blk_addr)
 
 int f2fs_fsync_device(void)
 {
-#ifndef _WIN32
+#ifdef HAVE_FSYNC
 	int i;
 
 	for (i = 0; i < c.ndevs; i++) {
@@ -783,7 +787,7 @@ int f2fs_finalize_device(void)
 	 * in the block device page cache.
 	 */
 	for (i = 0; i < c.ndevs; i++) {
-#ifndef _WIN32
+#ifdef HAVE_FSYNC
 		ret = fsync(c.devices[i].fd);
 		if (ret < 0) {
 			MSG(0, "\tError: Could not conduct fsync!!!\n");
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index cb954feabe61..fdde3f70a606 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -22,7 +22,7 @@
 #ifdef HAVE_LINUX_LIMITS_H
 #include <linux/limits.h>
 #endif
-#ifndef _WIN32
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
 #include <libgen.h>
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 6f2761cfdb75..ce7d1c9e40bd 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -13,8 +13,10 @@
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
-#ifndef _WIN32
+#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_MOUNT_H
 #include <sys/mount.h>
 #endif
 #include <time.h>
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 4d4fad9ad86d..b8936f15e0f2 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -15,7 +15,7 @@
 #include <stdbool.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#ifndef _WIN32
+#ifdef HAVE_SYS_MOUNT_H
 #include <sys/mount.h>
 #endif
 #include <time.h>
diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c
index 53101d1bd790..e3c58936e968 100644
--- a/mkfs/f2fs_format_utils.c
+++ b/mkfs/f2fs_format_utils.c
@@ -26,7 +26,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdbool.h>
-#ifndef _WIN32
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
 #include <sys/stat.h>
@@ -39,16 +39,19 @@
 #include <linux/falloc.h>
 #endif
 
+#ifdef __linux__
 #ifndef BLKDISCARD
 #define BLKDISCARD	_IO(0x12,119)
 #endif
 #ifndef BLKSECDISCARD
 #define BLKSECDISCARD	_IO(0x12,125)
 #endif
+#endif
 
 static int trim_device(int i)
 {
-#ifndef _WIN32
+#if defined(FALLOC_FL_PUNCH_HOLE) || defined(BLKDISCARD) || \
+	defined(BLKSECDISCARD)
 	unsigned long long range[2];
 	struct stat *stat_buf;
 	struct device_info *dev = c.devices + i;


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 25/31] fsck/segment.c: Remove dead code
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (23 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 24/31] Change #ifdef _WIN32 checks into #ifdef HAVE_.* Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 26/31] tools/f2fs_io: Fix the type of 'ret' Bart Van Assche
                   ` (5 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Since 'remained_blkentries' is unsigned, the assert statement that
verifies whether that variable is positive will never fail. Hence
remove that assert statement.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/segment.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fsck/segment.c b/fsck/segment.c
index 254a0d1425e9..401cbb69e0d7 100644
--- a/fsck/segment.c
+++ b/fsck/segment.c
@@ -537,7 +537,6 @@ static void update_largest_extent(struct f2fs_sb_info *sbi, nid_t ino)
 		cur_blk += count;
 		dn.ofs_in_node += count;
 		remained_blkentries -= count;
-		ASSERT(remained_blkentries >= 0);
 	}
 
 exit:


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 26/31] tools/f2fs_io: Fix the type of 'ret'
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (24 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 25/31] fsck/segment.c: Remove dead code Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 27/31] Annotate switch/case fallthrough Bart Van Assche
                   ` (4 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Make it possible to check whether the return value of ioctl() is negative.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 tools/f2fs_io/f2fs_io.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index e807177a4174..6bb094cc7f25 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -513,7 +513,7 @@ static void do_erase(int argc, char **argv, const struct cmd_desc *cmd)
 
 static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
 {
-	u64 buf_size = 0, inc_num = 0, ret = 0, written = 0;
+	u64 buf_size = 0, inc_num = 0, written = 0;
 	u64 offset;
 	char *buf = NULL;
 	unsigned bs, count, i;
@@ -561,6 +561,8 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
 	fd = xopen(argv[6], O_CREAT | O_WRONLY | flags, 0755);
 
 	if (atomic_commit || atomic_abort) {
+		int ret;
+
 		if (argc == 8)
 			useconds = atoi(argv[7]) * 1000;
 
@@ -573,6 +575,8 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
 
 	total_time = get_current_us();
 	for (i = 0; i < count; i++) {
+		uint64_t ret;
+
 		if (!strcmp(argv[4], "inc_num"))
 			*(int *)buf = inc_num++;
 		else if (!strcmp(argv[4], "rand"))
@@ -593,12 +597,16 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
 		usleep(useconds);
 
 	if (atomic_commit) {
+		int ret;
+
 		ret = ioctl(fd, F2FS_IOC_COMMIT_ATOMIC_WRITE);
 		if (ret < 0) {
 			fputs("committing atomic write failed\n", stderr);
 			exit(1);
 		}
 	} else if (atomic_abort) {
+		int ret;
+
 		ret = ioctl(fd, F2FS_IOC_ABORT_VOLATILE_WRITE);
 		if (ret < 0) {
 			fputs("aborting atomic write failed\n", stderr);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 27/31] Annotate switch/case fallthrough
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (25 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 26/31] tools/f2fs_io: Fix the type of 'ret' Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 28/31] Suppress a compiler warning about integer truncation Bart Van Assche
                   ` (3 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Just like in the Linux kernel source code, annotate switch/case
fallthrough.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fsck/fsck.c       | 1 +
 fsck/main.c       | 1 +
 include/f2fs_fs.h | 6 ++++++
 tools/f2fscrypt.c | 1 +
 4 files changed, 9 insertions(+)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 798779cfaf8a..19a28b0eedad 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1669,6 +1669,7 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, int casefolded,
 				switch (ret) {
 				case 1:
 					fixed = 1;
+					fallthrough;
 				case 0:
 					child->dots++;
 					break;
diff --git a/fsck/main.c b/fsck/main.c
index 8676f17555c5..aef797e98405 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -370,6 +370,7 @@ void f2fs_parse_options(int argc, char *argv[])
 				exit(0);
 			case '?':
 				option = optopt;
+				fallthrough;
 			default:
 				err = EUNKNOWN_OPT;
 				break;
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index dd62bc89a926..73dc48e25ec0 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -73,6 +73,12 @@
 #define static_assert _Static_assert
 #endif
 
+#ifdef __clang__
+#define fallthrough do {} while (0) /* fall through */
+#else
+#define fallthrough __attribute__((__fallthrough__))
+#endif
+
 #ifdef ANDROID_WINDOWS_HOST
 #undef HAVE_LINUX_TYPES_H
 #endif
diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c
index 293173fcb5b4..f2fbf0bf3878 100644
--- a/tools/f2fscrypt.c
+++ b/tools/f2fscrypt.c
@@ -726,6 +726,7 @@ static void do_add_key(int argc, char **argv, const struct cmd_desc *cmd)
 			break;
 		default:
 			fprintf(stderr, "Unrecognized option: %c\n", opt);
+			fallthrough;
 		case '?':
 			fputs("USAGE:\n  ", stderr);
 			fputs(cmd->cmd_help, stderr);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 28/31] Suppress a compiler warning about integer truncation
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (26 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 27/31] Annotate switch/case fallthrough Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 29/31] Support cross-compiliation for PowerPC Bart Van Assche
                   ` (2 subsequent siblings)
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

This patch prevents that older compilers report the following warning:

f2fs_format.c: In function ‘f2fs_prepare_super_block’:
../include/f2fs_fs.h:350:26: error: conversion from ‘unsigned int’ to ‘__uint16_t’ {aka ‘short unsigned int’} changes value from ‘4076150800’ to ‘8208’ [-Werror=overflow]
  350 | #define F2FS_SUPER_MAGIC 0xF2F52010 /* F2FS Magic Number */
      |                          ^~~~~~~~~~
 ../include/f2fs_fs.h:574:49: note: in expansion of macro ‘cpu_to_le16’
  574 | #define set_sb_le16(member, val)  (sb->member = cpu_to_le16(val))
      |                                                 ^~~~~~~~~~~

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/f2fs_fs.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 73dc48e25ec0..bc57dd07819a 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -579,14 +579,14 @@ struct f2fs_configuration {
 #define get_newsb_le32(member)			le32_to_cpu(new_sb->member)
 #define get_newsb_le16(member)			le16_to_cpu(new_sb->member)
 
-#define set_sb(member, val)	\
+#define set_sb(member, val)						\
 			do {						\
-				typeof(sb->member) t;			\
+				typeof(sb->member) t = (val);		\
 				switch (sizeof(t)) {			\
-				case 8: set_sb_le64(member, val); break; \
-				case 4: set_sb_le32(member, val); break; \
-				case 2: set_sb_le16(member, val); break; \
-				} \
+				case 8: set_sb_le64(member, t); break;	\
+				case 4: set_sb_le32(member, t); break;	\
+				case 2: set_sb_le16(member, t); break;	\
+				}					\
 			} while(0)
 
 #define get_sb(member)		\
@@ -617,14 +617,14 @@ struct f2fs_configuration {
 #define get_cp_le32(member)			le32_to_cpu(cp->member)
 #define get_cp_le16(member)			le16_to_cpu(cp->member)
 
-#define set_cp(member, val)	\
+#define set_cp(member, val)						\
 			do {						\
-				typeof(cp->member) t;			\
+				typeof(cp->member) t = (val);		\
 				switch (sizeof(t)) {			\
-				case 8: set_cp_le64(member, val); break; \
-				case 4: set_cp_le32(member, val); break; \
-				case 2: set_cp_le16(member, val); break; \
-				} \
+				case 8: set_cp_le64(member, t); break;	\
+				case 4: set_cp_le32(member, t); break;	\
+				case 2: set_cp_le16(member, t); break;	\
+				}					\
 			} while(0)
 
 #define get_cp(member)		\


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 29/31] Support cross-compiliation for PowerPC
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (27 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 28/31] Suppress a compiler warning about integer truncation Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 30/31] Fix PowerPC format string warnings Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 31/31] ci: Enable -Wall, -Wextra and -Werror Bart Van Assche
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Some PowerPC cross-compilers have the uuid.h header file but not the
uuid library. Hence this patch that causes f2fs-tools only to use the
uuid functions if both the uuid header file and library are available.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 mkfs/f2fs_format.c | 2 +-
 tools/f2fscrypt.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index ce7d1c9e40bd..60a6b15af8ec 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -22,7 +22,7 @@
 #include <time.h>
 
 #include "config.h"
-#ifdef HAVE_UUID_UUID_H
+#if defined(HAVE_UUID_UUID_H) && defined(HAVE_LIBUUID)
 #include <uuid/uuid.h>
 #else
 #define uuid_parse(a, b) -1
diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c
index f2fbf0bf3878..37c791e52e7f 100644
--- a/tools/f2fscrypt.c
+++ b/tools/f2fscrypt.c
@@ -356,7 +356,7 @@ static void parse_salt(char *salt_str, int flags)
 			perror("F2FS_IOC_GET_ENCRYPTION_PWSALT");
 			exit(1);
 		}
-#ifdef HAVE_UUID_UUID_H
+#if defined(HAVE_UUID_UUID_H) && defined(HAVE_LIBUUID)
 		if (options & OPT_VERBOSE) {
 			char tmp[80];
 			uuid_unparse(buf, tmp);
@@ -384,7 +384,7 @@ static void parse_salt(char *salt_str, int flags)
 				(((unsigned char)(h - hexchars) << 4) +
 				 (unsigned char)(l - hexchars));
 		}
-#ifdef HAVE_UUID_UUID_H
+#if defined(HAVE_UUID_UUID_H) && defined(HAVE_LIBUUID)
 	} else if (uuid_parse(cp, buf) == 0) {
 		salt_len = 16;
 #endif


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 30/31] Fix PowerPC format string warnings
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (28 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 29/31] Support cross-compiliation for PowerPC Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 31/31] ci: Enable -Wall, -Wextra and -Werror Bart Van Assche
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

__SANE_USERSPACE_TYPES__ must be defined before <linux/types.h> is
included. Hence this patch that moves the definition of that macro into
the source files that need it.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/f2fs_fs.h       | 7 ++++---
 tools/f2fs_io/f2fs_io.c | 3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index bc57dd07819a..eedb38a6da1c 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -17,6 +17,10 @@
 #ifndef __F2FS_FS_H__
 #define __F2FS_FS_H__
 
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__       /* For PPC64, to get LL64 types */
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
@@ -42,9 +46,6 @@
 
 #include <inttypes.h>
 #ifdef HAVE_LINUX_TYPES_H
-#ifndef __SANE_USERSPACE_TYPES__
-#define __SANE_USERSPACE_TYPES__       /* For PPC64, to get LL64 types */
-#endif
 #include <linux/types.h>
 #endif
 #include <sys/types.h>
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 6bb094cc7f25..0edac6fedf33 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -18,6 +18,9 @@
 #ifndef O_LARGEFILE
 #define O_LARGEFILE 0
 #endif
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__       /* For PPC64, to get LL64 types */
+#endif
 
 #include <errno.h>
 #include <fcntl.h>


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [f2fs-dev] [PATCH 31/31] ci: Enable -Wall, -Wextra and -Werror
  2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
                   ` (29 preceding siblings ...)
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 30/31] Fix PowerPC format string warnings Bart Van Assche
@ 2022-04-21 22:18 ` Bart Van Assche
  30 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-04-21 22:18 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel

Make the Github continuous integration checks more strict.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 .github/workflows/ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0c774f92fac8..428039db860d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -66,5 +66,5 @@ jobs:
           ./autogen.sh
           ./configure --host=${{matrix.host}} \
               CC=${{ matrix.host && format('{0}-{1}', matrix.host, matrix.cc) || matrix.cc }} \
-              CFLAGS="${{matrix.cflags}}"
+              CFLAGS="-Wall -Wextra -Werror -Wno-sign-compare -Wno-unused-function -Wno-unused-parameter ${{matrix.cflags}}"
           make -j$(nproc)


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [f2fs-dev] [PATCH 07/31] Change the ANDROID_WINDOWS_HOST macro into _WIN32
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 07/31] Change the ANDROID_WINDOWS_HOST macro into _WIN32 Bart Van Assche
@ 2022-04-22 17:53   ` Jaegeuk Kim
  0 siblings, 0 replies; 36+ messages in thread
From: Jaegeuk Kim @ 2022-04-22 17:53 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: linux-f2fs-devel

Fixed a missing resolution from [PATCH 06/31].

In include/f2fs_fs.h,

71 #ifdef ANDROID_WINDOWS_HOST
72 #undef HAVE_LINUX_TYPES_H
73 #endif

On 04/21, Bart Van Assche wrote:
> This makes it easier to build f2fs-tools for Windows.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  lib/libf2fs.c            | 10 +++++-----
>  lib/libf2fs_io.c         |  6 +++---
>  lib/libf2fs_zoned.c      |  2 +-
>  mkfs/f2fs_format.c       |  2 +-
>  mkfs/f2fs_format_main.c  |  2 +-
>  mkfs/f2fs_format_utils.c |  4 ++--
>  6 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index b0a892772de1..c7102528f2f4 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -22,7 +22,7 @@
>  #endif
>  #include <time.h>
>  #include <sys/stat.h>
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  #include <sys/mount.h>
>  #include <sys/ioctl.h>
>  #endif
> @@ -49,7 +49,7 @@
>  #define MODELINQUIRY	0x12,0x00,0x00,0x00,0x4A,0x00
>  #endif
>  
> -#ifndef ANDROID_WINDOWS_HOST /* O_BINARY is windows-specific flag */
> +#ifndef _WIN32 /* O_BINARY is windows-specific flag */
>  #define O_BINARY 0
>  #else
>  /* On Windows, wchar_t is 8 bit sized and it causes compilation errors. */
> @@ -606,7 +606,7 @@ int write_inode(struct f2fs_node *inode, u64 blkaddr)
>   */
>  char *get_rootdev()
>  {
> -#if defined(ANDROID_WINDOWS_HOST) || defined(WITH_ANDROID)
> +#if defined(_WIN32) || defined(WITH_ANDROID)
>  	return NULL;
>  #else
>  	struct stat sb;
> @@ -740,7 +740,7 @@ static int is_mounted(const char *mpt, const char *device)
>  
>  int f2fs_dev_is_umounted(char *path)
>  {
> -#ifdef ANDROID_WINDOWS_HOST
> +#ifdef _WIN32
>  	return 0;
>  #else
>  	struct stat *st_buf;
> @@ -872,7 +872,7 @@ void get_kernel_uname_version(__u8 *version)
>  #define BLKSSZGET	DKIOCGETBLOCKCOUNT
>  #endif /* APPLE_DARWIN */
>  
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  static int open_check_fs(char *path, int flag)
>  {
>  	if (c.func != DUMP && (c.func != FSCK || c.fix_on || c.auto_fix))
> diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
> index b985e6f37a0a..bf6dfe240bb7 100644
> --- a/lib/libf2fs_io.c
> +++ b/lib/libf2fs_io.c
> @@ -23,7 +23,7 @@
>  #include <mntent.h>
>  #endif
>  #include <time.h>
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  #include <sys/stat.h>
>  #include <sys/mount.h>
>  #include <sys/ioctl.h>
> @@ -634,7 +634,7 @@ int dev_reada_block(__u64 blk_addr)
>  
>  int f2fs_fsync_device(void)
>  {
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  	int i;
>  
>  	for (i = 0; i < c.ndevs; i++) {
> @@ -783,7 +783,7 @@ int f2fs_finalize_device(void)
>  	 * in the block device page cache.
>  	 */
>  	for (i = 0; i < c.ndevs; i++) {
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  		ret = fsync(c.devices[i].fd);
>  		if (ret < 0) {
>  			MSG(0, "\tError: Could not conduct fsync!!!\n");
> diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
> index c408a4991fa1..cb954feabe61 100644
> --- a/lib/libf2fs_zoned.c
> +++ b/lib/libf2fs_zoned.c
> @@ -22,7 +22,7 @@
>  #ifdef HAVE_LINUX_LIMITS_H
>  #include <linux/limits.h>
>  #endif
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  #include <sys/ioctl.h>
>  #endif
>  #include <libgen.h>
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index 8bd33ac003c5..332abf60d0d9 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -13,7 +13,7 @@
>  #include <fcntl.h>
>  #include <string.h>
>  #include <unistd.h>
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  #include <sys/stat.h>
>  #include <sys/mount.h>
>  #endif
> diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
> index d05d4e2cb4e5..ecc942b61d63 100644
> --- a/mkfs/f2fs_format_main.c
> +++ b/mkfs/f2fs_format_main.c
> @@ -15,7 +15,7 @@
>  #include <stdbool.h>
>  #include <unistd.h>
>  #include <sys/stat.h>
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  #include <sys/mount.h>
>  #endif
>  #include <time.h>
> diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c
> index e84311ae1287..53101d1bd790 100644
> --- a/mkfs/f2fs_format_utils.c
> +++ b/mkfs/f2fs_format_utils.c
> @@ -26,7 +26,7 @@
>  #include <unistd.h>
>  #include <stdlib.h>
>  #include <stdbool.h>
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  #include <sys/ioctl.h>
>  #endif
>  #include <sys/stat.h>
> @@ -48,7 +48,7 @@
>  
>  static int trim_device(int i)
>  {
> -#ifndef ANDROID_WINDOWS_HOST
> +#ifndef _WIN32
>  	unsigned long long range[2];
>  	struct stat *stat_buf;
>  	struct device_info *dev = c.devices + i;


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [f2fs-dev] [PATCH 18/31] configure.ac: Detect the sparse/sparse.h header
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 18/31] configure.ac: Detect the sparse/sparse.h header Bart Van Assche
@ 2022-04-22 19:01   ` Jaegeuk Kim
  0 siblings, 0 replies; 36+ messages in thread
From: Jaegeuk Kim @ 2022-04-22 19:01 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: linux-f2fs-devel

On 04/21, Bart Van Assche wrote:
> The <sparse/sparse.h> header is available in Android but not in the
> Android NDK. Hence this patch that only includes the sparse header file
> if it is available.

Need this in android_config.h

+#define HAVE_SPARSE_SPARSE_H 1

> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  configure.ac            |  1 +
>  lib/libf2fs_io.c        | 10 +++++-----
>  mkfs/f2fs_format_main.c |  2 +-
>  3 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 06aaed9a57d9..317030dad44f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -109,6 +109,7 @@ AC_CHECK_HEADERS(m4_flatten([
>  	pthread_time.h
>  	scsi/sg.h
>  	selinux/selinux.h
> +	sparse/sparse.h
>  	stdlib.h
>  	string.h
>  	sys/acl.h
> diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
> index bf6dfe240bb7..287199314190 100644
> --- a/lib/libf2fs_io.c
> +++ b/lib/libf2fs_io.c
> @@ -39,7 +39,7 @@
>  
>  struct f2fs_configuration c;
>  
> -#ifdef WITH_ANDROID
> +#ifdef HAVE_SPARSE_SPARSE_H
>  #include <sparse/sparse.h>
>  struct sparse_file *f2fs_sparse_file;
>  static char **blocks;
> @@ -398,7 +398,7 @@ int dev_read_version(void *buf, __u64 offset, size_t len)
>  	return 0;
>  }
>  
> -#ifdef WITH_ANDROID
> +#ifdef HAVE_SPARSE_SPARSE_H
>  static int sparse_read_blk(__u64 block, int count, void *buf)
>  {
>  	int i;
> @@ -649,7 +649,7 @@ int f2fs_fsync_device(void)
>  
>  int f2fs_init_sparse_file(void)
>  {
> -#ifdef WITH_ANDROID
> +#ifdef HAVE_SPARSE_SPARSE_H
>  	if (c.func == MKFS) {
>  		f2fs_sparse_file = sparse_file_new(F2FS_BLKSIZE, c.device_size);
>  		if (!f2fs_sparse_file)
> @@ -691,7 +691,7 @@ int f2fs_init_sparse_file(void)
>  
>  void f2fs_release_sparse_resource(void)
>  {
> -#ifdef WITH_ANDROID
> +#ifdef HAVE_SPARSE_SPARSE_H
>  	int j;
>  
>  	if (c.sparse_mode) {
> @@ -716,7 +716,7 @@ int f2fs_finalize_device(void)
>  	int i;
>  	int ret = 0;
>  
> -#ifdef WITH_ANDROID
> +#ifdef HAVE_SPARSE_SPARSE_H
>  	if (c.sparse_mode) {
>  		int64_t chunk_start = (blocks[0] == NULL) ? -1 : 0;
>  		uint64_t j;
> diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
> index 88b267492245..4d4fad9ad86d 100644
> --- a/mkfs/f2fs_format_main.c
> +++ b/mkfs/f2fs_format_main.c
> @@ -37,7 +37,7 @@
>  #ifdef HAVE_SYS_UTSNAME_H
>  #include <sys/utsname.h>
>  #endif
> -#ifdef WITH_ANDROID
> +#ifdef HAVE_SPARSE_SPARSE_H
>  #include <sparse/sparse.h>
>  extern struct sparse_file *f2fs_sparse_file;
>  #endif


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [f2fs-dev] [PATCH 10/31] Verify structure sizes at compile time
  2022-04-21 22:18 ` [f2fs-dev] [PATCH 10/31] Verify structure sizes at compile time Bart Van Assche
@ 2022-06-10  2:05   ` Peter Collingbourne via Linux-f2fs-devel
  2022-06-10 17:12     ` Bart Van Assche
  0 siblings, 1 reply; 36+ messages in thread
From: Peter Collingbourne via Linux-f2fs-devel @ 2022-06-10  2:05 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jaegeuk Kim, linux-f2fs-devel

Hi Bart,

On Thu, Apr 21, 2022 at 03:18:15PM -0700, Bart Van Assche wrote:
> +static_assert(sizeof(struct f2fs_dentry_block) == 4096, "");

I noticed that this static_assert fails when PAGE_SIZE is defined to
a value other than 4096.

I have to admit to being unfamiliar with f2fs. Is this an on-disk
data structure? If so, does it mean that non-4K page size kernels
are unable to mount f2fs file systems if the f2fs-tools were not
built with a matching PAGE_SIZE define?

In any event, maybe s/4096/PAGE_SIZE/g above is the correct fix
for now?

Peter


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [f2fs-dev] [PATCH 10/31] Verify structure sizes at compile time
  2022-06-10  2:05   ` Peter Collingbourne via Linux-f2fs-devel
@ 2022-06-10 17:12     ` Bart Van Assche
  0 siblings, 0 replies; 36+ messages in thread
From: Bart Van Assche @ 2022-06-10 17:12 UTC (permalink / raw)
  To: Peter Collingbourne; +Cc: Jaegeuk Kim, linux-f2fs-devel

On 6/9/22 19:05, Peter Collingbourne wrote:
> On Thu, Apr 21, 2022 at 03:18:15PM -0700, Bart Van Assche wrote:
>> +static_assert(sizeof(struct f2fs_dentry_block) == 4096, "");
> 
> I noticed that this static_assert fails when PAGE_SIZE is defined to
> a value other than 4096.
> 
> I have to admit to being unfamiliar with f2fs. Is this an on-disk
> data structure? If so, does it mean that non-4K page size kernels
> are unable to mount f2fs file systems if the f2fs-tools were not
> built with a matching PAGE_SIZE define?
> 
> In any event, maybe s/4096/PAGE_SIZE/g above is the correct fix
> for now?

Hi Peter,

How this issue should be fixed depends on whether or not 
f2fs_dentry_block is an on-disk data structure. I'm not sure about the 
answer. Jaegeuk, can you help with answering this question?

Thanks,

Bart.


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2022-06-10 17:12 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-21 22:18 [f2fs-dev] [PATCH 00/31] Make f2fs-tools easier to maintain Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 01/31] configure.ac: Stop using obsolete macros Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 02/31] configure.ac: Remove two prototype tests Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 03/31] configure.ac: Enable the automake -Wall option Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 04/31] configure.ac: Sort header file names alphabetically Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 05/31] configure.ac: Enable cross-compilation Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 06/31] Switch from the u_int to the uint types Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 07/31] Change the ANDROID_WINDOWS_HOST macro into _WIN32 Bart Van Assche
2022-04-22 17:53   ` Jaegeuk Kim
2022-04-21 22:18 ` [f2fs-dev] [PATCH 08/31] ci: Build f2fstools upon push and pull requests Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 09/31] Change one array member into a flexible array member Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 10/31] Verify structure sizes at compile time Bart Van Assche
2022-06-10  2:05   ` Peter Collingbourne via Linux-f2fs-devel
2022-06-10 17:12     ` Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 11/31] Suppress a compiler warning Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 12/31] f2fs_fs.h: Use standard fixed width integer types Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 13/31] Remove unnecessary __attribute__((packed)) annotations Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 14/31] Move the be32_to_cpu() definition Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 15/31] Include <stddef.h> instead of defining offsetof() Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 16/31] Use %zu to format size_t Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 17/31] Fix the MinGW build Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 18/31] configure.ac: Detect the sparse/sparse.h header Bart Van Assche
2022-04-22 19:01   ` Jaegeuk Kim
2022-04-21 22:18 ` [f2fs-dev] [PATCH 19/31] configure.ac: Detect selinux/android.h Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 20/31] mkfs/f2fs_format.c: Suppress a compiler warning Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 21/31] fsck: Remove a superfluous include directive Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 22/31] tools/f2fscrypt.c: Fix build without uuid/uuid.h header file Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 23/31] fsck/main.c: Suppress a compiler warning Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 24/31] Change #ifdef _WIN32 checks into #ifdef HAVE_.* Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 25/31] fsck/segment.c: Remove dead code Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 26/31] tools/f2fs_io: Fix the type of 'ret' Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 27/31] Annotate switch/case fallthrough Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 28/31] Suppress a compiler warning about integer truncation Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 29/31] Support cross-compiliation for PowerPC Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 30/31] Fix PowerPC format string warnings Bart Van Assche
2022-04-21 22:18 ` [f2fs-dev] [PATCH 31/31] ci: Enable -Wall, -Wextra and -Werror Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).