Skip to content

Commit 457a863

Browse files
thiagomacieiraQt Cherry-pick Bot
authored and
Qt Cherry-pick Bot
committed
3rdparty: update TinyCBOR to v0.6.1
[ChangeLog][Third-Party Code] The copy of TinyCBOR in Qt was updated to 0.6.1. Manual conflict resolution for 6.9: - worked around 34f6087 not having been picked to older branches Change-Id: If5d5ef6220874ae8858efffd1712a567597b6317 Reviewed-by: Marc Mutz <[email protected]> (cherry picked from commit 7df1286) (cherry picked from commit cd395a7) Reviewed-by: Qt Cherry-pick Bot <[email protected]>
1 parent 2f169f9 commit 457a863

File tree

10 files changed

+126
-113
lines changed

10 files changed

+126
-113
lines changed

src/3rdparty/tinycbor/0001-tst_Encoder-port-away-from-Q_FOREACH.patch

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/3rdparty/tinycbor/qt_attribution.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"License": "MIT License",
1111
"LicenseId": "MIT",
1212
"LicenseFile": "LICENSE",
13-
"DownloadLocation": "https://github.com/intel/tinycbor/archive/v0.6.0/tinycbor-0.6.0.tar.gz",
13+
"DownloadLocation": "https://github.com/intel/tinycbor/archive/v0.6.1/tinycbor-0.6.1.tar.gz",
1414
"PURL": "pkg:github/intel/tinycbor@v$<VERSION>",
1515
"CPE": "cpe:2.3:a:tinycbor:tinycbor:$<VERSION>:*:*:*:*:*:*:*",
16-
"Version": "0.6.0",
16+
"Version": "0.6.1",
1717
"Copyright": "Copyright (C) 2015-2021 Intel Corporation"
1818
}

src/3rdparty/tinycbor/src/cbor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include <string.h>
3535
#include <stdio.h>
3636

37+
#ifdef CBOR_EXTERNAL_CFG
38+
#include "cbor_cfg.h"
39+
#endif
40+
3741
#include "tinycbor-version.h"
3842

3943
#define TINYCBOR_VERSION ((TINYCBOR_VERSION_MAJOR << 16) | (TINYCBOR_VERSION_MINOR << 8) | TINYCBOR_VERSION_PATCH)

src/3rdparty/tinycbor/src/cborencoder.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#ifndef __STDC_LIMIT_MACROS
3232
# define __STDC_LIMIT_MACROS 1
3333
#endif
34+
#define __STDC_WANT_IEC_60559_TYPES_EXT__
3435

