Remove unnecessary if to save 16 bytes
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/library/bignum_core.c b/library/bignum_core.c
index ba6c0c1..a99b3be 100644
--- a/library/bignum_core.c
+++ b/library/bignum_core.c
@@ -71,12 +71,10 @@
int i;
size_t j;
- if (A_limbs != 0) {
- for (i = (int) A_limbs - 1; i >= 0; i--) {
- if (A[i] != 0) {
- j = biL - mbedtls_mpi_core_clz(A[i]);
- return (i * biL) + j;
- }
+ for (i = ((int) A_limbs) - 1; i >= 0; i--) {
+ if (A[i] != 0) {
+ j = biL - mbedtls_mpi_core_clz(A[i]);
+ return (i * biL) + j;
}
}
diff --git a/tests/suites/test_suite_bignum_core.function b/tests/suites/test_suite_bignum_core.function
index 53aa002..0cd1507 100644
--- a/tests/suites/test_suite_bignum_core.function
+++ b/tests/suites/test_suite_bignum_core.function
@@ -301,7 +301,11 @@
mbedtls_mpi_uint *X = NULL;
size_t limbs;
- TEST_EQUAL(mbedtls_test_read_mpi_core(&X, &limbs, input_X), 0);
+ if (strlen(input_X) == 0) {
+ limbs = 0;
+ } else {
+ TEST_EQUAL(mbedtls_test_read_mpi_core(&X, &limbs, input_X), 0);
+ }
TEST_EQUAL(mbedtls_mpi_core_bitlen(X, limbs), nr_bits);
exit:
diff --git a/tests/suites/test_suite_bignum_core.misc.data b/tests/suites/test_suite_bignum_core.misc.data
index ba86029..9e1b892 100644
--- a/tests/suites/test_suite_bignum_core.misc.data
+++ b/tests/suites/test_suite_bignum_core.misc.data
@@ -155,6 +155,9 @@
Test mbedtls_mpi_core_bitlen 0x0a
mpi_core_bitlen:"a":4
+Test mbedtls_mpi_core_bitlen: 0 limbs
+mpi_core_bitlen:"":0
+
Test mbedtls_mpi_core_bitlen: 0 (1 limb)
mpi_core_bitlen:"0":0