Skip to content

Commit 806f0c9

Browse files
cbor.h: Add explicit casts to conversions from uint64_t to size_t
User code might have stronger warning settings than the ones we've used so far. The explict casting will make the compiler not complain, as it was clearly intentional. This fixes #45. Signed-off-by: Thiago Macieira <[email protected]>
1 parent a50c012 commit 806f0c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cbor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ CBOR_INLINE_API CborError cbor_value_get_string_length(const CborValue *value, s
361361
if (!cbor_value_is_length_known(value))
362362
return CborErrorUnknownLength;
363363
uint64_t v = _cbor_value_extract_int64_helper(value);
364-
*length = v;
364+
*length = (size_t)v;
365365
if (*length != v)
366366
return CborErrorDataTooLarge;
367367
return CborNoError;
@@ -416,7 +416,7 @@ CBOR_INLINE_API CborError cbor_value_get_array_length(const CborValue *value, si
416416
if (!cbor_value_is_length_known(value))
417417
return CborErrorUnknownLength;
418418
uint64_t v = _cbor_value_extract_int64_helper(value);
419-
*length = v;
419+
*length = (size_t)v;
420420
if (*length != v)
421421
return CborErrorDataTooLarge;
422422
return CborNoError;
@@ -428,7 +428,7 @@ CBOR_INLINE_API CborError cbor_value_get_map_length(const CborValue *value, size
428428
if (!cbor_value_is_length_known(value))
429429
return CborErrorUnknownLength;
430430
uint64_t v = _cbor_value_extract_int64_helper(value);
431-
*length = v;
431+
*length = (size_t)v;
432432
if (*length != v)
433433
return CborErrorDataTooLarge;
434434
return CborNoError;

0 commit comments

Comments
 (0)