32
32
#include "cborinternal_p.h"
33
33
#include "compilersupport_p.h"
34
34
35
- #include <assert.h>
36
35
#include <string.h>
37
36
38
- #include "assert_p.h" /* Always include last */
39
-
40
37
#ifndef CBOR_PARSER_MAX_RECURSIONS
41
38
# define CBOR_PARSER_MAX_RECURSIONS 1024
42
39
#endif
@@ -281,7 +278,7 @@ static CborError preparse_value(CborValue *it)
281
278
case 29 :
282
279
case 30 :
283
280
case Break :
284
- assert (false); /* these conditions can't be reached */
281
+ cbor_assert (false); /* these conditions can't be reached */
285
282
return CborErrorUnexpectedBreak ;
286
283
}
287
284
return CborNoError ;
@@ -323,11 +320,11 @@ static CborError advance_internal(CborValue *it)
323
320
{
324
321
uint64_t length ;
325
322
CborError err = _cbor_value_extract_number (& it -> ptr , it -> parser -> end , & length );
326
- assert (err == CborNoError );
323
+ cbor_assert (err == CborNoError );
327
324
328
325
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 );
331
328
it -> ptr += length ;
332
329
}
333
330
@@ -346,16 +343,16 @@ static CborError advance_internal(CborValue *it)
346
343
*/
347
344
uint64_t _cbor_value_decode_int64_internal (const CborValue * value )
348
345
{
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 );
351
348
352
349
/* since the additional information can only be Value32Bit or Value64Bit,
353
350
* 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 );
355
352
if ((* value -> ptr & 1 ) == (Value32Bit & 1 ))
356
353
return get32 (value -> ptr + 1 );
357
354
358
- assert ((* value -> ptr & SmallValueMask ) == Value64Bit );
355
+ cbor_assert ((* value -> ptr & SmallValueMask ) == Value64Bit );
359
356
return get64 (value -> ptr + 1 );
360
357
}
361
358
@@ -440,8 +437,8 @@ CborError cbor_parser_init(const uint8_t *buffer, size_t size, int flags, CborPa
440
437
*/
441
438
CborError cbor_value_advance_fixed (CborValue * it )
442
439
{
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 ));
445
442
if (!it -> remaining )
446
443
return CborErrorAdvancePastEOF ;
447
444
return advance_internal (it );
@@ -488,7 +485,7 @@ static CborError advance_recursive(CborValue *it, int nestingLevel)
488
485
*/
489
486
CborError cbor_value_advance (CborValue * it )
490
487
{
491
- assert (it -> type != CborInvalidType );
488
+ cbor_assert (it -> type != CborInvalidType );
492
489
if (!it -> remaining )
493
490
return CborErrorAdvancePastEOF ;
494
491
return advance_recursive (it , 0 );
@@ -552,7 +549,7 @@ CborError cbor_value_skip_tag(CborValue *it)
552
549
CborError cbor_value_enter_container (const CborValue * it , CborValue * recursed )
553
550
{
554
551
CborError err ;
555
- assert (cbor_value_is_container (it ));
552
+ cbor_assert (cbor_value_is_container (it ));
556
553
* recursed = * it ;
557
554
558
555
if (it -> flags & CborIteratorFlag_UnknownLength ) {
@@ -567,7 +564,7 @@ CborError cbor_value_enter_container(const CborValue *it, CborValue *recursed)
567
564
} else {
568
565
uint64_t len ;
569
566
err = _cbor_value_extract_number (& recursed -> ptr , recursed -> parser -> end , & len );
570
- assert (err == CborNoError );
567
+ cbor_assert (err == CborNoError );
571
568
572
569
recursed -> remaining = (uint32_t )len ;
573
570
if (recursed -> remaining != len || len == UINT32_MAX ) {
@@ -608,8 +605,8 @@ CborError cbor_value_enter_container(const CborValue *it, CborValue *recursed)
608
605
*/
609
606
CborError cbor_value_leave_container (CborValue * it , const CborValue * recursed )
610
607
{
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 );
613
610
it -> ptr = recursed -> ptr ;
614
611
return preparse_next_value (it );
615
612
}
@@ -790,7 +787,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
790
787
*/
791
788
CborError cbor_value_get_int64_checked (const CborValue * value , int64_t * result )
792
789
{
793
- assert (cbor_value_is_integer (value ));
790
+ cbor_assert (cbor_value_is_integer (value ));
794
791
uint64_t v = _cbor_value_extract_int64_helper (value );
795
792
796
793
/* 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)
829
826
*/
830
827
CborError cbor_value_get_int_checked (const CborValue * value , int * result )
831
828
{
832
- assert (cbor_value_is_integer (value ));
829
+ cbor_assert (cbor_value_is_integer (value ));
833
830
uint64_t v = _cbor_value_extract_int64_helper (value );
834
831
835
832
/* 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)
965
962
static CborError iterate_string_chunks (const CborValue * value , char * buffer , size_t * buflen ,
966
963
bool * result , CborValue * next , IterateFunction func )
967
964
{
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 ));
969
966
970
967
size_t total ;
971
968
CborError err ;
@@ -1220,7 +1217,7 @@ CborError cbor_value_text_string_equals(const CborValue *value, const char *stri
1220
1217
*/
1221
1218
CborError cbor_value_map_find_value (const CborValue * map , const char * string , CborValue * element )
1222
1219
{
1223
- assert (cbor_value_is_map (map ));
1220
+ cbor_assert (cbor_value_is_map (map ));
1224
1221
size_t len = strlen (string );
1225
1222
CborError err = cbor_value_enter_container (map , element );
1226
1223
if (err )
@@ -1331,7 +1328,7 @@ CborError cbor_value_map_find_value(const CborValue *map, const char *string, Cb
1331
1328
*/
1332
1329
CborError cbor_value_get_half_float (const CborValue * value , void * result )
1333
1330
{
1334
- assert (cbor_value_is_half_float (value ));
1331
+ cbor_assert (cbor_value_is_half_float (value ));
1335
1332
1336
1333
/* size has been computed already */
1337
1334
uint16_t v = get16 (value -> ptr + 1 );
0 commit comments