summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2233e6a)
raw | patch | inline | side by side (parent: 2233e6a)
author | Vincent Bernat <vincent@bernat.im> | |
Thu, 13 Nov 2014 16:57:46 +0000 (17:57 +0100) | ||
committer | Vincent Bernat <vincent@bernat.im> | |
Thu, 13 Nov 2014 16:57:46 +0000 (17:57 +0100) |
In those versions, `sg_get_disk_io_stats()` need to be invoked a pointer
to size_t instead of pointer to int. Such a requirement is detected at
configure-time.
Fixes: #445
to size_t instead of pointer to int. Such a requirement is detected at
configure-time.
Fixes: #445
configure.ac | patch | blob | history | |
src/disk.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index f1873dee2427bea78ff037b62d20fee61ad5f829..734105001be542ff04070c42228abedb667f19aa 100644 (file)
--- a/configure.ac
+++ b/configure.ac
)
)
+ AC_CACHE_CHECK([if sg_disk_io_stats() uses size_t],
+ [c_cv_have_libstatgrab_get_disk_io_stats_sizet],
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <stdio.h>
+#include <statgrab.h>
+]]],
+[[[
+ sg_disk_io_stats *(*ptr) (size_t *);
+ ptr = sg_get_disk_io_stats;
+ if (ptr != NULL) return 0;
+]]]
+ )],
+ [c_cv_have_libstatgrab_get_disk_io_stats_sizet="yes"],
+ [c_cv_have_libstatgrab_get_disk_io_stats_sizet="no"]
+ )
+ )
+
CFLAGS="$SAVE_CFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
fi
then
AC_DEFINE(HAVE_LIBSTATGRAB_GET_USER_STATS_ARG, 1, [Define to 1 if sg_get_user_stats does require an argument])
fi
+ if test "x$c_cv_have_libstatgrab_get_disk_io_stats_sizet" = "xyes"
+ then
+ AC_DEFINE(HAVE_LIBSTATGRAB_GET_DISK_IO_STATS_SIZET, 1, [Define to 1 if sg_get_disk_io_stats does require pointer to size_t as an argument])
+ fi
fi
# }}}
diff --git a/src/disk.c b/src/disk.c
index e84e8355af2f802d3ce6a610ab76c45c264ad82b..51fbc025dde38c0f5eac02075f2aae010d0b3271 100644 (file)
--- a/src/disk.c
+++ b/src/disk.c
#elif defined(HAVE_LIBSTATGRAB)
sg_disk_io_stats *ds;
- int disks, counter;
+# if HAVE_LIBSTATGRAB_GET_DISK_IO_STATS_SIZET
+ size_t disks;
+# else
+ int disks;
+#endif
+ int counter;
char name[DATA_MAX_NAME_LEN];
if ((ds = sg_get_disk_io_stats(&disks)) == NULL)