changing {} style to match majority of previous style

This commit is contained in:
Philippe Teuwen 2019-03-10 11:20:22 +01:00
commit 961d929f4d
320 changed files with 5502 additions and 10485 deletions

View file

@ -246,18 +246,15 @@ CBOR_API CborError cbor_encoder_create_map(CborEncoder *encoder, CborEncoder *ma
CBOR_API CborError cbor_encoder_close_container(CborEncoder *encoder, const CborEncoder *containerEncoder);
CBOR_API CborError cbor_encoder_close_container_checked(CborEncoder *encoder, const CborEncoder *containerEncoder);
CBOR_INLINE_API uint8_t *_cbor_encoder_get_buffer_pointer(const CborEncoder *encoder)
{
CBOR_INLINE_API uint8_t *_cbor_encoder_get_buffer_pointer(const CborEncoder *encoder) {
return encoder->data.ptr;
}
CBOR_INLINE_API size_t cbor_encoder_get_buffer_size(const CborEncoder *encoder, const uint8_t *buffer)
{
CBOR_INLINE_API size_t cbor_encoder_get_buffer_size(const CborEncoder *encoder, const uint8_t *buffer) {
return (size_t)(encoder->data.ptr - buffer);
}
CBOR_INLINE_API size_t cbor_encoder_get_extra_bytes_needed(const CborEncoder *encoder)
{
CBOR_INLINE_API size_t cbor_encoder_get_extra_bytes_needed(const CborEncoder *encoder) {
return encoder->end ? 0 : (size_t)encoder->data.bytes_needed;
}
@ -303,8 +300,7 @@ CBOR_API CborError cbor_value_enter_container(const CborValue *it, CborValue *re
CBOR_API CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed);
CBOR_PRIVATE_API uint64_t _cbor_value_decode_int64_internal(const CborValue *value);
CBOR_INLINE_API uint64_t _cbor_value_extract_int64_helper(const CborValue *value)
{
CBOR_INLINE_API uint64_t _cbor_value_extract_int64_helper(const CborValue *value) {
return value->flags & CborIteratorFlag_IntegerValueTooLarge ?
_cbor_value_decode_int64_internal(value) : value->extra;
}
@ -323,8 +319,7 @@ CBOR_INLINE_API bool cbor_value_is_undefined(const CborValue *value)
/* Booleans */
CBOR_INLINE_API bool cbor_value_is_boolean(const CborValue *value)
{ return value->type == CborBooleanType; }
CBOR_INLINE_API CborError cbor_value_get_boolean(const CborValue *value, bool *result)
{
CBOR_INLINE_API CborError cbor_value_get_boolean(const CborValue *value, bool *result) {
assert(cbor_value_is_boolean(value));
*result = !!value->extra;
return CborNoError;
@ -333,8 +328,7 @@ CBOR_INLINE_API CborError cbor_value_get_boolean(const CborValue *value, bool *r
/* Simple types */
CBOR_INLINE_API bool cbor_value_is_simple_type(const CborValue *value)
{ return value->type == CborSimpleType; }
CBOR_INLINE_API CborError cbor_value_get_simple_type(const CborValue *value, uint8_t *result)
{
CBOR_INLINE_API CborError cbor_value_get_simple_type(const CborValue *value, uint8_t *result) {
assert(cbor_value_is_simple_type(value));
*result = (uint8_t)value->extra;
return CborNoError;
@ -348,22 +342,19 @@ CBOR_INLINE_API bool cbor_value_is_unsigned_integer(const CborValue *value)
CBOR_INLINE_API bool cbor_value_is_negative_integer(const CborValue *value)
{ return cbor_value_is_integer(value) && (value->flags & CborIteratorFlag_NegativeInteger); }
CBOR_INLINE_API CborError cbor_value_get_raw_integer(const CborValue *value, uint64_t *result)
{
CBOR_INLINE_API CborError cbor_value_get_raw_integer(const CborValue *value, uint64_t *result) {
assert(cbor_value_is_integer(value));
*result = _cbor_value_extract_int64_helper(value);
return CborNoError;
}
CBOR_INLINE_API CborError cbor_value_get_uint64(const CborValue *value, uint64_t *result)
{
CBOR_INLINE_API CborError cbor_value_get_uint64(const CborValue *value, uint64_t *result) {
assert(cbor_value_is_unsigned_integer(value));
*result = _cbor_value_extract_int64_helper(value);
return CborNoError;
}
CBOR_INLINE_API CborError cbor_value_get_int64(const CborValue *value, int64_t *result)
{
CBOR_INLINE_API CborError cbor_value_get_int64(const CborValue *value, int64_t *result) {
assert(cbor_value_is_integer(value));
*result = (int64_t) _cbor_value_extract_int64_helper(value);
if (value->flags & CborIteratorFlag_NegativeInteger)
@ -371,8 +362,7 @@ CBOR_INLINE_API CborError cbor_value_get_int64(const CborValue *value, int64_t *
return CborNoError;
}
CBOR_INLINE_API CborError cbor_value_get_int(const CborValue *value, int *result)
{
CBOR_INLINE_API CborError cbor_value_get_int(const CborValue *value, int *result) {
assert(cbor_value_is_integer(value));
*result = (int) _cbor_value_extract_int64_helper(value);
if (value->flags & CborIteratorFlag_NegativeInteger)
@ -389,8 +379,7 @@ CBOR_INLINE_API bool cbor_value_is_length_known(const CborValue *value)
/* Tags */
CBOR_INLINE_API bool cbor_value_is_tag(const CborValue *value)
{ return value->type == CborTagType; }
CBOR_INLINE_API CborError cbor_value_get_tag(const CborValue *value, CborTag *result)
{
CBOR_INLINE_API CborError cbor_value_get_tag(const CborValue *value, CborTag *result) {
assert(cbor_value_is_tag(value));
*result = _cbor_value_extract_int64_helper(value);
return CborNoError;
@ -403,8 +392,7 @@ CBOR_INLINE_API bool cbor_value_is_byte_string(const CborValue *value)
CBOR_INLINE_API bool cbor_value_is_text_string(const CborValue *value)
{ return value->type == CborTextStringType; }
CBOR_INLINE_API CborError cbor_value_get_string_length(const CborValue *value, size_t *length)
{
CBOR_INLINE_API CborError cbor_value_get_string_length(const CborValue *value, size_t *length) {
uint64_t v;
assert(cbor_value_is_byte_string(value) || cbor_value_is_text_string(value));
if (!cbor_value_is_length_known(value))
@ -424,27 +412,23 @@ CBOR_PRIVATE_API CborError _cbor_value_dup_string(const CborValue *value, void *
CBOR_API CborError cbor_value_calculate_string_length(const CborValue *value, size_t *length);
CBOR_INLINE_API CborError cbor_value_copy_text_string(const CborValue *value, char *buffer,
size_t *buflen, CborValue *next)
{
size_t *buflen, CborValue *next) {
assert(cbor_value_is_text_string(value));
return _cbor_value_copy_string(value, buffer, buflen, next);
}
CBOR_INLINE_API CborError cbor_value_copy_byte_string(const CborValue *value, uint8_t *buffer,
size_t *buflen, CborValue *next)
{
size_t *buflen, CborValue *next) {
assert(cbor_value_is_byte_string(value));
return _cbor_value_copy_string(value, buffer, buflen, next);
}
CBOR_INLINE_API CborError cbor_value_dup_text_string(const CborValue *value, char **buffer,
size_t *buflen, CborValue *next)
{
size_t *buflen, CborValue *next) {
assert(cbor_value_is_text_string(value));
return _cbor_value_dup_string(value, (void **)buffer, buflen, next);
}
CBOR_INLINE_API CborError cbor_value_dup_byte_string(const CborValue *value, uint8_t **buffer,
size_t *buflen, CborValue *next)
{
size_t *buflen, CborValue *next) {
assert(cbor_value_is_byte_string(value));
return _cbor_value_dup_string(value, (void **)buffer, buflen, next);
}
@ -457,8 +441,7 @@ CBOR_INLINE_API bool cbor_value_is_array(const CborValue *value)
CBOR_INLINE_API bool cbor_value_is_map(const CborValue *value)
{ return value->type == CborMapType; }
CBOR_INLINE_API CborError cbor_value_get_array_length(const CborValue *value, size_t *length)
{
CBOR_INLINE_API CborError cbor_value_get_array_length(const CborValue *value, size_t *length) {
uint64_t v;
assert(cbor_value_is_array(value));
if (!cbor_value_is_length_known(value))
@ -470,8 +453,7 @@ CBOR_INLINE_API CborError cbor_value_get_array_length(const CborValue *value, si
return CborNoError;
}
CBOR_INLINE_API CborError cbor_value_get_map_length(const CborValue *value, size_t *length)
{
CBOR_INLINE_API CborError cbor_value_get_map_length(const CborValue *value, size_t *length) {
uint64_t v;
assert(cbor_value_is_map(value));
if (!cbor_value_is_length_known(value))
@ -492,8 +474,7 @@ CBOR_API CborError cbor_value_get_half_float(const CborValue *value, void *resul
CBOR_INLINE_API bool cbor_value_is_float(const CborValue *value)
{ return value->type == CborFloatType; }
CBOR_INLINE_API CborError cbor_value_get_float(const CborValue *value, float *result)
{
CBOR_INLINE_API CborError cbor_value_get_float(const CborValue *value, float *result) {
uint32_t data;
assert(cbor_value_is_float(value));
assert(value->flags & CborIteratorFlag_IntegerValueTooLarge);
@ -504,8 +485,7 @@ CBOR_INLINE_API CborError cbor_value_get_float(const CborValue *value, float *re
CBOR_INLINE_API bool cbor_value_is_double(const CborValue *value)
{ return value->type == CborDoubleType; }
CBOR_INLINE_API CborError cbor_value_get_double(const CborValue *value, double *result)
{
CBOR_INLINE_API CborError cbor_value_get_double(const CborValue *value, double *result) {
uint64_t data;
assert(cbor_value_is_double(value));
assert(value->flags & CborIteratorFlag_IntegerValueTooLarge);
@ -587,8 +567,7 @@ CBOR_API CborError cbor_value_to_pretty_stream(CborStreamFunction streamFunction
#if !defined(__STDC_HOSTED__) || __STDC_HOSTED__-0 == 1
CBOR_API CborError cbor_value_to_pretty_advance_flags(FILE *out, CborValue *value, int flags);
CBOR_API CborError cbor_value_to_pretty_advance(FILE *out, CborValue *value);
CBOR_INLINE_API CborError cbor_value_to_pretty(FILE *out, const CborValue *value)
{
CBOR_INLINE_API CborError cbor_value_to_pretty(FILE *out, const CborValue *value) {
CborValue copy = *value;
return cbor_value_to_pretty_advance_flags(out, &copy, CborPrettyDefaultFlags);
}

View file

@ -200,16 +200,14 @@
* buffer of size \a size. The \a flags field is currently unused and must be
* zero.
*/
void cbor_encoder_init(CborEncoder *encoder, uint8_t *buffer, size_t size, int flags)
{
void cbor_encoder_init(CborEncoder *encoder, uint8_t *buffer, size_t size, int flags) {
encoder->data.ptr = buffer;
encoder->end = buffer + size;
encoder->remaining = 2;
encoder->flags = flags;
}
static inline void put16(void *where, uint16_t v)
{
static inline void put16(void *where, uint16_t v) {
v = cbor_htons(v);
memcpy(where, &v, sizeof(v));
}
@ -219,42 +217,36 @@ static inline void put16(void *where, uint16_t v)
* but if in the future, any function starts returning a non-OOM error, this will need
* to be changed to the test. At the moment, this is done to prevent more branches
* being created in the tinycbor output */
static inline bool isOomError(CborError err)
{
static inline bool isOomError(CborError err) {
(void) err;
return true;
}
static inline void put32(void *where, uint32_t v)
{
static inline void put32(void *where, uint32_t v) {
v = cbor_htonl(v);
memcpy(where, &v, sizeof(v));
}
static inline void put64(void *where, uint64_t v)
{
static inline void put64(void *where, uint64_t v) {
v = cbor_htonll(v);
memcpy(where, &v, sizeof(v));
}
static inline bool would_overflow(CborEncoder *encoder, size_t len)
{
static inline bool would_overflow(CborEncoder *encoder, size_t len) {
ptrdiff_t remaining = (ptrdiff_t)encoder->end;
remaining -= remaining ? (ptrdiff_t)encoder->data.ptr : encoder->data.bytes_needed;
remaining -= (ptrdiff_t)len;
return unlikely(remaining < 0);
}
static inline void advance_ptr(CborEncoder *encoder, size_t n)
{
static inline void advance_ptr(CborEncoder *encoder, size_t n) {
if (encoder->end)
encoder->data.ptr += n;
else
encoder->data.bytes_needed += n;
}
static inline CborError append_to_buffer(CborEncoder *encoder, const void *data, size_t len)
{
static inline CborError append_to_buffer(CborEncoder *encoder, const void *data, size_t len) {
if (would_overflow(encoder, len)) {
if (encoder->end != NULL) {
len -= encoder->end - encoder->data.ptr;
@ -271,13 +263,11 @@ static inline CborError append_to_buffer(CborEncoder *encoder, const void *data,
return CborNoError;
}
static inline CborError append_byte_to_buffer(CborEncoder *encoder, uint8_t byte)
{
static inline CborError append_byte_to_buffer(CborEncoder *encoder, uint8_t byte) {
return append_to_buffer(encoder, &byte, 1);
}
static inline CborError encode_number_no_update(CborEncoder *encoder, uint64_t ui, uint8_t shiftedMajorType)
{
static inline CborError encode_number_no_update(CborEncoder *encoder, uint64_t ui, uint8_t shiftedMajorType) {
/* Little-endian would have been so much more convenient here:
* We could just write at the beginning of buf but append_to_buffer
* only the necessary bytes.
@ -305,14 +295,12 @@ static inline CborError encode_number_no_update(CborEncoder *encoder, uint64_t u
return append_to_buffer(encoder, bufstart, bufend - bufstart);
}
static inline void saturated_decrement(CborEncoder *encoder)
{
static inline void saturated_decrement(CborEncoder *encoder) {
if (encoder->remaining)
--encoder->remaining;
}
static inline CborError encode_number(CborEncoder *encoder, uint64_t ui, uint8_t shiftedMajorType)
{
static inline CborError encode_number(CborEncoder *encoder, uint64_t ui, uint8_t shiftedMajorType) {
saturated_decrement(encoder);
return encode_number_no_update(encoder, ui, shiftedMajorType);
}
@ -323,8 +311,7 @@ static inline CborError encode_number(CborEncoder *encoder, uint64_t ui, uint8_t
*
* \sa cbor_encode_negative_int, cbor_encode_int
*/
CborError cbor_encode_uint(CborEncoder *encoder, uint64_t value)
{
CborError cbor_encode_uint(CborEncoder *encoder, uint64_t value) {
return encode_number(encoder, value, UnsignedIntegerType << MajorTypeShift);
}
@ -336,8 +323,7 @@ CborError cbor_encode_uint(CborEncoder *encoder, uint64_t value)
*
* \sa cbor_encode_uint, cbor_encode_int
*/
CborError cbor_encode_negative_int(CborEncoder *encoder, uint64_t absolute_value)
{
CborError cbor_encode_negative_int(CborEncoder *encoder, uint64_t absolute_value) {
return encode_number(encoder, absolute_value - 1, NegativeIntegerType << MajorTypeShift);
}
@ -347,8 +333,7 @@ CborError cbor_encode_negative_int(CborEncoder *encoder, uint64_t absolute_value
*
* \sa cbor_encode_negative_int, cbor_encode_uint
*/
CborError cbor_encode_int(CborEncoder *encoder, int64_t value)
{
CborError cbor_encode_int(CborEncoder *encoder, int64_t value) {
/* adapted from code in RFC 7049 appendix C (pseudocode) */
uint64_t ui = value >> 63; /* extend sign to whole length */
uint8_t majorType = ui & 0x20; /* extract major type */
@ -363,8 +348,7 @@ CborError cbor_encode_int(CborEncoder *encoder, int64_t value)
* This function may return error CborErrorIllegalSimpleType if the \a value
* variable contains a number that is not a valid simple type.
*/
CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value)
{
CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value) {
#ifndef CBOR_ENCODER_NO_CHECK_USER
/* check if this is a valid simple type */
if (value >= HalfPrecisionFloat && value <= Break)
@ -384,8 +368,7 @@ CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value)
*
* \sa cbor_encode_half_float, cbor_encode_float, cbor_encode_double
*/
CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, const void *value)
{
CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, const void *value) {
unsigned size;
uint8_t buf[1 + sizeof(uint64_t)];
cbor_assert(fpType == CborHalfFloatType || fpType == CborFloatType || fpType == CborDoubleType);
@ -407,14 +390,12 @@ CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, cons
*
* \sa CborTag
*/
CborError cbor_encode_tag(CborEncoder *encoder, CborTag tag)
{
CborError cbor_encode_tag(CborEncoder *encoder, CborTag tag) {
/* tags don't count towards the number of elements in an array or map */
return encode_number_no_update(encoder, tag, TagType << MajorTypeShift);
}
static CborError encode_string(CborEncoder *encoder, size_t length, uint8_t shiftedMajorType, const void *string)
{
static CborError encode_string(CborEncoder *encoder, size_t length, uint8_t shiftedMajorType, const void *string) {
CborError err = encode_number(encoder, length, shiftedMajorType);
if (err && !isOomError(err))
return err;
@ -439,8 +420,7 @@ static CborError encode_string(CborEncoder *encoder, size_t length, uint8_t shif
*
* \sa CborError cbor_encode_text_stringz, cbor_encode_byte_string
*/
CborError cbor_encode_byte_string(CborEncoder *encoder, const uint8_t *string, size_t length)
{
CborError cbor_encode_byte_string(CborEncoder *encoder, const uint8_t *string, size_t length) {
return encode_string(encoder, length, ByteStringType << MajorTypeShift, string);
}
@ -450,16 +430,14 @@ CborError cbor_encode_byte_string(CborEncoder *encoder, const uint8_t *string, s
*
* \sa cbor_encode_text_stringz, cbor_encode_text_string
*/
CborError cbor_encode_text_string(CborEncoder *encoder, const char *string, size_t length)
{
CborError cbor_encode_text_string(CborEncoder *encoder, const char *string, size_t length) {
return encode_string(encoder, length, TextStringType << MajorTypeShift, string);
}
#ifdef __GNUC__
__attribute__((noinline))
#endif
static CborError create_container(CborEncoder *encoder, CborEncoder *container, size_t length, uint8_t shiftedMajorType)
{
static CborError create_container(CborEncoder *encoder, CborEncoder *container, size_t length, uint8_t shiftedMajorType) {
CborError err;
container->data.ptr = encoder->data.ptr;
container->end = encoder->end;
@ -495,8 +473,7 @@ static CborError create_container(CborEncoder *encoder, CborEncoder *container,
*
* \sa cbor_encoder_create_map
*/
CborError cbor_encoder_create_array(CborEncoder *encoder, CborEncoder *arrayEncoder, size_t length)
{
CborError cbor_encoder_create_array(CborEncoder *encoder, CborEncoder *arrayEncoder, size_t length) {
return create_container(encoder, arrayEncoder, length, ArrayType << MajorTypeShift);
}
@ -519,8 +496,7 @@ CborError cbor_encoder_create_array(CborEncoder *encoder, CborEncoder *arrayEnco
*
* \sa cbor_encoder_create_array
*/
CborError cbor_encoder_create_map(CborEncoder *encoder, CborEncoder *mapEncoder, size_t length)
{
CborError cbor_encoder_create_map(CborEncoder *encoder, CborEncoder *mapEncoder, size_t length) {
if (length != CborIndefiniteLength && length > SIZE_MAX / 2)
return CborErrorDataTooLarge;
return create_container(encoder, mapEncoder, length, MapType << MajorTypeShift);
@ -538,8 +514,7 @@ CborError cbor_encoder_create_map(CborEncoder *encoder, CborEncoder *mapEncoder,
*
* \sa cbor_encoder_create_array(), cbor_encoder_create_map()
*/
CborError cbor_encoder_close_container(CborEncoder *encoder, const CborEncoder *containerEncoder)
{
CborError cbor_encoder_close_container(CborEncoder *encoder, const CborEncoder *containerEncoder) {
if (encoder->end)
encoder->data.ptr = containerEncoder->data.ptr;
else

View file

@ -49,8 +49,7 @@
*
* \sa cbor_encoder_create_array(), cbor_encoder_create_map()
*/
CborError cbor_encoder_close_container_checked(CborEncoder *encoder, const CborEncoder *containerEncoder)
{
CborError cbor_encoder_close_container_checked(CborEncoder *encoder, const CborEncoder *containerEncoder) {
return cbor_encoder_close_container(encoder, containerEncoder);
}

View file

@ -77,8 +77,7 @@
* \ingroup CborGlobals
* Returns the error string corresponding to the CBOR error condition \a error.
*/
const char *cbor_error_string(CborError error)
{
const char *cbor_error_string(CborError error) {
switch (error) {
case CborNoError:
return "";

View file

@ -39,18 +39,15 @@
#ifndef CBOR_NO_HALF_FLOAT_TYPE
# ifdef __F16C__
# include <immintrin.h>
static inline unsigned short encode_half(double val)
{
static inline unsigned short encode_half(double val) {
return _cvtss_sh((float)val, 3);
}
static inline double decode_half(unsigned short half)
{
static inline double decode_half(unsigned short half) {
return _cvtsh_ss(half);
}
# else
/* software implementation of float-to-fp16 conversions */
static inline unsigned short encode_half(double val)
{
static inline unsigned short encode_half(double val) {
uint64_t v;
int sign, exp, mant;
memcpy(&v, &val, sizeof(v));
@ -83,8 +80,7 @@ static inline unsigned short encode_half(double val)
}
/* this function was copied & adapted from RFC 7049 Appendix D */
static inline double decode_half(unsigned short half)
{
static inline double decode_half(unsigned short half) {
int exp = (half >> 10) & 0x1f;
int mant = half & 0x3ff;
double val;

View file

@ -47,8 +47,7 @@ enum CborToJsonFlags {
};
CBOR_API CborError cbor_value_to_json_advance(FILE *out, CborValue *value, int flags);
CBOR_INLINE_API CborError cbor_value_to_json(FILE *out, const CborValue *value, int flags)
{
CBOR_INLINE_API CborError cbor_value_to_json(FILE *out, const CborValue *value, int flags) {
CborValue copy = *value;
return cbor_value_to_json_advance(out, &copy, flags);
}

View file

@ -142,29 +142,25 @@
* \endif
*/
static inline uint16_t get16(const uint8_t *ptr)
{
static inline uint16_t get16(const uint8_t *ptr) {
uint16_t result;
memcpy(&result, ptr, sizeof(result));
return cbor_ntohs(result);
}
static inline uint32_t get32(const uint8_t *ptr)
{
static inline uint32_t get32(const uint8_t *ptr) {
uint32_t result;
memcpy(&result, ptr, sizeof(result));
return cbor_ntohl(result);
}
static inline uint64_t get64(const uint8_t *ptr)
{
static inline uint64_t get64(const uint8_t *ptr) {
uint64_t result;
memcpy(&result, ptr, sizeof(result));
return cbor_ntohll(result);
}
CborError CBOR_INTERNAL_API_CC _cbor_value_extract_number(const uint8_t **ptr, const uint8_t *end, uint64_t *len)
{
CborError CBOR_INTERNAL_API_CC _cbor_value_extract_number(const uint8_t **ptr, const uint8_t *end, uint64_t *len) {
size_t bytesNeeded;
uint8_t additional_information = **ptr & SmallValueMask;
++*ptr;
@ -191,8 +187,7 @@ CborError CBOR_INTERNAL_API_CC _cbor_value_extract_number(const uint8_t **ptr, c
return CborNoError;
}
static CborError extract_length(const CborParser *parser, const uint8_t **ptr, size_t *len)
{
static CborError extract_length(const CborParser *parser, const uint8_t **ptr, size_t *len) {
uint64_t v;
CborError err = _cbor_value_extract_number(ptr, parser->end, &v);
if (err) {
@ -206,14 +201,12 @@ static CborError extract_length(const CborParser *parser, const uint8_t **ptr, s
return CborNoError;
}
static bool is_fixed_type(uint8_t type)
{
static bool is_fixed_type(uint8_t type) {
return type != CborTextStringType && type != CborByteStringType && type != CborArrayType &&
type != CborMapType;
}
static CborError preparse_value(CborValue *it)
{
static CborError preparse_value(CborValue *it) {
const CborParser *parser = it->parser;
it->type = CborInvalidType;
@ -298,8 +291,7 @@ static CborError preparse_value(CborValue *it)
return CborNoError;
}
static CborError preparse_next_value_nodecrement(CborValue *it)
{
static CborError preparse_next_value_nodecrement(CborValue *it) {
if (it->remaining == UINT32_MAX && it->ptr != it->parser->end && *it->ptr == (uint8_t)BreakByte) {
/* end of map or array */
++it->ptr;
@ -311,8 +303,7 @@ static CborError preparse_next_value_nodecrement(CborValue *it)
return preparse_value(it);
}
static CborError preparse_next_value(CborValue *it)
{
static CborError preparse_next_value(CborValue *it) {
if (it->remaining != UINT32_MAX) {
/* don't decrement the item count if the current item is tag: they don't count */
if (it->type != CborTagType && --it->remaining == 0) {
@ -323,8 +314,7 @@ static CborError preparse_next_value(CborValue *it)
return preparse_next_value_nodecrement(it);
}
static CborError advance_internal(CborValue *it)
{
static CborError advance_internal(CborValue *it) {
uint64_t length;
CborError err = _cbor_value_extract_number(&it->ptr, it->parser->end, &length);
cbor_assert(err == CborNoError);
@ -348,8 +338,7 @@ static CborError advance_internal(CborValue *it)
* point values (SinglePrecisionFloat == Value32Bit and DoublePrecisionFloat ==
* Value64Bit).
*/
uint64_t _cbor_value_decode_int64_internal(const CborValue *value)
{
uint64_t _cbor_value_decode_int64_internal(const CborValue *value) {
cbor_assert(value->flags & CborIteratorFlag_IntegerValueTooLarge ||
value->type == CborFloatType || value->type == CborDoubleType);
@ -373,8 +362,7 @@ uint64_t _cbor_value_decode_int64_internal(const CborValue *value)
* threads iterating at the same time, but the object can be copied so multiple
* threads can iterate.
*/
CborError cbor_parser_init(const uint8_t *buffer, size_t size, uint32_t flags, CborParser *parser, CborValue *it)
{
CborError cbor_parser_init(const uint8_t *buffer, size_t size, uint32_t flags, CborParser *parser, CborValue *it) {
memset(parser, 0, sizeof(*parser));
parser->end = buffer + size;
parser->flags = flags;
@ -448,8 +436,7 @@ CborError cbor_parser_init(const uint8_t *buffer, size_t size, uint32_t flags, C
*
* \sa cbor_value_validate(), cbor_value_advance()
*/
CborError cbor_value_validate_basic(const CborValue *it)
{
CborError cbor_value_validate_basic(const CborValue *it) {
CborValue value = *it;
return cbor_value_advance(&value);
}
@ -469,8 +456,7 @@ CborError cbor_value_validate_basic(const CborValue *it)
*
* \sa cbor_value_at_end(), cbor_value_advance(), cbor_value_enter_container(), cbor_value_leave_container()
*/
CborError cbor_value_advance_fixed(CborValue *it)
{
CborError cbor_value_advance_fixed(CborValue *it) {
cbor_assert(it->type != CborInvalidType);
cbor_assert(is_fixed_type(it->type));
if (!it->remaining)
@ -478,8 +464,7 @@ CborError cbor_value_advance_fixed(CborValue *it)
return advance_internal(it);
}
static CborError advance_recursive(CborValue *it, int nestingLevel)
{
static CborError advance_recursive(CborValue *it, int nestingLevel) {
CborError err;
CborValue recursed;
@ -521,8 +506,7 @@ static CborError advance_recursive(CborValue *it, int nestingLevel)
*
* \sa cbor_value_at_end(), cbor_value_advance_fixed(), cbor_value_enter_container(), cbor_value_leave_container()
*/
CborError cbor_value_advance(CborValue *it)
{
CborError cbor_value_advance(CborValue *it) {
cbor_assert(it->type != CborInvalidType);
if (!it->remaining)
return CborErrorAdvancePastEOF;
@ -557,8 +541,7 @@ CborError cbor_value_advance(CborValue *it)
*
* \sa cbor_value_advance_fixed(), cbor_value_advance()
*/
CborError cbor_value_skip_tag(CborValue *it)
{
CborError cbor_value_skip_tag(CborValue *it) {
while (cbor_value_is_tag(it)) {
CborError err = cbor_value_advance_fixed(it);
if (err)
@ -584,8 +567,7 @@ CborError cbor_value_skip_tag(CborValue *it)
*
* \sa cbor_value_is_container(), cbor_value_leave_container(), cbor_value_advance()
*/
CborError cbor_value_enter_container(const CborValue *it, CborValue *recursed)
{
CborError cbor_value_enter_container(const CborValue *it, CborValue *recursed) {
cbor_assert(cbor_value_is_container(it));
*recursed = *it;
@ -633,8 +615,7 @@ CborError cbor_value_enter_container(const CborValue *it, CborValue *recursed)
*
* \sa cbor_value_enter_container(), cbor_value_at_end()
*/
CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
{
CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed) {
cbor_assert(cbor_value_is_container(it));
cbor_assert(recursed->type == CborInvalidType);
it->ptr = recursed->ptr;
@ -815,8 +796,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
*
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer(), cbor_value_get_int64()
*/
CborError cbor_value_get_int64_checked(const CborValue *value, int64_t *result)
{
CborError cbor_value_get_int64_checked(const CborValue *value, int64_t *result) {
uint64_t v;
cbor_assert(cbor_value_is_integer(value));
v = _cbor_value_extract_int64_helper(value);
@ -855,8 +835,7 @@ CborError cbor_value_get_int64_checked(const CborValue *value, int64_t *result)
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer(), cbor_value_get_int64(),
* cbor_value_get_uint64(), cbor_value_get_int64_checked(), cbor_value_get_raw_integer()
*/
CborError cbor_value_get_int_checked(const CborValue *value, int *result)
{
CborError cbor_value_get_int_checked(const CborValue *value, int *result) {
uint64_t v;
cbor_assert(cbor_value_is_integer(value));
v = _cbor_value_extract_int64_helper(value);
@ -966,14 +945,12 @@ CborError cbor_value_get_int_checked(const CborValue *value, int *result)
*
* \sa cbor_value_get_string_length(), cbor_value_copy_text_string(), cbor_value_copy_byte_string(), cbor_value_is_length_known()
*/
CborError cbor_value_calculate_string_length(const CborValue *value, size_t *len)
{
CborError cbor_value_calculate_string_length(const CborValue *value, size_t *len) {
*len = SIZE_MAX;
return _cbor_value_copy_string(value, NULL, len, NULL);
}
static inline void prepare_string_iteration(CborValue *it)
{
static inline void prepare_string_iteration(CborValue *it) {
if (!cbor_value_is_length_known(it)) {
/* chunked string: we're before the first chunk;
* advance to the first chunk */
@ -982,8 +959,7 @@ static inline void prepare_string_iteration(CborValue *it)
}
}
CborError CBOR_INTERNAL_API_CC _cbor_value_prepare_string_iteration(CborValue *it)
{
CborError CBOR_INTERNAL_API_CC _cbor_value_prepare_string_iteration(CborValue *it) {
cbor_assert((it->flags & CborIteratorFlag_IteratingStringChunks) == 0);
prepare_string_iteration(it);
@ -993,8 +969,7 @@ CborError CBOR_INTERNAL_API_CC _cbor_value_prepare_string_iteration(CborValue *i
return CborNoError;
}
static CborError get_string_chunk(CborValue *it, const void **bufferptr, size_t *len)
{
static CborError get_string_chunk(CborValue *it, const void **bufferptr, size_t *len) {
CborError err;
/* Possible states:
@ -1044,8 +1019,7 @@ last_chunk:
CborError CBOR_INTERNAL_API_CC
_cbor_value_get_string_chunk(const CborValue *value, const void **bufferptr,
size_t *len, CborValue *next)
{
size_t *len, CborValue *next) {
CborValue tmp;
if (!next)
next = &tmp;
@ -1059,27 +1033,23 @@ _cbor_value_get_string_chunk(const CborValue *value, const void **bufferptr,
* only. */
typedef uintptr_t (*IterateFunction)(char *, const uint8_t *, size_t);
static uintptr_t iterate_noop(char *dest, const uint8_t *src, size_t len)
{
static uintptr_t iterate_noop(char *dest, const uint8_t *src, size_t len) {
(void)dest;
(void)src;
(void)len;
return true;
}
static uintptr_t iterate_memcmp(char *s1, const uint8_t *s2, size_t len)
{
static uintptr_t iterate_memcmp(char *s1, const uint8_t *s2, size_t len) {
return memcmp(s1, (const char *)s2, len) == 0;
}
static uintptr_t iterate_memcpy(char *dest, const uint8_t *src, size_t len)
{
static uintptr_t iterate_memcpy(char *dest, const uint8_t *src, size_t len) {
return (uintptr_t)memcpy(dest, src, len);
}
static CborError iterate_string_chunks(const CborValue *value, char *buffer, size_t *buflen,
bool *result, CborValue *next, IterateFunction func)
{
bool *result, CborValue *next, IterateFunction func) {
CborError err;
CborValue tmp;
size_t total = 0;
@ -1189,8 +1159,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
*/
CborError _cbor_value_copy_string(const CborValue *value, void *buffer,
size_t *buflen, CborValue *next)
{
size_t *buflen, CborValue *next) {
bool copied_all;
CborError err = iterate_string_chunks(value, (char *)buffer, buflen, &copied_all, next,
buffer ? iterate_memcpy : iterate_noop);
@ -1216,8 +1185,7 @@ CborError _cbor_value_copy_string(const CborValue *value, void *buffer,
*
* \sa cbor_value_skip_tag(), cbor_value_copy_text_string()
*/
CborError cbor_value_text_string_equals(const CborValue *value, const char *string, bool *result)
{
CborError cbor_value_text_string_equals(const CborValue *value, const char *string, bool *result) {
size_t len;
CborValue copy = *value;
CborError err = cbor_value_skip_tag(&copy);
@ -1304,8 +1272,7 @@ CborError cbor_value_text_string_equals(const CborValue *value, const char *stri
*
* \sa cbor_value_is_valid(), cbor_value_text_string_equals(), cbor_value_advance()
*/
CborError cbor_value_map_find_value(const CborValue *map, const char *string, CborValue *element)
{
CborError cbor_value_map_find_value(const CborValue *map, const char *string, CborValue *element) {
CborError err;
size_t len = strlen(string);
cbor_assert(cbor_value_is_map(map));
@ -1416,8 +1383,7 @@ error:
*
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_half_float(), cbor_value_get_float()
*/
CborError cbor_value_get_half_float(const CborValue *value, void *result)
{
CborError cbor_value_get_half_float(const CborValue *value, void *result) {
uint16_t v;
cbor_assert(cbor_value_is_half_float(value));

View file

@ -94,8 +94,7 @@
*
* \sa cbor_value_get_text_string_chunk(), cbor_value_copy_byte_string(), cbor_value_dup_text_string()
*/
CborError _cbor_value_dup_string(const CborValue *value, void **buffer, size_t *buflen, CborValue *next)
{
CborError _cbor_value_dup_string(const CborValue *value, void **buffer, size_t *buflen, CborValue *next) {
CborError err;
cbor_assert(buffer);
cbor_assert(buflen);

View file

@ -145,8 +145,7 @@
*/
#ifndef CBOR_NO_FLOATING_POINT
static inline bool convertToUint64(double v, uint64_t *absolute)
{
static inline bool convertToUint64(double v, uint64_t *absolute) {
double supremum;
v = fabs(v);
@ -177,13 +176,11 @@ static inline bool convertToUint64(double v, uint64_t *absolute)
}
#endif
static void printRecursionLimit(CborStreamFunction stream, void *out)
{
static void printRecursionLimit(CborStreamFunction stream, void *out) {
stream(out, "<nesting too deep, recursion stopped>");
}
static CborError hexDump(CborStreamFunction stream, void *out, const void *ptr, size_t n)
{
static CborError hexDump(CborStreamFunction stream, void *out, const void *ptr, size_t n) {
const uint8_t *buffer = (const uint8_t *)ptr;
CborError err = CborNoError;
while (n-- && !err)
@ -194,8 +191,7 @@ static CborError hexDump(CborStreamFunction stream, void *out, const void *ptr,
/* This function decodes buffer as UTF-8 and prints as escaped UTF-16.
* On UTF-8 decoding error, it returns CborErrorInvalidUtf8TextString */
static CborError utf8EscapedDump(CborStreamFunction stream, void *out, const void *ptr, size_t n)
{
static CborError utf8EscapedDump(CborStreamFunction stream, void *out, const void *ptr, size_t n) {
const uint8_t *buffer = (const uint8_t *)ptr;
const uint8_t *const end = buffer + n;
CborError err = CborNoError;
@ -255,8 +251,7 @@ print_utf16:
return err;
}
static const char *resolve_indicator(const uint8_t *ptr, const uint8_t *end, int flags)
{
static const char *resolve_indicator(const uint8_t *ptr, const uint8_t *end, int flags) {
static const char indicators[8][3] = {
"_0", "_1", "_2", "_3",
"", "", "", /* these are not possible */
@ -277,7 +272,7 @@ static const char *resolve_indicator(const uint8_t *ptr, const uint8_t *end, int
/* determine whether to show anything */
if ((flags & CborPrettyIndicateIndeterminateLength) &&
additional_information == IndefiniteLength)
additional_information == IndefiniteLength)
return indicators[IndefiniteLength - Value8Bit];
if ((flags & CborPrettyIndicateOverlongNumbers) == 0)
return no_indicator;
@ -300,15 +295,13 @@ static const char *resolve_indicator(const uint8_t *ptr, const uint8_t *end, int
indicators[additional_information - Value8Bit];
}
static const char *get_indicator(const CborValue *it, int flags)
{
static const char *get_indicator(const CborValue *it, int flags) {
return resolve_indicator(it->ptr, it->parser->end, flags);
}
static CborError value_to_pretty(CborStreamFunction stream, void *out, CborValue *it, int flags, int recursionsLeft);
static CborError container_to_pretty(CborStreamFunction stream, void *out, CborValue *it, CborType containerType,
int flags, int recursionsLeft)
{
int flags, int recursionsLeft) {
const char *comma = "";
CborError err = CborNoError;
@ -336,8 +329,7 @@ static CborError container_to_pretty(CborStreamFunction stream, void *out, CborV
return err;
}
static CborError value_to_pretty(CborStreamFunction stream, void *out, CborValue *it, int flags, int recursionsLeft)
{
static CborError value_to_pretty(CborStreamFunction stream, void *out, CborValue *it, int flags, int recursionsLeft) {
CborError err = CborNoError;
CborType type = cbor_value_get_type(it);
switch (type) {
@ -570,8 +562,7 @@ static CborError value_to_pretty(CborStreamFunction stream, void *out, CborValue
*
* \sa cbor_value_to_pretty(), cbor_value_to_json_advance()
*/
CborError cbor_value_to_pretty_stream(CborStreamFunction streamFunction, void *token, CborValue *value, int flags)
{
CborError cbor_value_to_pretty_stream(CborStreamFunction streamFunction, void *token, CborValue *value, int flags) {
return value_to_pretty(streamFunction, token, value, flags, CBOR_PARSER_MAX_RECURSIONS);
}

View file

@ -26,8 +26,7 @@
#include <stdarg.h>
#include <stdio.h>
static CborError cbor_fprintf(void *out, const char *fmt, ...)
{
static CborError cbor_fprintf(void *out, const char *fmt, ...) {
int n;
va_list list;
@ -60,8 +59,7 @@ static CborError cbor_fprintf(void *out, const char *fmt, ...)
*
* \sa cbor_value_to_pretty(), cbor_value_to_pretty_stream(), cbor_value_to_json_advance()
*/
CborError cbor_value_to_pretty_advance(FILE *out, CborValue *value)
{
CborError cbor_value_to_pretty_advance(FILE *out, CborValue *value) {
return cbor_value_to_pretty_stream(cbor_fprintf, out, value, CborPrettyDefaultFlags);
}
@ -80,8 +78,7 @@ CborError cbor_value_to_pretty_advance(FILE *out, CborValue *value)
*
* \sa cbor_value_to_pretty_stream(), cbor_value_to_pretty(), cbor_value_to_json_advance()
*/
CborError cbor_value_to_pretty_advance_flags(FILE *out, CborValue *value, int flags)
{
CborError cbor_value_to_pretty_advance_flags(FILE *out, CborValue *value, int flags) {
return cbor_value_to_pretty_stream(cbor_fprintf, out, value, flags);
}

View file

@ -167,8 +167,7 @@ typedef struct ConversionStatus {
static CborError value_to_json(FILE *out, CborValue *it, int flags, CborType type, ConversionStatus *status);
static CborError dump_bytestring_base16(char **result, CborValue *it)
{
static CborError dump_bytestring_base16(char **result, CborValue *it) {
static const char characters[] = "0123456789abcdef";
size_t i;
size_t n = 0;
@ -194,8 +193,7 @@ static CborError dump_bytestring_base16(char **result, CborValue *it)
return CborNoError;
}
static CborError generic_dump_base64(char **result, CborValue *it, const char alphabet[65])
{
static CborError generic_dump_base64(char **result, CborValue *it, const char alphabet[65]) {
size_t n = 0, i;
uint8_t *buffer, *out, *in;
CborError err = cbor_value_calculate_string_length(it, &n);
@ -267,22 +265,19 @@ static CborError generic_dump_base64(char **result, CborValue *it, const char al
return CborNoError;
}
static CborError dump_bytestring_base64(char **result, CborValue *it)
{
static CborError dump_bytestring_base64(char **result, CborValue *it) {
static const char alphabet[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef"
"ghijklmn" "opqrstuv" "wxyz0123" "456789+/" "=";
return generic_dump_base64(result, it, alphabet);
}
static CborError dump_bytestring_base64url(char **result, CborValue *it)
{
static CborError dump_bytestring_base64url(char **result, CborValue *it) {
static const char alphabet[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef"
"ghijklmn" "opqrstuv" "wxyz0123" "456789-_";
return generic_dump_base64(result, it, alphabet);
}
static CborError add_value_metadata(FILE *out, CborType type, const ConversionStatus *status)
{
static CborError add_value_metadata(FILE *out, CborType type, const ConversionStatus *status) {
int flags = status->flags;
if (flags & TypeWasTagged) {
/* extract the tagged type, which may be JSON native */
@ -317,8 +312,7 @@ static CborError add_value_metadata(FILE *out, CborType type, const ConversionSt
return CborNoError;
}
static CborError find_tagged_type(CborValue *it, CborTag *tag, CborType *type)
{
static CborError find_tagged_type(CborValue *it, CborTag *tag, CborType *type) {
CborError err = CborNoError;
*type = cbor_value_get_type(it);
while (*type == CborTagType) {
@ -332,8 +326,7 @@ static CborError find_tagged_type(CborValue *it, CborTag *tag, CborType *type)
return err;
}
static CborError tagged_value_to_json(FILE *out, CborValue *it, int flags, ConversionStatus *status)
{
static CborError tagged_value_to_json(FILE *out, CborValue *it, int flags, ConversionStatus *status) {
CborTag tag;
CborError err;
@ -352,8 +345,8 @@ static CborError tagged_value_to_json(FILE *out, CborValue *it, int flags, Conve
return err;
if (flags & CborConvertAddMetadata && status->flags) {
if (fprintf(out, ",\"tag%" PRIu64 "$cbor\":{", tag) < 0 ||
add_value_metadata(out, type, status) != CborNoError ||
fputc('}', out) < 0)
add_value_metadata(out, type, status) != CborNoError ||
fputc('}', out) < 0)
return CborErrorIO;
}
if (fputc('}', out) < 0)
@ -370,7 +363,7 @@ static CborError tagged_value_to_json(FILE *out, CborValue *it, int flags, Conve
/* special handling of byte strings? */
if (type == CborByteStringType && (flags & CborConvertByteStringsToBase64Url) == 0 &&
(tag == CborNegativeBignumTag || tag == CborExpectedBase16Tag || tag == CborExpectedBase64Tag)) {
(tag == CborNegativeBignumTag || tag == CborExpectedBase16Tag || tag == CborExpectedBase64Tag)) {
char *str;
char *pre = "";
@ -396,8 +389,7 @@ static CborError tagged_value_to_json(FILE *out, CborValue *it, int flags, Conve
return err;
}
static CborError stringify_map_key(char **key, CborValue *it, int flags, CborType type)
{
static CborError stringify_map_key(char **key, CborValue *it, int flags, CborType type) {
(void)flags; /* unused */
(void)type; /* unused */
#ifdef WITHOUT_OPEN_MEMSTREAM
@ -418,8 +410,7 @@ static CborError stringify_map_key(char **key, CborValue *it, int flags, CborTyp
#endif
}
static CborError array_to_json(FILE *out, CborValue *it, int flags, ConversionStatus *status)
{
static CborError array_to_json(FILE *out, CborValue *it, int flags, ConversionStatus *status) {
const char *comma = "";
while (!cbor_value_at_end(it)) {
if (fprintf(out, "%s", comma) < 0)
@ -433,8 +424,7 @@ static CborError array_to_json(FILE *out, CborValue *it, int flags, ConversionSt
return CborNoError;
}
static CborError map_to_json(FILE *out, CborValue *it, int flags, ConversionStatus *status)
{
static CborError map_to_json(FILE *out, CborValue *it, int flags, ConversionStatus *status) {
const char *comma = "";
CborError err;
while (!cbor_value_at_end(it)) {
@ -473,8 +463,8 @@ static CborError map_to_json(FILE *out, CborValue *it, int flags, ConversionStat
}
if (!err && status->flags) {
if (fprintf(out, ",\"%s$cbor\":{", key) < 0 ||
add_value_metadata(out, valueType, status) != CborNoError ||
fputc('}', out) < 0)
add_value_metadata(out, valueType, status) != CborNoError ||
fputc('}', out) < 0)
err = CborErrorIO;
}
}
@ -486,8 +476,7 @@ static CborError map_to_json(FILE *out, CborValue *it, int flags, ConversionStat
return CborNoError;
}
static CborError value_to_json(FILE *out, CborValue *it, int flags, CborType type, ConversionStatus *status)
{
static CborError value_to_json(FILE *out, CborValue *it, int flags, CborType type, ConversionStatus *status) {
CborError err;
status->flags = 0;
@ -690,8 +679,7 @@ static CborError value_to_json(FILE *out, CborValue *it, int flags, CborType typ
*
* \sa cbor_value_to_json(), cbor_value_to_pretty_advance()
*/
CborError cbor_value_to_json_advance(FILE *out, CborValue *value, int flags)
{
CborError cbor_value_to_json_advance(FILE *out, CborValue *value, int flags) {
ConversionStatus status;
return value_to_json(out, value, flags, cbor_value_get_type(value), &status);
}

View file

@ -267,8 +267,7 @@ static const struct KnownTagData knownTagData[] = {
static CborError validate_value(CborValue *it, uint32_t flags, int recursionLeft);
static inline CborError validate_utf8_string(const void *ptr, size_t n)
{
static inline CborError validate_utf8_string(const void *ptr, size_t n) {
const uint8_t *buffer = (const uint8_t *)ptr;
const uint8_t *const end = buffer + n;
while (buffer < end) {
@ -279,8 +278,7 @@ static inline CborError validate_utf8_string(const void *ptr, size_t n)
return CborNoError;
}
static inline CborError validate_simple_type(uint8_t simple_type, uint32_t flags)
{
static inline CborError validate_simple_type(uint8_t simple_type, uint32_t flags) {
/* At current time, all known simple types are those from RFC 7049,
* which are parsed by the parser into different CBOR types.
* That means that if we've got here, the type is unknown */
@ -290,8 +288,7 @@ static inline CborError validate_simple_type(uint8_t simple_type, uint32_t flags
CborErrorUnknownSimpleType : CborNoError;
}
static inline CborError validate_number(const CborValue *it, CborType type, uint32_t flags)
{
static inline CborError validate_number(const CborValue *it, CborType type, uint32_t flags) {
CborError err = CborNoError;
const uint8_t *ptr = it->ptr;
size_t bytesUsed, bytesNeeded;
@ -321,8 +318,7 @@ static inline CborError validate_number(const CborValue *it, CborType type, uint
return CborNoError;
}
static inline CborError validate_tag(CborValue *it, CborTag tag, uint32_t flags, int recursionLeft)
{
static inline CborError validate_tag(CborValue *it, CborTag tag, uint32_t flags, int recursionLeft) {
CborType type = cbor_value_get_type(it);
const size_t knownTagCount = sizeof(knownTagData) / sizeof(knownTagData[0]);
const struct KnownTagData *tagData = knownTagData;
@ -374,8 +370,7 @@ static inline CborError validate_tag(CborValue *it, CborTag tag, uint32_t flags,
}
#ifndef CBOR_NO_FLOATING_POINT
static inline CborError validate_floating_point(CborValue *it, CborType type, uint32_t flags)
{
static inline CborError validate_floating_point(CborValue *it, CborType type, uint32_t flags) {
CborError err;
int r;
double val;
@ -437,8 +432,7 @@ static inline CborError validate_floating_point(CborValue *it, CborType type, ui
}
#endif
static CborError validate_container(CborValue *it, int containerType, uint32_t flags, int recursionLeft)
{
static CborError validate_container(CborValue *it, int containerType, uint32_t flags, int recursionLeft) {
CborError err;
const uint8_t *previous = NULL;
const uint8_t *previous_end = NULL;
@ -511,8 +505,7 @@ static CborError validate_container(CborValue *it, int containerType, uint32_t f
return CborNoError;
}
static CborError validate_value(CborValue *it, uint32_t flags, int recursionLeft)
{
static CborError validate_value(CborValue *it, uint32_t flags, int recursionLeft) {
CborError err;
CborType type = cbor_value_get_type(it);
@ -650,8 +643,7 @@ static CborError validate_value(CborValue *it, uint32_t flags, int recursionLeft
*
* \sa CborValidationFlags, cbor_value_validate_basic(), cbor_value_advance()
*/
CborError cbor_value_validate(const CborValue *it, uint32_t flags)
{
CborError cbor_value_validate(const CborValue *it, uint32_t flags) {
CborValue value = *it;
CborError err = validate_value(&value, flags, CBOR_PARSER_MAX_RECURSIONS);
if (err)

View file

@ -190,8 +190,7 @@
# define unreachable() do {} while (0)
#endif
static inline bool add_check_overflow(size_t v1, size_t v2, size_t *r)
{
static inline bool add_check_overflow(size_t v1, size_t v2, size_t *r) {
#if ((defined(__GNUC__) && (__GNUC__ >= 5)) && !defined(__INTEL_COMPILER)) || __has_builtin(__builtin_add_overflow)
return __builtin_add_overflow(v1, v2, r);
#else

View file

@ -53,8 +53,7 @@ struct Buffer {
size_t alloc;
};
static RetType write_to_buffer(void *cookie, const char *data, LenType len)
{
static RetType write_to_buffer(void *cookie, const char *data, LenType len) {
struct Buffer *b = (struct Buffer *)cookie;
char *ptr = *b->ptr;
size_t newsize;
@ -78,8 +77,7 @@ static RetType write_to_buffer(void *cookie, const char *data, LenType len)
return len;
}
static int close_buffer(void *cookie)
{
static int close_buffer(void *cookie) {
struct Buffer *b = (struct Buffer *)cookie;
if (*b->ptr)
(*b->ptr)[*b->len] = '\0';
@ -87,8 +85,7 @@ static int close_buffer(void *cookie)
return 0;
}
FILE *open_memstream(char **bufptr, size_t *lenptr)
{
FILE *open_memstream(char **bufptr, size_t *lenptr) {
struct Buffer *b = (struct Buffer *)calloc(sizeof(struct Buffer), sizeof(uint8_t));
if (b == NULL)
return NULL;

View file

@ -29,8 +29,7 @@
#include <stdint.h>
static inline uint32_t get_utf8(const uint8_t **buffer, const uint8_t *end)
{
static inline uint32_t get_utf8(const uint8_t **buffer, const uint8_t *end) {
int charsNeeded;
uint32_t uc, min_uc;
uint8_t b;