From 9011dae0c18d6195b756d43b823265a9b0a685e4 Mon Sep 17 00:00:00 2001
From: Paul Elliott <paul.elliott@arm.com>
Date: Sat, 24 Feb 2024 10:57:22 +0000
Subject: [PATCH] Improve documentation / comments

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
---
 tests/src/helpers.c           | 17 ++++++++---------
 tests/src/threading_helpers.c |  4 ++--
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/tests/src/helpers.c b/tests/src/helpers.c
index 8e1d564145..24334228ff 100644
--- a/tests/src/helpers.c
+++ b/tests/src/helpers.c
@@ -33,15 +33,14 @@ mbedtls_threading_mutex_t mbedtls_test_info_mutex;
 /*----------------------------------------------------------------------------*/
 /* Mbedtls Test Info accessors
  *
- * NOTE - there are two types of accessors here; the _internal functions, which
- * are expected to be used from this module *only*. These do not attempt to lock
- * the mbedtls_test_info_mutex, as they are designed to be called from within
- * public functions which do lock the mutex first (if mutexes are enabled).
- * The main reason for this is the need to set some sets of test data
- * atomically, without releasing the mutex inbetween to prevent race conditions
- * resulting in mixed test info. The other public accessors have prototypes in
- * the header and have to lock the mutex for safety as we obviously cannot
- * control where they are called from. */
+ * NOTE - there are two types of accessors here: public accessors and internal
+ * accessors. The public accessors have prototypes in helpers.h and lock
+ * mbedtls_test_info_mutex (if mutexes are enabled). The _internal accessors,
+ * which are expected to be used from this module *only*, do not lock the mutex.
+ * These are designed to be called from within public functions which already
+ * hold the mutex. The main reason for this difference is the need to set
+ * multiple test data values atomically (without releasing the mutex) to prevent
+ * race conditions. */
 
 mbedtls_test_result_t mbedtls_test_get_result(void)
 {
diff --git a/tests/src/threading_helpers.c b/tests/src/threading_helpers.c
index 5eac02909e..c1686c21ad 100644
--- a/tests/src/threading_helpers.c
+++ b/tests/src/threading_helpers.c
@@ -321,8 +321,8 @@ void mbedtls_test_mutex_usage_check(void)
         if (live_mutexes != 0) {
             /* A positive number (more init than free) means that a mutex resource
              * is leaking (on platforms where a mutex consumes more than the
-             * mbedtls_threading_mutex_t object itself). The rare case of a
-             * negative number means a missing init somewhere. */
+             * mbedtls_threading_mutex_t object itself). The (hopefully) rare
+             * case of a negative number means a missing init somewhere. */
             mbedtls_fprintf(stdout, "[mutex: %d leaked] ", live_mutexes);
             live_mutexes = 0;
             mbedtls_test_set_mutex_usage_error("missing free");