From 9c32656c9b157b8e4b05b6c3176a59fa270bcd7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Oto=20=C5=A0=C5=A5=C3=A1va?= <oto.stava@nic.cz>
Date: Fri, 2 Aug 2024 15:43:04 +0200
Subject: [PATCH] bench/bench_lru: make it build again, and check it in CI

It's not too important, but I just stumbled upon this and it looked like
nobody has touched it in a long time. Since it's not completely broken
(the fix is trivial), I decided to fix it and add it to CI to ensure
that we can still build it. Maybe `lru` will be used some more at some
point again in the future...
---
 .gitlab-ci.yml    |  2 +-
 bench/bench_lru.c | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cf1d77c95..832a85f22 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -130,7 +130,7 @@ build-arch:
 build-stable:
   <<: *build
   script:
-    - meson build_ci_stable --prefix=$PREFIX -Dmalloc=disabled -Dwerror=true -Dextra_tests=enabled
+    - meson build_ci_stable --prefix=$PREFIX -Dmalloc=disabled -Dwerror=true -Dextra_tests=enabled -Dbench=enabled
     - ninja -C build_ci_stable
     - ninja -C build_ci_stable install >/dev/null
     - ${MESON_TEST} --suite unit --suite config --suite dnstap --no-suite snowflake
diff --git a/bench/bench_lru.c b/bench/bench_lru.c
index 06f77c0d9..b00607738 100644
--- a/bench/bench_lru.c
+++ b/bench/bench_lru.c
@@ -13,13 +13,13 @@
 #include "daemon/engine.h"
 #include "lib/selection.h"
 
-typedef kr_nsrep_lru_t lru_bench_t;
+typedef lru_t(unsigned) lru_bench_t;
 
 #define p_out(...) do { \
 	printf(__VA_ARGS__); \
-	fflush(stdout); \
-	} while (0)
-#define p_err(...) fprintf(stderr, __VA_ARGS__)
+	(void)fflush(stdout); \
+} while (0)
+#define p_err(...) ((void)fprintf(stderr, __VA_ARGS__))
 
 #ifndef LRU_RTT_SIZE
 #define LRU_RTT_SIZE 65536 /**< NS RTT cache size */
@@ -27,7 +27,7 @@ typedef kr_nsrep_lru_t lru_bench_t;
 
 static int die(const char *cause)
 {
-	fprintf(stderr, "%s: %s\n", cause, strerror(errno));
+	(void)fprintf(stderr, "%s: %s\n", cause, strerror(errno));
 	exit(1);
 }
 
@@ -171,7 +171,7 @@ int main(int argc, char ** argv)
 	struct key *keys = read_lines(argv[2], &key_count, &data_to_free);
 	size_t run_count;
 	{
-		size_t run_log = atoi(argv[1]);
+		size_t run_log = atoi(argv[1]); // NOLINT: atoi is fine for this tool...
 		assert(run_log < 64);
 		run_count = 1ULL << run_log;
 		p_err("\ntest run length:\t2^");
@@ -179,7 +179,7 @@ int main(int argc, char ** argv)
 	}
 
 	struct timeval time;
-	const int lru_size = argc > 4 ? atoi(argv[4]) : LRU_RTT_SIZE;
+	const int lru_size = argc > 4 ? atoi(argv[4]) : LRU_RTT_SIZE; // NOLINT: ditto atoi
 
 	lru_bench_t *lru;
 	#ifdef lru_create
-- 
GitLab