Improve readability with less negation.
Err, I mean don't worsen readability by not using more negation.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h
index 5a27b42..017557a 100644
--- a/include/mbedtls/pk.h
+++ b/include/mbedtls/pk.h
@@ -643,8 +643,9 @@
*/
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_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 */