From 08b2ebd2bef0c4903219bffeec9510afe8ca42cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 17 Jun 2022 10:11:15 +0200 Subject: [PATCH] Improve readability with less negation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Err, I mean don't worsen readability by not using more negation. Signed-off-by: Manuel Pégourié-Gonnard --- include/mbedtls/pk.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h index 5a27b4276..017557a83 100644 --- a/include/mbedtls/pk.h +++ b/include/mbedtls/pk.h @@ -643,8 +643,9 @@ mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx ); */ static inline mbedtls_rsa_context *mbedtls_pk_rsa( const mbedtls_pk_context pk ) { - return( mbedtls_pk_get_type( &pk ) != MBEDTLS_PK_RSA ? NULL : - (mbedtls_rsa_context *) (pk).pk_ctx ); + return( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA ? + (mbedtls_rsa_context *) (pk).pk_ctx : + NULL ); } #endif /* MBEDTLS_RSA_C */ @@ -662,10 +663,11 @@ static inline mbedtls_rsa_context *mbedtls_pk_rsa( const mbedtls_pk_context pk ) */ static inline mbedtls_ecp_keypair *mbedtls_pk_ec( const mbedtls_pk_context pk ) { - return( mbedtls_pk_get_type( &pk ) != MBEDTLS_PK_ECKEY && - mbedtls_pk_get_type( &pk ) != MBEDTLS_PK_ECKEY_DH && - mbedtls_pk_get_type( &pk ) != MBEDTLS_PK_ECDSA ? NULL : - (mbedtls_ecp_keypair *) (pk).pk_ctx ); + return( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY || + mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY_DH || + mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECDSA ? + (mbedtls_ecp_keypair *) (pk).pk_ctx : + NULL ); } #endif /* MBEDTLS_ECP_C */