From ed38366f1dfeb0b0789fd69b400728598ae3c64e Mon Sep 17 00:00:00 2001 From: Nicolas Toromanoff Date: Wed, 23 Dec 2020 16:01:25 +0100 Subject: [PATCH] fix(auth): correct sign-compare warning 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 --- drivers/auth/mbedtls/mbedtls_x509_parser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/auth/mbedtls/mbedtls_x509_parser.c b/drivers/auth/mbedtls/mbedtls_x509_parser.c index 129566bd6..993ef1264 100644 --- a/drivers/auth/mbedtls/mbedtls_x509_parser.c +++ b/drivers/auth/mbedtls/mbedtls_x509_parser.c @@ -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; -- 2.39.5