Document undefined case. Clarify test code.
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/library/bignum_core.c b/library/bignum_core.c
index 1f3a57c..998c06c 100644
--- a/library/bignum_core.c
+++ b/library/bignum_core.c
@@ -33,11 +33,18 @@
#include "bn_mul.h"
#include "constant_time_internal.h"
+/**
+ * \brief Count leading zeros
+ *
+ * \warning The result is undefined if \p a == 0
+ *
+ * \param a The value to operate on
+ *
+ * \return The number of leading zeros, if \p a != 0. If \p a == 0, the result
+ * is undefined.
+ */
inline size_t mbedtls_mpi_core_clz(mbedtls_mpi_uint a)
{
- /* Note: the result is undefined for a == 0
- * (because this is the behaviour of __builtin_clz).
- */
#if defined(__has_builtin)
#if __has_builtin(__builtin_clz)
if (sizeof(mbedtls_mpi_uint) == sizeof(unsigned int)) {