From 9581fa30503b6416bd3ef01813a9041bb1341f9c Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Thu, 11 Jun 2020 09:50:51 +0200 Subject: [PATCH] Align with check-like function return value convention By convention, in the project, functions that have a check or similar in the name return 0 if the check succeeds, non-zero otherwise. Align with this for mbedtls_ssl_chk_buf_ptr(). Signed-off-by: Ronald Cron --- include/mbedtls/ssl_internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/ssl_internal.h b/include/mbedtls/ssl_internal.h index daf3f6a2d..e6d948ee9 100644 --- a/include/mbedtls/ssl_internal.h +++ b/include/mbedtls/ssl_internal.h @@ -250,13 +250,13 @@ * \param end Pointer to one past the end of the buffer. * \param need Needed space in bytes. * - * \return Non-zero if the needed space is available in the buffer, 0 + * \return Zero if the needed space is available in the buffer, non-zero * otherwise. */ static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur, const uint8_t *end, size_t need ) { - return( cur <= end && need <= (size_t)( end - cur ) ); + return( ( cur > end ) || ( need > (size_t)( end - cur ) ) ); } /** @@ -271,7 +271,7 @@ static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur, */ #define MBEDTLS_SSL_CHK_BUF_PTR( cur, end, need ) \ do { \ - if( mbedtls_ssl_chk_buf_ptr( ( cur ), ( end ), ( need ) ) == 0 ) \ + if( mbedtls_ssl_chk_buf_ptr( ( cur ), ( end ), ( need ) ) != 0 ) \ { \ return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); \ } \