This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 06d07b15228b9af04e23137ecd337604293f73d6 Author: ouyangxiangzhen <[email protected]> AuthorDate: Tue Dec 30 10:07:46 2025 +0800 testing/ostest: Fix Coverity for spinlock test. This commit fixed coverity for spinlock test. Signed-off-by: ouyangxiangzhen <[email protected]> --- testing/ostest/spinlock.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/testing/ostest/spinlock.c b/testing/ostest/spinlock.c index 0e38ec03b..1ebe290f1 100644 --- a/testing/ostest/spinlock.c +++ b/testing/ostest/spinlock.c @@ -215,13 +215,20 @@ void run_test_thread(void *lock, FAR void *(*thread_func)(FAR void *arg), total_ns += param[i].delta; } - printf("%s: Test Results:\n", lock_type); - printf("%s: Final counter: %" PRIu32 "\n", lock_type, pub.counter); - assert(pub.counter == thread_num * LOOP_TIMES); - printf("%s: Average throughput : %" PRIu64 " op/s\n", lock_type, - (uint64_t)NSEC_PER_SEC * LOOP_TIMES * thread_num / total_ns); - printf("%s: Total execution time: %" PRIu64 " ns\n \n", - lock_type, calc_diff(&stime, &etime)); + if (total_ns != 0) + { + printf("%s: Test Results:\n", lock_type); + printf("%s: Final counter: %" PRIu32 "\n", lock_type, pub.counter); + assert(pub.counter == thread_num * LOOP_TIMES); + printf("%s: Average throughput : %" PRIu64 " op/s\n", lock_type, + (uint64_t)NSEC_PER_SEC * LOOP_TIMES * thread_num / total_ns); + printf("%s: Total execution time: %" PRIu64 " ns\n \n", + lock_type, calc_diff(&stime, &etime)); + } + else + { + printf("spinlock_test: ERROR: total_ns is 0\n"); + } } /**************************************************************************** @@ -258,7 +265,7 @@ void spinlock_test(void) { unsigned tnr; - for (tnr = 1; tnr < MAX_THREAD_NUM; tnr++) + for (tnr = 1; tnr <= MAX_THREAD_NUM; tnr++) { spinlock_test_thread_num(tnr); }
