net-analyzer/nagios-plugins-linux-madrisan: fixes for x86, #927490
Closes: https://bugs.gentoo.org/927490 Signed-off-by: Louis Sautier <sbraz@gentoo.org>
This commit is contained in:
parent
56cf8e11a4
commit
5c1322c6e5
|
@ -0,0 +1,148 @@
|
|||
https://github.com/madrisan/nagios-plugins-linux/pull/146
|
||||
|
||||
From d09bfd1b3974743af4b719629f59b5b96e1393a1 Mon Sep 17 00:00:00 2001
|
||||
From: Davide Madrisan <d.madrisan@proton.me>
|
||||
Date: Wed, 27 Mar 2024 09:29:59 +0100
|
||||
Subject: [PATCH 1/3] fix: size_t variables on 32 and 64 bits arch have
|
||||
different type
|
||||
|
||||
Fix the following warning on 32-bits architectures:
|
||||
|
||||
In file included from ../lib/container_docker_count.c:44,
|
||||
from tslibcontainer_docker_count.c:33:
|
||||
../lib/container_docker_count.c: In function 'docker_running_containers':
|
||||
../include/logging.h:28:44: warning: format '%lu' expects argument of type 'long unsigned int',
|
||||
but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
|
||||
28 | # define dbg(format, ...) fprintf (stdout, "DEBUG: " format, ##__VA_ARGS__)
|
||||
| ^~~~~~~~~
|
||||
../lib/container_docker_count.c:213:3: note: in expansion of macro 'dbg'
|
||||
213 | dbg ("%lu bytes retrieved\n", chunk.size);
|
||||
| ^~~
|
||||
|
||||
Signed-off-by: Davide Madrisan <d.madrisan@proton.me>
|
||||
--- a/lib/container_docker_count.c
|
||||
+++ b/lib/container_docker_count.c
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
/*
|
||||
* License: GPLv3+
|
||||
- * Copyright (c) 2018 Davide Madrisan <davide.madrisan@gmail.com>
|
||||
+ * Copyright (c) 2018,2024 Davide Madrisan <davide.madrisan@gmail.com>
|
||||
*
|
||||
* A library for checking for Docker exposed metrics.
|
||||
*
|
||||
@@ -210,7 +210,7 @@ docker_running_containers (unsigned int *count, const char *image,
|
||||
#endif /* NPL_TESTING */
|
||||
|
||||
assert (chunk.memory);
|
||||
- dbg ("%lu bytes retrieved\n", chunk.size);
|
||||
+ dbg ("%zu bytes retrieved\n", chunk.size);
|
||||
dbg ("json data: %s", chunk.memory);
|
||||
|
||||
hashtable = docker_json_parser (chunk.memory, "Image", 1);
|
||||
|
||||
From 4574e9ed77ebda062279622bb3d8678fa983d272 Mon Sep 17 00:00:00 2001
|
||||
From: Davide Madrisan <d.madrisan@proton.me>
|
||||
Date: Wed, 27 Mar 2024 17:36:04 +0100
|
||||
Subject: [PATCH 2/3] fix: workaround for a round issue on 32 bits
|
||||
|
||||
On Gentoo Base System release 2.14 for 32-bits
|
||||
|
||||
(unsigned long)(6.26*100) = 625
|
||||
|
||||
So the test fails.
|
||||
As a workaround modify the data file used by the test.
|
||||
|
||||
Signed-off-by: Davide Madrisan <d.madrisan@proton.me>
|
||||
--- a/tests/ts_procpressurecpu.data
|
||||
+++ b/tests/ts_procpressurecpu.data
|
||||
@@ -1 +1 @@
|
||||
-some avg10=7.48 avg60=6.26 avg300=6.66 total=200932088
|
||||
+some avg10=7.48 avg60=6.25 avg300=6.66 total=200932088
|
||||
--- a/tests/tslibpressure.c
|
||||
+++ b/tests/tslibpressure.c
|
||||
@@ -103,7 +103,7 @@ mymain (void)
|
||||
/* we multiply by 100 the averages to somewhat transform
|
||||
* the double values into integer ones */
|
||||
DO_TEST ("cpu some avg10", psi_oneline->avg10 * 100, 748ULL);
|
||||
- DO_TEST ("cpu some avg60", psi_oneline->avg60 * 100, 626ULL);
|
||||
+ DO_TEST ("cpu some avg60", psi_oneline->avg60 * 100, 625ULL);
|
||||
DO_TEST ("cpu some avg300", psi_oneline->avg300 * 100, 666ULL);
|
||||
DO_TEST ("cpu single total", psi_oneline->total, 200932088ULL);
|
||||
|
||||
|
||||
From c90afc02705fd6c32a6764741616b4e17688117b Mon Sep 17 00:00:00 2001
|
||||
From: Davide Madrisan <d.madrisan@proton.me>
|
||||
Date: Wed, 27 Mar 2024 21:06:25 +0100
|
||||
Subject: [PATCH 3/3] fix: fix test tslibxstrton_sizetollint on 32-bit arch
|
||||
|
||||
Fix the following errors:
|
||||
|
||||
1) check function sizetollint with arg 1024b ... OK
|
||||
2) check function sizetollint with arg 8k ... OK
|
||||
3) check function sizetollint with arg 50m ... OK
|
||||
4) check function sizetollint with arg 2g ... OK
|
||||
5) check function sizetollint with arg 3t ... FAILED
|
||||
6) check function sizetollint with arg 2p ... FAILED
|
||||
7) check function sizetollint with arg 1024B ... OK
|
||||
8) check function sizetollint with arg 8K ... OK
|
||||
9) check function sizetollint with arg 50M ... OK
|
||||
10) check function sizetollint with arg 2G ... OK
|
||||
11) check function sizetollint with arg 3T ... FAILED
|
||||
12) check function sizetollint with arg 2P ... FAILED
|
||||
|
||||
The long int is not large enough on 32-bit architectures.
|
||||
|
||||
Signed-off-by: Davide Madrisan <d.madrisan@proton.me>
|
||||
--- a/tests/tslibxstrton_sizetoint64.c
|
||||
+++ b/tests/tslibxstrton_sizetoint64.c
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
/*
|
||||
* License: GPLv3+
|
||||
- * Copyright (c) 2022 Davide Madrisan <davide.madrisan@gmail.com>
|
||||
+ * Copyright (c) 2022,2024 Davide Madrisan <davide.madrisan@gmail.com>
|
||||
*
|
||||
* Unit test for lib/xstrton.c
|
||||
*
|
||||
@@ -29,11 +29,11 @@
|
||||
typedef struct test_data
|
||||
{
|
||||
char *size;
|
||||
- int64_t expect_value;
|
||||
+ long long int expect_value;
|
||||
} test_data;
|
||||
|
||||
static int
|
||||
-test_sizetoint64 (const void *tdata)
|
||||
+test_sizetollint (const void *tdata)
|
||||
{
|
||||
const struct test_data *data = tdata;
|
||||
long long int result;
|
||||
@@ -57,19 +57,19 @@ mymain (void)
|
||||
.size = SIZE, \
|
||||
.expect_value = EXPECT_VALUE, \
|
||||
}; \
|
||||
- if (test_run("check function sizetoint64 with arg " SIZE, \
|
||||
- test_sizetoint64, (&data)) < 0) \
|
||||
+ if (test_run("check function sizetollint with arg " SIZE, \
|
||||
+ test_sizetollint, (&data)) < 0) \
|
||||
ret = -1; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* test the function sizetoint64() */
|
||||
|
||||
-#define ONE_KILOBYTE 1000UL
|
||||
-#define ONE_MEGABYTE (1000UL * ONE_KILOBYTE)
|
||||
-#define ONE_GIGABYTE (1000UL * ONE_MEGABYTE)
|
||||
-#define ONE_TERABYTE (1000UL * ONE_GIGABYTE)
|
||||
-#define ONE_PETABYTE (1000UL * ONE_TERABYTE)
|
||||
+#define ONE_KILOBYTE 1000ULL
|
||||
+#define ONE_MEGABYTE (1000ULL * ONE_KILOBYTE)
|
||||
+#define ONE_GIGABYTE (1000ULL * ONE_MEGABYTE)
|
||||
+#define ONE_TERABYTE (1000ULL * ONE_GIGABYTE)
|
||||
+#define ONE_PETABYTE (1000ULL * ONE_TERABYTE)
|
||||
|
||||
DO_TEST ("1024b", 1024);
|
||||
DO_TEST ("8k", 8 * ONE_KILOBYTE);
|
|
@ -27,6 +27,7 @@ RDEPEND="${DEPEND}"
|
|||
|
||||
PATCHES=(
|
||||
"${FILESDIR}/${P}-rename-with-systemd.patch"
|
||||
"${FILESDIR}/${P}-x86-fixes.patch"
|
||||
)
|
||||
|
||||
src_prepare() {
|
Loading…
Reference in New Issue