]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
fstests: fix blksize_t printf format warnings across architectures
authorAnand Jain <anand.jain@oracle.com>
Wed, 20 Nov 2024 11:40:41 +0000 (19:40 +0800)
committerZorro Lang <zlang@kernel.org>
Thu, 28 Nov 2024 13:42:34 +0000 (21:42 +0800)
Fix format string warnings when printing blksize_t values that vary
across architectures. The warning occurs because blksize_t is defined
differently between architectures: aarch64 architectures blksize_t is
int, on x86-64 it's long-int.  Cast the values to long. Fixes warnings
as below.

 seek_sanity_test.c:110:45: warning: format '%ld' expects argument of type
 'long int', but argument 3 has type 'blksize_t' {aka 'int'}

 attr_replace_test.c:70:22: warning: format '%ld' expects argument of type
 'long int', but argument 3 has type '__blksize_t' {aka 'int'}

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/attr_replace_test.c
src/seek_sanity_test.c

index 1218e7264c8f91132364d21762867a19abc2089b..5d560a6333612370845317986a160947933039c8 100644 (file)
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
        if (ret < 0) die();
        size = sbuf.st_blksize * 3 / 4;
        if (!size)
-               fail("Invalid st_blksize(%ld)\n", sbuf.st_blksize);
+               fail("Invalid st_blksize(%ld)\n", (long)sbuf.st_blksize);
        size = MIN(size, maxsize);
        value = malloc(size);
        if (!value)
index a61ed3da9a8f56927d148fd52dfc6bf28c78df22..c5930357911f7e7a3c903df305fda7e15fb4b9b6 100644 (file)
@@ -107,7 +107,7 @@ static int get_io_sizes(int fd)
                offset += pos ? 0 : 1;
        alloc_size = offset;
 done:
-       fprintf(stdout, "Allocation size: %ld\n", alloc_size);
+       fprintf(stdout, "Allocation size: %ld\n", (long)alloc_size);
        return 0;
 
 fail: