Improve documentation for error code checking
Improve comments explaining error code checking, fix incorrect comments
and make a small formatting fix.
Signed-off-by: Chris Jones <christopher.jones@arm.com>
diff --git a/include/mbedtls/error.h b/include/mbedtls/error.h
index 3d8a5ea..52b8188 100644
--- a/include/mbedtls/error.h
+++ b/include/mbedtls/error.h
@@ -122,7 +122,7 @@
/**
* \brief Combines a high-level and low-level error code together.
*
- * Wrapper function for mbedtls_err_add_ext(). See that function for
+ * Wrapper macro for mbedtls_error_add_ext(). See that function for
* more details.
*/
#define MBEDTLS_ERROR_ADD( high, low ) \
diff --git a/library/ssl_cookie.c b/library/ssl_cookie.c
index b64c354..69d1b32 100644
--- a/library/ssl_cookie.c
+++ b/library/ssl_cookie.c
@@ -220,7 +220,7 @@
#if defined(MBEDTLS_THREADING_C)
if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
- return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_SSL_INTERNAL_ERROR ,
+ return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_SSL_INTERNAL_ERROR,
MBEDTLS_ERR_THREADING_MUTEX_ERROR ) );
#endif
diff --git a/tests/src/helpers.c b/tests/src/helpers.c
index b546611..4923e3c 100644
--- a/tests/src/helpers.c
+++ b/tests/src/helpers.c
@@ -298,22 +298,34 @@
* h = high level error code (includes high and module error codes).
* l = low level error code.
*/
- if ( high > -0x1000 && high != 0 ) // high < 0001000000000000
+ if ( high > -0x1000 && high != 0 )
+ /* high < 0001000000000000
+ * No high level error bits are set.
+ */
{
mbedtls_test_fail( "'high' is not a high-level error code",
line, file );
}
- else if ( high < -0x7F80 ) // high > 0111111110000000
+ else if ( high < -0x7F80 )
+ /* high > 0111111110000000
+ * Error code is larger than the greatest high + module level error.
+ */
{
mbedtls_test_fail( "'high' error code is greater than 15 bits",
line, file );
}
- else if ( ( high & 0x7F ) != 0 ) // high & 0000000001111111
+ else if ( ( high & 0x7F ) != 0 )
+ /* high & 0000000001111111
+ * Error code contains low level error code bits.
+ */
{
mbedtls_test_fail( "'high' contains a low-level error code",
line, file );
}
- else if ( low < -0x007F ) // low > 0000000001111111
+ else if ( low < -0x007F )
+ /* low > 0000000001111111
+ * Error code contains high or module level error code bits.
+ */
{
mbedtls_test_fail( "'low' error code is greater than 7 bits",
line, file );