3232#include "cborinternal_p.h"
3333#include "compilersupport_p.h"
3434
35- #include <assert.h>
3635#include <string.h>
3736
38- #include "assert_p.h" /* Always include last */
39-
4037#ifndef CBOR_PARSER_MAX_RECURSIONS
4138# define CBOR_PARSER_MAX_RECURSIONS 1024
4239#endif
@@ -281,7 +278,7 @@ static CborError preparse_value(CborValue *it)
281278 case 29 :
282279 case 30 :
283280 case Break :
284- assert (false); /* these conditions can't be reached */
281+ cbor_assert (false); /* these conditions can't be reached */
285282 return CborErrorUnexpectedBreak ;
286283 }
287284 return CborNoError ;
@@ -323,11 +320,11 @@ static CborError advance_internal(CborValue *it)
323320{
324321 uint64_t length ;
325322 CborError err = _cbor_value_extract_number (& it -> ptr , it -> parser -> end , & length );
326- assert (err == CborNoError );
323+ cbor_assert (err == CborNoError );
327324
328325 if (it -> type == CborByteStringType || it -> type == CborTextStringType ) {
329- assert (length == (size_t )length );
330- assert ((it -> flags & CborIteratorFlag_UnknownLength ) == 0 );
326+ cbor_assert (length == (size_t )length );
327+ cbor_assert ((it -> flags & CborIteratorFlag_UnknownLength ) == 0 );
331328 it -> ptr += length ;
332329 }
333330
@@ -346,16 +343,16 @@ static CborError advance_internal(CborValue *it)
346343 */
347344uint64_t _cbor_value_decode_int64_internal (const CborValue * value )
348345{
349- assert (value -> flags & CborIteratorFlag_IntegerValueTooLarge ||
350- value -> type == CborFloatType || value -> type == CborDoubleType );
346+ cbor_assert (value -> flags & CborIteratorFlag_IntegerValueTooLarge ||
347+ value -> type == CborFloatType || value -> type == CborDoubleType );
351348
352349 /* since the additional information can only be Value32Bit or Value64Bit,
353350 * we just need to test for the one bit those two options differ */
354- assert ((* value -> ptr & SmallValueMask ) == Value32Bit || (* value -> ptr & SmallValueMask ) == Value64Bit );
351+ cbor_assert ((* value -> ptr & SmallValueMask ) == Value32Bit || (* value -> ptr & SmallValueMask ) == Value64Bit );
355352 if ((* value -> ptr & 1 ) == (Value32Bit & 1 ))
356353 return get32 (value -> ptr + 1 );
357354
358- assert ((* value -> ptr & SmallValueMask ) == Value64Bit );
355+ cbor_assert ((* value -> ptr & SmallValueMask ) == Value64Bit );
359356 return get64 (value -> ptr + 1 );
360357}
361358
@@ -440,8 +437,8 @@ CborError cbor_parser_init(const uint8_t *buffer, size_t size, int flags, CborPa
440437 */
441438CborError cbor_value_advance_fixed (CborValue * it )
442439{
443- assert (it -> type != CborInvalidType );
444- assert (is_fixed_type (it -> type ));
440+ cbor_assert (it -> type != CborInvalidType );
441+ cbor_assert (is_fixed_type (it -> type ));
445442 if (!it -> remaining )
446443 return CborErrorAdvancePastEOF ;
447444 return advance_internal (it );
@@ -488,7 +485,7 @@ static CborError advance_recursive(CborValue *it, int nestingLevel)
488485 */
489486CborError cbor_value_advance (CborValue * it )
490487{
491- assert (it -> type != CborInvalidType );
488+ cbor_assert (it -> type != CborInvalidType );
492489 if (!it -> remaining )
493490 return CborErrorAdvancePastEOF ;
494491 return advance_recursive (it , 0 );
@@ -552,7 +549,7 @@ CborError cbor_value_skip_tag(CborValue *it)
552549CborError cbor_value_enter_container (const CborValue * it , CborValue * recursed )
553550{
554551 CborError err ;
555- assert (cbor_value_is_container (it ));
552+ cbor_assert (cbor_value_is_container (it ));
556553 * recursed = * it ;
557554
558555 if (it -> flags & CborIteratorFlag_UnknownLength ) {
@@ -567,7 +564,7 @@ CborError cbor_value_enter_container(const CborValue *it, CborValue *recursed)
567564 } else {
568565 uint64_t len ;
569566 err = _cbor_value_extract_number (& recursed -> ptr , recursed -> parser -> end , & len );
570- assert (err == CborNoError );
567+ cbor_assert (err == CborNoError );
571568
572569 recursed -> remaining = (uint32_t )len ;
573570 if (recursed -> remaining != len || len == UINT32_MAX ) {
@@ -608,8 +605,8 @@ CborError cbor_value_enter_container(const CborValue *it, CborValue *recursed)
608605 */
609606CborError cbor_value_leave_container (CborValue * it , const CborValue * recursed )
610607{
611- assert (cbor_value_is_container (it ));
612- assert (recursed -> type == CborInvalidType );
608+ cbor_assert (cbor_value_is_container (it ));
609+ cbor_assert (recursed -> type == CborInvalidType );
613610 it -> ptr = recursed -> ptr ;
614611 return preparse_next_value (it );
615612}
@@ -790,7 +787,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
790787 */
791788CborError cbor_value_get_int64_checked (const CborValue * value , int64_t * result )
792789{
793- assert (cbor_value_is_integer (value ));
790+ cbor_assert (cbor_value_is_integer (value ));
794791 uint64_t v = _cbor_value_extract_int64_helper (value );
795792
796793 /* Check before converting, as the standard says (C11 6.3.1.3 paragraph 3):
@@ -829,7 +826,7 @@ CborError cbor_value_get_int64_checked(const CborValue *value, int64_t *result)
829826 */
830827CborError cbor_value_get_int_checked (const CborValue * value , int * result )
831828{
832- assert (cbor_value_is_integer (value ));
829+ cbor_assert (cbor_value_is_integer (value ));
833830 uint64_t v = _cbor_value_extract_int64_helper (value );
834831
835832 /* Check before converting, as the standard says (C11 6.3.1.3 paragraph 3):
@@ -965,7 +962,7 @@ static uintptr_t iterate_memcmp(char *s1, const uint8_t *s2, size_t len)
965962static CborError iterate_string_chunks (const CborValue * value , char * buffer , size_t * buflen ,
966963 bool * result , CborValue * next , IterateFunction func )
967964{
968- assert (cbor_value_is_byte_string (value ) || cbor_value_is_text_string (value ));
965+ cbor_assert (cbor_value_is_byte_string (value ) || cbor_value_is_text_string (value ));
969966
970967 size_t total ;
971968 CborError err ;
@@ -1220,7 +1217,7 @@ CborError cbor_value_text_string_equals(const CborValue *value, const char *stri
12201217 */
12211218CborError cbor_value_map_find_value (const CborValue * map , const char * string , CborValue * element )
12221219{
1223- assert (cbor_value_is_map (map ));
1220+ cbor_assert (cbor_value_is_map (map ));
12241221 size_t len = strlen (string );
12251222 CborError err = cbor_value_enter_container (map , element );
12261223 if (err )
@@ -1331,7 +1328,7 @@ CborError cbor_value_map_find_value(const CborValue *map, const char *string, Cb
13311328 */
13321329CborError cbor_value_get_half_float (const CborValue * value , void * result )
13331330{
1334- assert (cbor_value_is_half_float (value ));
1331+ cbor_assert (cbor_value_is_half_float (value ));
13351332
13361333 /* size has been computed already */
13371334 uint16_t v = get16 (value -> ptr + 1 );
0 commit comments