[rtems commit] libtest: Fix implicit type conversions

Sebastian Huber sebh at rtems.org
Mon Feb 1 06:20:12 UTC 2021


Module:    rtems
Branch:    master
Commit:    23f4e5b6c9ffe9a5d08b9c7f51ff3a7efedd8019
Changeset: http://git.rtems.org/rtems/commit/?id=23f4e5b6c9ffe9a5d08b9c7f51ff3a7efedd8019

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jan 28 16:43:55 2021 +0100

libtest: Fix implicit type conversions

This fix relates to a Coverity issue (PW.MIXED_ENUM_TYPE).

---

 cpukit/libtest/t-test-interrupt.c | 11 +++++++----
 cpukit/libtest/t-test-rtems.c     |  4 ++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/cpukit/libtest/t-test-interrupt.c b/cpukit/libtest/t-test-interrupt.c
index 5e17043..cbdc603 100644
--- a/cpukit/libtest/t-test-interrupt.c
+++ b/cpukit/libtest/t-test-interrupt.c
@@ -252,7 +252,7 @@ T_interrupt_test_change_state(T_interrupt_test_state expected_state,
 	_Atomic_Compare_exchange_uint(&ctx->state, &expected,
 	    desired_state, ATOMIC_ORDER_RELAXED, ATOMIC_ORDER_RELAXED);
 
-	return expected;
+	return (T_interrupt_test_state)expected;
 }
 
 T_interrupt_test_state
@@ -261,7 +261,8 @@ T_interrupt_test_get_state(void)
 	T_interrupt_context *ctx;
 
 	ctx = &T_interrupt_instance;
-	return _Atomic_Load_uint(&ctx->state, ATOMIC_ORDER_RELAXED);
+	return (T_interrupt_test_state)_Atomic_Load_uint(&ctx->state,
+	    ATOMIC_ORDER_RELAXED);
 }
 
 void
@@ -288,7 +289,8 @@ T_interrupt_thread_switch(Thread_Control *executing, Thread_Control *heir)
 	if (ctx->self == executing) {
 		T_interrupt_test_state state;
 
-		state = _Atomic_Load_uint(&ctx->state, ATOMIC_ORDER_RELAXED);
+		state = (T_interrupt_test_state)_Atomic_Load_uint(&ctx->state,
+		    ATOMIC_ORDER_RELAXED);
 
 		if (state != T_INTERRUPT_TEST_INITIAL) {
 #ifdef RTEMS_SMP
@@ -433,7 +435,8 @@ T_interrupt_test(const T_interrupt_test_config *config, void *arg)
 		T_busy(busy);
 		(*config->action)(arg);
 
-		state = _Atomic_Exchange_uint(&ctx->state,
+		state = (T_interrupt_test_state)
+		    _Atomic_Exchange_uint(&ctx->state,
 		    T_INTERRUPT_TEST_INITIAL, ATOMIC_ORDER_RELAXED);
 
 		if (state == T_INTERRUPT_TEST_DONE) {
diff --git a/cpukit/libtest/t-test-rtems.c b/cpukit/libtest/t-test-rtems.c
index 8ca5a08..71d8057 100644
--- a/cpukit/libtest/t-test-rtems.c
+++ b/cpukit/libtest/t-test-rtems.c
@@ -40,8 +40,8 @@ T_putchar_default(int c, void *arg)
 void
 T_check_rsc(const T_check_context *t, uint32_t a, uint32_t e)
 {
-	T_check(t, a == e, "%s == %s", rtems_status_text(a),
-	    rtems_status_text(e));
+	T_check(t, a == e, "%s == %s", rtems_status_text((rtems_status_code)a),
+	    rtems_status_text((rtems_status_code)e));
 }
 
 void



More information about the vc mailing list