[parted-devel] [PATCH 5/5] tests: Fix formatting and snprintf warnings in tests.

Brian C. Lane bcl at redhat.com
Wed Feb 15 19:57:11 GMT 2023


The assert message includes sector values, which are long long int, so
use the proper formatting of %lld.

The snprintf warning complained about trying to write 258 bytes so I
bumped the buffer size up to 259. The return value is already being
checked for truncation so this is just to keep the compiler happy
without having to suppress the warning.
---
 libparted/tests/disk.c    | 2 +-
 libparted/tests/symlink.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
index f7b16a5..a2e304c 100644
--- a/libparted/tests/disk.c
+++ b/libparted/tests/disk.c
@@ -75,7 +75,7 @@ START_TEST (test_duplicate)
                 ck_assert_msg(part->geom.start == part_dup->geom.start &&
                          part->geom.end == part_dup->geom.end,
                          "Duplicated partition %d doesn't match. "
-                         "Details are start: %d/%d end: %d/%d\n",
+                         "Details are start: %lld/%lld end: %lld/%lld\n",
                          *i, part->geom.start, part_dup->geom.start,
                          part->geom.end, part_dup->geom.end);
         }
diff --git a/libparted/tests/symlink.c b/libparted/tests/symlink.c
index da6bef8..7be02cd 100644
--- a/libparted/tests/symlink.c
+++ b/libparted/tests/symlink.c
@@ -61,7 +61,7 @@ START_TEST (test_symlink)
            here, but as /dev/mapper is root owned this is a non issue */
         close (tmp_fd);
         unlink (ln);
-        char temp_disk_path[256];
+        char temp_disk_path[259];
         int r = snprintf(temp_disk_path, sizeof temp_disk_path, "%s/%s",
                           cwd,
                           temporary_disk);
-- 
2.39.1




More information about the parted-devel mailing list