mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-26 12:35:20 +00:00
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 <ronald.cron@arm.com>
This commit is contained in:
parent
5ee5707521
commit
b7b35e125b
@ -313,13 +313,13 @@ static inline uint32_t mbedtls_ssl_get_input_buflen( const mbedtls_ssl_context *
|
|||||||
* \param end Pointer to one past the end of the buffer.
|
* \param end Pointer to one past the end of the buffer.
|
||||||
* \param need Needed space in bytes.
|
* \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.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur,
|
static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur,
|
||||||
const uint8_t *end, size_t need )
|
const uint8_t *end, size_t need )
|
||||||
{
|
{
|
||||||
return( cur <= end && need <= (size_t)( end - cur ) );
|
return( ( cur > end ) || ( need > (size_t)( end - cur ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -334,7 +334,7 @@ static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur,
|
|||||||
*/
|
*/
|
||||||
#define MBEDTLS_SSL_CHK_BUF_PTR( cur, end, need ) \
|
#define MBEDTLS_SSL_CHK_BUF_PTR( cur, end, need ) \
|
||||||
do { \
|
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 ); \
|
return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); \
|
||||||
} \
|
} \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user