summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-05-22 04:59:46 +0100
committerSam James <sam@gentoo.org>2022-05-22 04:59:52 +0100
commitc7673fc5ae5788e7acb76f8e024b7bc27f37af4e (patch)
tree226a65866dcae8a2988955add7603783fe7c7646 /dev-util/scanmem
parentdev-util/scanmem: update EAPI 7 -> 8, Python 3.10 (diff)
downloadgentoo-c7673fc5ae5788e7acb76f8e024b7bc27f37af4e.tar.gz
gentoo-c7673fc5ae5788e7acb76f8e024b7bc27f37af4e.tar.bz2
gentoo-c7673fc5ae5788e7acb76f8e024b7bc27f37af4e.zip
dev-util/scanmem: fix musl tests
Closes: https://bugs.gentoo.org/713208 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'dev-util/scanmem')
-rw-r--r--dev-util/scanmem/files/scanmem-0.17-musl-tests.patch42
-rw-r--r--dev-util/scanmem/scanmem-0.17.ebuild4
2 files changed, 46 insertions, 0 deletions
diff --git a/dev-util/scanmem/files/scanmem-0.17-musl-tests.patch b/dev-util/scanmem/files/scanmem-0.17-musl-tests.patch
new file mode 100644
index 000000000000..5dcab6dfe54d
--- /dev/null
+++ b/dev-util/scanmem/files/scanmem-0.17-musl-tests.patch
@@ -0,0 +1,42 @@
+https://github.com/scanmem/scanmem/commit/81300d05d7d55bbf8e0f6200bb4c4309a320504f
+https://github.com/scanmem/scanmem/pull/396
+https://bugs.gentoo.org/713208
+
+From: Andrea Stacchiotti <andreastacchiotti@gmail.com>
+Date: Sun, 31 Jan 2021 16:57:44 +0100
+Subject: [PATCH] Use `size_t` instead of `int` for size variables.
+
+And use strtoul() instead of atoi() because atoi() returns int, even
+worse if the value can not be represented, behavior is undefined.
+
+Patch by @shenada , some tweaks by @12345ieee .
+
+Closes #396
+--- a/test/memfake.c
++++ b/test/memfake.c
+@@ -22,19 +22,21 @@
+ #include <stdlib.h>
+ #include <time.h>
+ #include <unistd.h>
++#include <assert.h>
+
+ int main(int argc, char **argv)
+ {
+- uint MB_to_allocate = 1;
++ size_t MB_to_allocate = 1;
+ bool add_randomness = false;
+
+- if (argc >= 2) MB_to_allocate = atoi(argv[1]);
+- if (argc >= 3) add_randomness = atoi(argv[2]);
++ if (argc >= 2) MB_to_allocate = strtoul(argv[1], NULL, 10);
++ if (argc >= 3) add_randomness = strtoul(argv[2], NULL, 10);
+ if (argc >= 4) return 1;
+
+ size_t array_size = MB_to_allocate * 1024 * 1024 / sizeof(int);
+
+ int* array = calloc(array_size, sizeof(int));
++ assert(array != NULL);
+
+ // Fill half with random values and leave an half of zeroes, if asked to
+ if (add_randomness) {
+
diff --git a/dev-util/scanmem/scanmem-0.17.ebuild b/dev-util/scanmem/scanmem-0.17.ebuild
index eb0dd2115025..35fff207b409 100644
--- a/dev-util/scanmem/scanmem-0.17.ebuild
+++ b/dev-util/scanmem/scanmem-0.17.ebuild
@@ -25,6 +25,10 @@ RDEPEND="${DEPEND}
REQUIRED_USE="gui? ( ${PYTHON_REQUIRED_USE} )"
+PATCHES=(
+ "${FILESDIR}"/${P}-musl-tests.patch
+)
+
pkg_setup() {
use gui && python-single-r1_pkg_setup
}