]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(auth): correct sign-compare warning
authorNicolas Toromanoff <nicolas.toromanoff@st.com>
Wed, 23 Dec 2020 15:01:25 +0000 (16:01 +0100)
committerLionel Debieve <lionel.debieve@foss.st.com>
Mon, 14 Nov 2022 10:25:01 +0000 (11:25 +0100)
Correct the warning due to comparison between signed and
unsigned variable.

drivers/auth/mbedtls/mbedtls_x509_parser.c: In function 'get_ext':
drivers/auth/mbedtls/mbedtls_x509_parser.c:120:30:
error: comparison of integer expressions of different
signedness: 'int' and 'size_t' {aka 'unsigned int'}
[-Werror=sign-compare]
120 | if ((oid_len == strlen(oid_str)) && !strcmp(oid, oid_str)) {
    |              ^~

Change-Id: Ic12527f5f92a34e925bee3047c168eacf5e99d8a
Signed-off-by: Nicolas Toromanoff <nicolas.toromanoff@st.com>
drivers/auth/mbedtls/mbedtls_x509_parser.c

index 129566bd6914cf8740c858b4e760419c3fd9329c..993ef1264a0251477dad16025757d077c6b8bb90 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -114,10 +114,10 @@ static int get_ext(const char *oid, void **ext, unsigned int *ext_len)
                oid_len = mbedtls_oid_get_numeric_string(oid_str,
                                                         MAX_OID_STR_LEN,
                                                         &extn_oid);
-               if (oid_len == MBEDTLS_ERR_OID_BUF_TOO_SMALL) {
+               if ((oid_len == MBEDTLS_ERR_OID_BUF_TOO_SMALL) || (oid_len < 0)) {
                        return IMG_PARSER_ERR;
                }
-               if ((oid_len == strlen(oid_str)) && !strcmp(oid, oid_str)) {
+               if (((size_t)oid_len == strlen(oid_str)) && !strcmp(oid, oid_str)) {
                        *ext = (void *)p;
                        *ext_len = (unsigned int)len;
                        return IMG_PARSER_OK;