From: Paul Eggert Date: Sat, 11 May 2019 20:09:39 +0000 (-0700) Subject: cp: port fiemap.h to C99 X-Git-Tag: v8.32~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f4c2e06ae2715a678e3d8856b2b26f4b883179a;p=thirdparty%2Fcoreutils.git cp: port fiemap.h to C99 * src/extent-scan.c (extent_scan_read): Adjust to change in struct fiemap. * src/fiemap.h (struct fiemap): Use FLEXIBLE_ARRAY_MEMBER to port to C99. --- diff --git a/src/extent-scan.c b/src/extent-scan.c index 2c9db4405a..ae0d3914b8 100644 --- a/src/extent-scan.c +++ b/src/extent-scan.c @@ -94,7 +94,8 @@ extent_scan_read (struct extent_scan *scan) union { struct fiemap f; char c[4096]; } fiemap_buf; struct fiemap *fiemap = &fiemap_buf.f; struct fiemap_extent *fm_extents = &fiemap->fm_extents[0]; - enum { count = (sizeof fiemap_buf - sizeof *fiemap)/sizeof *fm_extents }; + enum { headersize = offsetof (struct fiemap, fm_extents) }; + enum { count = (sizeof fiemap_buf - headersize) / sizeof *fm_extents }; verify (count > 1); /* This is required at least to initialize fiemap->fm_start, diff --git a/src/fiemap.h b/src/fiemap.h index 88a9fa6144..bf5337381d 100644 --- a/src/fiemap.h +++ b/src/fiemap.h @@ -51,13 +51,8 @@ struct fiemap uint32_t fm_reserved; - /* Array of mapped extents(out). - This is protected by the ifdef because it uses non standard - zero length arrays. Note C99 has the equivalent flexible arrays, - but we don't use those for maximum portability to older systems. */ -# ifdef __linux__ - struct fiemap_extent fm_extents[0]; -# endif + /* Array of mapped extents(out). */ + struct fiemap_extent fm_extents[FLEXIBLE_ARRAY_MEMBER]; }; /* The maximum offset can be mapped for a file. */