3536
#include "cbor.h"
3637
#include "cborinternal_p.h"
@@ -101,7 +102,7 @@
101102
* complete the encoding. At the end, you can obtain that count by calling
102103
* cbor_encoder_get_extra_bytes_needed().
103104
*
104-
* \section1 Finalizing the encoding
105+
* \section Finalizing the encoding
105106
*
106107
* Once all items have been appended and the containers have all been properly
107108
* closed, the user-supplied buffer will contain the CBOR stream and may be
@@ -212,6 +213,7 @@ void cbor_encoder_init_writer(CborEncoder *encoder, CborEncoderWriteFunction wri
212213
{
213214
#ifdef CBOR_ENCODER_WRITE_FUNCTION
214215
(void) writer;
216+
encoder->data.writer = CBOR_NULLPTR;
215217
#else
216218
encoder->data.writer = writer;
217219
#endif
@@ -544,7 +546,7 @@ CborError cbor_encoder_create_array(CborEncoder *parentEncoder, CborEncoder *arr
544546
* when creating the map, the constant \ref CborIndefiniteLength may be passed as
545547
* length instead, and an indefinite length map is created.
546548
*
547-
* \b{Implementation limitation:} TinyCBOR cannot encode more than SIZE_MAX/2
549+
* <b>Implementation limitation:</b> TinyCBOR cannot encode more than SIZE_MAX/2
548550
* key-value pairs in the stream. If the length \a length is larger than this
549551
* value (and is not \ref CborIndefiniteLength), this function returns error
550552
* CborErrorDataTooLarge.

src/3rdparty/tinycbor/src/cborinternal_p.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,46 @@
2525
#ifndef CBORINTERNAL_P_H
2626
#define CBORINTERNAL_P_H
2727

28+
/* Dependent source files (*.c) must define __STDC_WANT_IEC_60559_TYPES_EXT__
29+
* before <float.h> is (transitively) first included.
30+
*/
31+
#if !defined(__STDC_WANT_IEC_60559_TYPES_EXT__)
32+
# error __STDC_WANT_IEC_60559_TYPES_EXT__ not defined
33+
#endif
34+
2835
#include "compilersupport_p.h"
2936

3037
#ifndef CBOR_NO_FLOATING_POINT
3138
# include <float.h>
3239
# include <math.h>
40+
# include <string.h>
3341
#else
3442
# ifndef CBOR_NO_HALF_FLOAT_TYPE
3543
# define CBOR_NO_HALF_FLOAT_TYPE 1
3644
# endif
3745
#endif
3846

3947
#ifndef CBOR_NO_HALF_FLOAT_TYPE
40-
# if defined(__F16C__) || defined(__AVX2__)
48+
/* Check for FLT16_MANT_DIG using integer comparison. Clang headers incorrectly
49+
* define this macro unconditionally when __STDC_WANT_IEC_60559_TYPES_EXT__
50+
* is defined (regardless of actual support for _Float16).
51+
*/
52+
# if FLT16_MANT_DIG > 0 || __FLT16_MANT_DIG__ > 0
53+
static inline unsigned short encode_half(float x)
54+
{
55+
unsigned short h;
56+
_Float16 f = (_Float16)x;
57+
memcpy(&h, &f, 2);
58+
return h;
59+
}
60+
61+
static inline float decode_half(unsigned short x)
62+
{
63+
_Float16 f;
64+
memcpy(&f, &x, 2);
65+
return (float)f;
66+
}
67+
# elif defined(__F16C__) || defined(__AVX2__)
4168
# include <immintrin.h>
4269
static inline unsigned short encode_half(float val)
4370
{

src/3rdparty/tinycbor/src/cborparser.c

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#ifndef __STDC_LIMIT_MACROS
3232
# define __STDC_LIMIT_MACROS 1
3333
#endif
34+
#define __STDC_WANT_IEC_60559_TYPES_EXT__
3435

3536
#include "cbor.h"
3637
#include "cborinternal_p.h"
@@ -93,7 +94,7 @@
9394
*
9495
* The code above does not execute a range-check either: it is possible that
9596
* the value decoded from the CBOR stream encodes a number larger than what can
96-
* be represented in a variable of type \c{int}. If detecting that case is
97+
* be represented in a variable of type \c int. If detecting that case is
9798
* important, the code should call cbor_value_get_int_checked() instead.
9899
*
99100
* <h3 class="groupheader">Memory and parsing constraints</h3>
@@ -133,12 +134,10 @@
133134
*
134135
* \if privatedocs
135136
* Implementation details: the CborValue contains these fields:
136-
* \list
137-
* \li ptr: pointer to the actual data
138-
* \li flags: flags from the decoder
139-
* \li extra: partially decoded integer value (0, 1 or 2 bytes)
140-
* \li remaining: remaining items in this collection after this item or UINT32_MAX if length is unknown
141-
* \endlist
137+
* - ptr: pointer to the actual data
138+
* - flags: flags from the decoder
139+
* - extra: partially decoded integer value (0, 1 or 2 bytes)
140+
* - remaining: remaining items in this collection after this item or UINT32_MAX if length is unknown
142141
* \endif
143142
*/
144143

@@ -232,7 +231,7 @@ static CborError preparse_value(CborValue *it)
232231
case SinglePrecisionFloat:
233232
case DoublePrecisionFloat:
234233
it->flags |= CborIteratorFlag_IntegerValueTooLarge;
235-
Q_FALLTHROUGH();
234+
CBOR_FALLTHROUGH;
236235
case TrueValue:
237236
case NullValue:
238237
case UndefinedValue:
@@ -428,12 +427,10 @@ CborError cbor_value_reparse(CborValue *it)
428427
* will appear during parsing.
429428
*
430429
* A basic validation checks for:
431-
* \list
432-
* \li absence of undefined additional information bytes;
433-
* \li well-formedness of all numbers, lengths, and simple values;
434-
* \li string contents match reported sizes;
435-
* \li arrays and maps contain the number of elements they are reported to have;
436-
* \endlist
430+
* - absence of undefined additional information bytes;
431+
* - well-formedness of all numbers, lengths, and simple values;
432+
* - string contents match reported sizes;
433+
* - arrays and maps contain the number of elements they are reported to have;
437434
*
438435
* For further checks, see cbor_value_validate().
439436
*
@@ -744,7 +741,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
744741
* \ref cbor_value_is_integer is recommended.
745742
*
746743
* Note that this function does not do range-checking: integral values that do
747-
* not fit in a variable of type \c{int} are silently truncated to fit. Use
744+
* not fit in a variable of type \c int are silently truncated to fit. Use
748745
* cbor_value_get_int_checked() if that is not acceptable.
749746
*
750747
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer()
@@ -759,7 +756,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
759756
* \ref cbor_value_is_integer is recommended.
760757
*
761758
* Note that this function does not do range-checking: integral values that do
762-
* not fit in a variable of type \c{int64_t} are silently truncated to fit. Use
759+
* not fit in a variable of type \c int64_t are silently truncated to fit. Use
763760
* cbor_value_get_int64_checked() that is not acceptable.
764761
*
765762
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer()
@@ -790,7 +787,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
790787
* If the integer is unsigned (that is, if cbor_value_is_unsigned_integer()
791788
* returns true), then \a result will contain the actual value. If the integer
792789
* is negative, then \a result will contain the absolute value of that integer,
793-
* minus one. That is, \c {actual = -result - 1}. On architectures using two's
790+
* minus one. That is, <tt>actual = -result - 1</tt>. On architectures using two's
794791
* complement for representation of negative integers, it is equivalent to say
795792
* that \a result will contain the bitwise negation of the actual value.
796793
*
@@ -1211,7 +1208,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
12111208
return CborErrorDataTooLarge;
12121209

12131210
if (*result && *buflen >= newTotal)
1214-
*result = !!func(buffer + total, (const uint8_t *)ptr, chunkLen);
1211+
*result = !!func(buffer == NULL ? buffer : buffer + total, (const uint8_t *)ptr, chunkLen);
12151212
else
12161213
*result = false;
12171214

@@ -1221,7 +1218,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
12211218
/* is there enough room for the ending NUL byte? */
12221219
if (*result && *buflen > total) {
12231220
uint8_t nul[] = { 0 };
1224-
*result = !!func(buffer + total, nul, 1);
1221+
*result = !!func(buffer == NULL ? buffer : buffer + total, nul, 1);
12251222
}
12261223
*buflen = total;
12271224
return _cbor_value_finish_string_iteration(next);
@@ -1243,10 +1240,10 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
12431240
* of the string in order to preallocate a buffer, use
12441241
* cbor_value_calculate_string_length().
12451242
*
1246-
* On success, this function sets the number of bytes copied to \c{*buflen}. If
1243+
* On success, this function sets the number of bytes copied to \c *buflen. If
12471244
* the buffer is large enough, this function will insert a null byte after the
12481245
* last copied byte, to facilitate manipulation of text strings. That byte is
1249-
* not included in the returned value of \c{*buflen}. If there was no space for
1246+
* not included in the returned value of \c *buflen. If there was no space for
12501247
* the terminating null, no error is returned, so callers must check the value
12511248
* of *buflen after the call, before relying on the '\0'; if it has not been
12521249
* changed by the call, there is no '\0'-termination on the buffer's contents.
@@ -1280,10 +1277,10 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
12801277
* of the string in order to preallocate a buffer, use
12811278
* cbor_value_calculate_string_length().
12821279
*
1283-
* On success, this function sets the number of bytes copied to \c{*buflen}. If
1280+
* On success, this function sets the number of bytes copied to \c *buflen. If
12841281
* the buffer is large enough, this function will insert a null byte after the
12851282
* last copied byte, to facilitate manipulation of null-terminated strings.
1286-
* That byte is not included in the returned value of \c{*buflen}.
1283+
* That byte is not included in the returned value of \c *buflen.
12871284
*
12881285
* The \a next pointer, if not null, will be updated to point to the next item
12891286
* after this string. If \a value points to the last item, then \a next will be
@@ -1520,7 +1517,7 @@ CborError cbor_value_map_find_value(const CborValue *map, const char *string, Cb
15201517
* cbor_value_is_half_float is recommended.
15211518
*
15221519
* Note: since the C language does not have a standard type for half-precision
1523-
* floating point, this function takes a \c{void *} as a parameter for the
1520+
* floating point, this function takes a <tt>void *</tt> as a parameter for the
15241521
* storage area, which must be at least 16 bits wide.
15251522
*
15261523
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_half_float(), cbor_value_get_half_float_as_float(), cbor_value_get_float()

0 commit comments

Comments
 (0)