[PATCH] libtest: Fix warnings without a pragma
Sebastian Huber
sebastian.huber at embedded-brains.de
Tue Aug 30 05:41:58 UTC 2022
It seems that recent GCC versions expect that functions with "const type *"
parameter will read from the referenced location.
Update #4662.
---
cpukit/include/rtems/test.h | 23 ++++++++---------------
cpukit/libtest/t-test-checks.c | 12 ++++++------
testsuites/libtests/ttest01/test-checks.c | 10 +++++-----
3 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h
index e0823394d1..aa6b4f88b2 100644
--- a/cpukit/include/rtems/test.h
+++ b/cpukit/include/rtems/test.h
@@ -187,50 +187,43 @@ extern const T_check_context T_special;
T_flags_true(flags, \
(a) != (T_VA_ARGS_FIRST(__VA_ARGS__)) T_VA_ARGS_MORE(__VA_ARGS__))
-void T_check_eq_ptr(const T_check_context_msg *, const void *, const void *);
+void T_check_eq_ptr(const T_check_context_msg *, uintptr_t, uintptr_t);
#define T_flags_eq_ptr(a, e, flags, sa, se) \
{ \
static const T_check_context_msg T_check_instance = { \
{ T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, \
sa " == " se }; \
- T_check_eq_ptr(&T_check_instance, a, e); \
+ T_check_eq_ptr(&T_check_instance, (uintptr_t)a, (uintptr_t)e); \
}
-void T_check_ne_ptr(const T_check_context_msg *, const void *, const void *);
+void T_check_ne_ptr(const T_check_context_msg *, uintptr_t, uintptr_t);
#define T_flags_ne_ptr(a, e, flags, sa, se) \
{ \
static const T_check_context_msg T_check_instance = { \
{ T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, \
sa " != " se }; \
- T_check_ne_ptr(&T_check_instance, a, e); \
+ T_check_ne_ptr(&T_check_instance, (uintptr_t)a, (uintptr_t)e); \
}
-void T_check_null(const T_check_context_msg *, const void *);
+void T_check_null(const T_check_context_msg *, uintptr_t);
#define T_flags_null(a, flags, sa) \
{ \
static const T_check_context_msg T_check_instance = { \
{ T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, sa }; \
- T_check_null(&T_check_instance, a); \
+ T_check_null(&T_check_instance, (uintptr_t)a); \
}
-void T_check_not_null(const T_check_context_msg *, const void *);
+void T_check_not_null(const T_check_context_msg *, uintptr_t);
-/*
- * This was added to address the following warning.
- * warning: 'a' may be used uninitialized
- */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#define T_flags_not_null(a, flags, sa) \
{ \
static const T_check_context_msg T_check_instance = { \
{ T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, sa }; \
- T_check_not_null(&T_check_instance, a); \
+ T_check_not_null(&T_check_instance, (uintptr_t)a); \
}
-#pragma GCC diagnostic pop
void T_check_eq_mem(const T_check_context_msg *, const void *, const void *,
size_t);
diff --git a/cpukit/libtest/t-test-checks.c b/cpukit/libtest/t-test-checks.c
index c86596521b..1a278b55ec 100644
--- a/cpukit/libtest/t-test-checks.c
+++ b/cpukit/libtest/t-test-checks.c
@@ -30,27 +30,27 @@
#include <inttypes.h>
void
-T_check_eq_ptr(const T_check_context_msg *t, const void *a, const void *e)
+T_check_eq_ptr(const T_check_context_msg *t, uintptr_t a, uintptr_t e)
{
T_check(&t->base, a == e, "%s", t->msg);
}
void
-T_check_ne_ptr(const T_check_context_msg *t, const void *a, const void *e)
+T_check_ne_ptr(const T_check_context_msg *t, uintptr_t a, uintptr_t e)
{
T_check(&t->base, a != e, "%s", t->msg);
}
void
-T_check_null(const T_check_context_msg *t, const void *a)
+T_check_null(const T_check_context_msg *t, uintptr_t a)
{
- T_check(&t->base, a == NULL, "%s == NULL", t->msg);
+ T_check(&t->base, a == 0, "%s == NULL", t->msg);
}
void
-T_check_not_null(const T_check_context_msg *t, const void *a)
+T_check_not_null(const T_check_context_msg *t, uintptr_t a)
{
- T_check(&t->base, a != NULL, "%s != NULL", t->msg);
+ T_check(&t->base, a != 0, "%s != NULL", t->msg);
}
void
diff --git a/testsuites/libtests/ttest01/test-checks.c b/testsuites/libtests/ttest01/test-checks.c
index 06e1a959bf..fa5591121e 100644
--- a/testsuites/libtests/ttest01/test-checks.c
+++ b/testsuites/libtests/ttest01/test-checks.c
@@ -90,8 +90,8 @@ T_TEST_CASE(step_assert_eq_ptr)
T_TEST_CASE(check_eq_ptr)
{
- int a = 0;
- int b = 0;
+ int a;
+ int b;
T_eq_ptr(&a, &a);
T_eq_ptr(&a, &b);
@@ -115,8 +115,8 @@ T_TEST_CASE(step_assert_ne_ptr)
T_TEST_CASE(check_ne_ptr)
{
- int a = 0;
- int b = 0;
+ int a;
+ int b;
T_ne_ptr(&a, &b);
T_ne_ptr(&a, &a);
@@ -162,7 +162,7 @@ T_TEST_CASE(step_assert_not_null)
T_TEST_CASE(check_not_null)
{
- int a = 0;
+ int a;
T_not_null(&a);
T_not_null(NULL);
--
2.35.3
More information about the devel
mailing list