test: enable -Wunused-function in test suite (Fix #1831)
What changed, and why it matters
This commit only changes compiler warning settings inside the project's test code. It turns on a warning for unused functions so the test suite catches dead code. It does not change any actual security logic, cryptography, or runtime behavior of the library.
No security action needed; treat as normal code-quality/test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds #pragma GCC diagnostic warning "-Wunused-function" push/pop blocks around four test source files (ctime_tests.c, tests.c, tests_exhaustive.c, unit_test.c). This is a build-hygiene change to address issue #1831. No library code, APIs, algorithms, or memory handling are modified.
Changed components
test suite build configurationInspect captured patch +36 / −0
diff --git a/src/ctime_tests.c b/src/ctime_tests.c
index f80042a..8a885ca 100644
--- a/src/ctime_tests.c
+++ b/src/ctime_tests.c
@@ -40,6 +40,11 @@
#include "../include/secp256k1_ellswift.h"
#endif
+#if defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic warning "-Wunused-function"
+#endif
+
static void run_tests(secp256k1_context *ctx, unsigned char *key);
int main(void) {
@@ -265,3 +270,7 @@ static void run_tests(secp256k1_context *ctx, unsigned char *key) {
#endif
}
+
+#if defined(__GNUC__)
+# pragma GCC diagnostic pop
+#endif
diff --git a/src/tests.c b/src/tests.c
index 5070f59..6c3cd39 100644
--- a/src/tests.c
+++ b/src/tests.c
@@ -37,6 +37,11 @@
#include "int128_impl.h"
#endif
+#if defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic warning "-Wunused-function"
+#endif
+
#define CONDITIONAL_TEST(cnt, nam) if (COUNT < (cnt)) { printf("Skipping %s (iteration count too low)\n", nam); } else
static secp256k1_context *CTX = NULL;
@@ -8091,3 +8096,7 @@ int main(int argc, char **argv) {
if (tf_init(&tf, argc, argv) != 0) return EXIT_FAILURE;
return tf_run(&tf);
}
+
+#if defined(__GNUC__)
+# pragma GCC diagnostic pop
+#endif
diff --git a/src/tests_exhaustive.c b/src/tests_exhaustive.c
index 80f7156..99d7b24 100644
--- a/src/tests_exhaustive.c
+++ b/src/tests_exhaustive.c
@@ -31,6 +31,11 @@
#include "testutil.h"
#include "util.h"
+#if defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic warning "-Wunused-function"
+#endif
+
static int count = 2;
static uint32_t num_cores = 1;
@@ -467,3 +472,7 @@ int main(int argc, char** argv) {
printf("no problems found\n");
return EXIT_SUCCESS;
}
+
+#if defined(__GNUC__)
+# pragma GCC diagnostic pop
+#endif
diff --git a/src/unit_test.c b/src/unit_test.c
index a1858a1..2ac709c 100644
--- a/src/unit_test.c
+++ b/src/unit_test.c
@@ -17,6 +17,11 @@
#include "testrand.h"
#include "tests_common.h"
+#if defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic warning "-Wunused-function"
+#endif
+
#define UNUSED(x) (void)(x)
/* Number of times certain tests will run */
@@ -477,3 +482,7 @@ static int tf_run(struct tf_framework* tf) {
return status;
}
+
+#if defined(__GNUC__)
+# pragma GCC diagnostic pop
+#endif
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.