summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-03-12 16:27:10 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-03-12 16:27:10 +0000
commitd66dd2260c724bdfe57a8595aac37c8e9173cee5 (patch)
treeba15c128b3acede41361125aaa0c569bbbc870d3
parent17182af3a6de8e3e94e0a914416c54f09bb74007 (diff)
downloadlibguestfs-d66dd2260c724bdfe57a8595aac37c8e9173cee5.tar.gz
libguestfs-d66dd2260c724bdfe57a8595aac37c8e9173cee5.tar.xz
libguestfs-d66dd2260c724bdfe57a8595aac37c8e9173cee5.zip
Fix strict-overflow bugs and reenable this warning.
In two places, we were counting things in an array using an 'int'. In theory, the int could overflow, so gcc determines this to be undefined behaviour. The fix is to use size_t or ssize_t instead.
-rw-r--r--configure.ac5
-rw-r--r--format/format.c2
-rw-r--r--src/inspect_fs_unix.c6
3 files changed, 4 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index 55385759..e23e739c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,11 +135,6 @@ if test "$gl_gcc_warnings" = yes; then
# Missing field initializers is not a bug in C.
gl_WARN_ADD([-Wno-missing-field-initializers])
- # We think this is a bug in gcc:
- # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52560
- # Reenable this warning as soon as we have a resolution.
- gl_WARN_ADD([-Wno-strict-overflow])
-
# Display the name of the warning option with the warning.
gl_WARN_ADD([-fdiagnostics-show-option])
diff --git a/format/format.c b/format/format.c
index 0cf010ab..40e53c52 100644
--- a/format/format.c
+++ b/format/format.c
@@ -424,7 +424,7 @@ static int
do_rescan (char **devices)
{
size_t i;
- int errors = 0;
+ size_t errors = 0;
guestfs_error_handler_cb old_error_cb;
void *old_error_data;
diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c
index 74f014c6..e9c7d008 100644
--- a/src/inspect_fs_unix.c
+++ b/src/inspect_fs_unix.c
@@ -170,7 +170,7 @@ static size_t mdadm_app_hash(const void *x, size_t table_size);
static bool mdadm_app_cmp(const void *x, const void *y);
static void mdadm_app_free(void *x);
-static int map_app_md_devices (guestfs_h *g, Hash_table **map);
+static ssize_t map_app_md_devices (guestfs_h *g, Hash_table **map);
static int map_md_devices(guestfs_h *g, Hash_table **map);
/* Set fs->product_name to the first line of the release file. */
@@ -963,11 +963,11 @@ parse_uuid (const char *str, uint32_t *uuid)
}
/* Create a mapping of uuids to appliance md device names */
-static int
+static ssize_t
map_app_md_devices (guestfs_h *g, Hash_table **map)
{
char **mds = NULL;
- int n = 0;
+ ssize_t n = 0;
/* A hash mapping uuids to md device names */
*map = hash_initialize(16, NULL, uuid_hash, uuid_cmp, md_uuid_free);