You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/12 16:26:14 UTC
(mynewt-core) 05/24: encoding/cborattr: Fix coding style
This is an automated email from the ASF dual-hosted git repository.
sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit a5047ea343b959e6523e40d176918460d2de55f1
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Mon Oct 12 15:11:35 2026 +0200
encoding/cborattr: Fix coding style
This makes code imported from apache-mynewt-mcumgr repository compliant
with clang-format coding style. No functional changes.
Assisted-by: Claude:claude-opus-5-5
---
encoding/cborattr/include/cborattr/cborattr.h | 31 +++----
encoding/cborattr/src/cborattr.c | 55 +++++--------
encoding/cborattr/test/src/test_cborattr.h | 1 -
encoding/cborattr/test/src/test_cborattr_utils.c | 8 +-
.../src/testcases/cborattr_decode_bool_array.c | 24 +++---
.../test/src/testcases/cborattr_decode_int_array.c | 64 ++++++---------
.../test/src/testcases/cborattr_decode_nesting.c | 24 +++---
.../test/src/testcases/cborattr_decode_obj_array.c | 24 +++---
.../test/src/testcases/cborattr_decode_object.c | 94 ++++++++--------------
.../src/testcases/cborattr_decode_object_array.c | 32 +++-----
.../test/src/testcases/cborattr_decode_partial.c | 16 ++--
.../test/src/testcases/cborattr_decode_simple.c | 41 ++++------
.../src/testcases/cborattr_decode_string_array.c | 28 +++----
.../cborattr_decode_string_array_bounds.c | 18 ++---
.../src/testcases/cborattr_decode_string_bounds.c | 30 +++----
.../src/testcases/cborattr_decode_substring_key.c | 44 ++++------
.../src/testcases/cborattr_decode_unnamed_array.c | 24 +++---
.../test/src/testcases/cborattr_encode_omit.c | 3 +-
.../test/src/testcases/cborattr_encode_simple.c | 25 +++---
19 files changed, 230 insertions(+), 356 deletions(-)
diff --git a/encoding/cborattr/include/cborattr/cborattr.h b/encoding/cborattr/include/cborattr/cborattr.h
index d025e6404..6c800e0bb 100644
--- a/encoding/cborattr/include/cborattr/cborattr.h
+++ b/encoding/cborattr/include/cborattr/cborattr.h
@@ -17,7 +17,6 @@
* under the License.
*/
-
#ifndef CBORATTR_H
#define CBORATTR_H
@@ -86,7 +85,7 @@ struct cbor_array_t {
struct {
double *store;
} reals;
- struct{
+ struct {
uint16_t *store;
} halffloats;
struct {
@@ -159,9 +158,9 @@ struct cbor_out_val_t {
/** An object key-value pair to be encoded as CBOR. */
struct cbor_out_attr_t {
- const char *attribute; /** The attribute name (key). */
- struct cbor_out_val_t val; /** The attribute value. */
- bool omit; /** Attribute ignored if true. */
+ const char *attribute; /** The attribute name (key). */
+ struct cbor_out_val_t val; /** The attribute value. */
+ bool omit; /** Attribute ignored if true. */
};
#endif
@@ -176,22 +175,20 @@ struct cbor_out_attr_t {
* initializer defining the subobject type, and the address of an integer to
* store the length in.
*/
-#define CBORATTR_STRUCT_OBJECT(s, f) .addr.offset = offsetof(s, f)
-#define CBORATTR_STRUCT_ARRAY(a, e, n) \
- .addr.array.element_type = CborAttrStructObjectType, \
- .addr.array.arr.objects.subtype = e, \
- .addr.array.arr.objects.base = (char*)a, \
- .addr.array.arr.objects.stride = sizeof(a[0]), \
- .addr.array.count = n, \
- .addr.array.maxlen = (int)(sizeof(a)/sizeof(a[0]))
+#define CBORATTR_STRUCT_OBJECT(s, f) .addr.offset = offsetof(s, f)
+#define CBORATTR_STRUCT_ARRAY(a, e, n) \
+ .addr.array.element_type = CborAttrStructObjectType, \
+ .addr.array.arr.objects.subtype = e, \
+ .addr.array.arr.objects.base = (char *)a, \
+ .addr.array.arr.objects.stride = sizeof(a[0]), .addr.array.count = n, \
+ .addr.array.maxlen = (int)(sizeof(a) / sizeof(a[0]))
#define CBORATTR_ATTR_UNNAMED (char *)(-1)
int cbor_read_object(struct CborValue *, const struct cbor_attr_t *);
int cbor_read_array(struct CborValue *, const struct cbor_array_t *);
-int cbor_read_flat_attrs(const uint8_t *data, int len,
- const struct cbor_attr_t *attrs);
+int cbor_read_flat_attrs(const uint8_t *data, int len, const struct cbor_attr_t *attrs);
#ifdef MYNEWT
int cbor_read_mbuf_attrs(struct os_mbuf *m, uint16_t off, uint16_t len,
const struct cbor_attr_t *attrs);
@@ -204,8 +201,7 @@ int cbor_read_mbuf_attrs(struct os_mbuf *m, uint16_t off, uint16_t len,
*
* @return 0 on success; SYS_E[...] error on failure.
*/
-int cbor_write_object(struct CborEncoder *enc,
- const struct cbor_out_attr_t *attrs);
+int cbor_write_object(struct CborEncoder *enc, const struct cbor_out_attr_t *attrs);
/**
* @brief Encodes a CBOR representation of the specified key-value map into an
@@ -224,4 +220,3 @@ int cbor_write_object_msys(const struct cbor_out_attr_t *attrs,
#endif
#endif /* CBORATTR_H */
-
diff --git a/encoding/cborattr/src/cborattr.c b/encoding/cborattr/src/cborattr.c
index 797d96a6f..8266e50d8 100644
--- a/encoding/cborattr/src/cborattr.c
+++ b/encoding/cborattr/src/cborattr.c
@@ -35,7 +35,7 @@
#include "tinycbor/cbor_mbuf_reader.h"
#include "tinycbor/cbor_mbuf_writer.h"
#include "os/os_mbuf.h"
-#define CBORATTR_MAX_SIZE MYNEWT_VAL(CBORATTR_MAX_SIZE)
+#define CBORATTR_MAX_SIZE MYNEWT_VAL(CBORATTR_MAX_SIZE)
#define CBORATTR_MAX_NESTING MYNEWT_VAL(CBORATTR_MAX_NESTING)
#endif
@@ -70,7 +70,7 @@ valid_attr_type(CborType ct, CborAttrType at)
if (ct == CborBooleanType) {
return 1;
}
- break;
+ break;
#if FLOAT_SUPPORT
case CborAttrHalfFloatType:
if (ct == CborHalfFloatType) {
@@ -163,7 +163,7 @@ cborattr_advance(CborValue *it)
}
/* this function find the pointer to the memory location to
- * write or read and attribute from the cbor_attr_r structure */
+ * write or read and attribute from the cbor_attr_r structure */
static char *
cbor_target_address(const struct cbor_attr_t *cursor,
const struct cbor_array_t *parent, int offset)
@@ -194,7 +194,7 @@ cbor_target_address(const struct cbor_attr_t *cursor,
break;
#endif
case CborAttrByteStringType:
- targetaddr = (char *) cursor->addr.bytestring.data;
+ targetaddr = (char *)cursor->addr.bytestring.data;
break;
case CborAttrTextStringType:
targetaddr = cursor->addr.string;
@@ -208,18 +208,15 @@ cbor_target_address(const struct cbor_attr_t *cursor,
}
} else {
/* tricky case - hacking a member in an array of structures */
- targetaddr =
- parent->arr.objects.base + (offset * parent->arr.objects.stride) +
- cursor->addr.offset;
+ targetaddr = parent->arr.objects.base +
+ (offset * parent->arr.objects.stride) + cursor->addr.offset;
}
return targetaddr;
}
static int
-cbor_internal_read_object(CborValue *root_value,
- const struct cbor_attr_t *attrs,
- const struct cbor_array_t *parent,
- int offset)
+cbor_internal_read_object(CborValue *root_value, const struct cbor_attr_t *attrs,
+ const struct cbor_array_t *parent, int offset)
{
const struct cbor_attr_t *cursor, *best_match;
char attrbuf[CBORATTR_MAX_SIZE + 1];
@@ -292,8 +289,7 @@ cbor_internal_read_object(CborValue *root_value,
err |= CborErrorDataTooLarge;
break;
}
- err |= cbor_value_copy_text_string(&cur_value, attrbuf, &len,
- NULL);
+ err |= cbor_value_copy_text_string(&cur_value, attrbuf, &len, NULL);
/* at least get the type of the next value so we can match the
* attribute name and type for a perfect match */
@@ -313,11 +309,10 @@ cbor_internal_read_object(CborValue *root_value,
best_match = NULL;
for (cursor = attrs; cursor->attribute != NULL; cursor++) {
if (valid_attr_type(type, cursor->type)) {
- if (cursor->attribute == CBORATTR_ATTR_UNNAMED &&
- attrbuf[0] == '\0') {
+ if (cursor->attribute == CBORATTR_ATTR_UNNAMED && attrbuf[0] == '\0') {
best_match = cursor;
} else if (strlen(cursor->attribute) == len &&
- !memcmp(cursor->attribute, attrbuf, len)) {
+ !memcmp(cursor->attribute, attrbuf, len)) {
break;
}
}
@@ -356,8 +351,7 @@ cbor_internal_read_object(CborValue *root_value,
size_t len = cursor->len;
CborError copy_err;
- copy_err = cbor_value_copy_byte_string(&cur_value, lptr,
- &len, NULL);
+ copy_err = cbor_value_copy_byte_string(&cur_value, lptr, &len, NULL);
err |= copy_err;
/* On error len is set to string length, not copied length */
*cursor->addr.bytestring.len = copy_err ? 0 : len;
@@ -373,8 +367,7 @@ cbor_internal_read_object(CborValue *root_value,
}
/* Reserve space for terminating NUL */
len = cursor->len - 1;
- copy_err = cbor_value_copy_text_string(&cur_value, lptr,
- &len, NULL);
+ copy_err = cbor_value_copy_text_string(&cur_value, lptr, &len, NULL);
err |= copy_err;
((char *)lptr)[copy_err ? 0 : len] = '\0';
break;
@@ -517,8 +510,7 @@ cbor_read_object(struct CborValue *value, const struct cbor_attr_t *attrs)
* @return 0 on success; non-zero on failure.
*/
int
-cbor_read_flat_attrs(const uint8_t *data, int len,
- const struct cbor_attr_t *attrs)
+cbor_read_flat_attrs(const uint8_t *data, int len, const struct cbor_attr_t *attrs)
{
struct cbor_buf_reader reader;
struct CborParser parser;
@@ -534,8 +526,7 @@ cbor_read_flat_attrs(const uint8_t *data, int len,
}
#ifdef MYNEWT
-static int cbor_write_val(struct CborEncoder *enc,
- const struct cbor_out_val_t *val);
+static int cbor_write_val(struct CborEncoder *enc, const struct cbor_out_val_t *val);
/*
* Read in cbor key/values from os_mbuf pointed by m, and fill them
@@ -566,8 +557,7 @@ cbor_read_mbuf_attrs(struct os_mbuf *m, uint16_t off, uint16_t len,
}
static int
-cbor_write_arr_val(struct CborEncoder *enc,
- const struct cbor_out_arr_val_t *arr)
+cbor_write_arr_val(struct CborEncoder *enc, const struct cbor_out_arr_val_t *arr)
{
struct CborEncoder arr_enc;
size_t i;
@@ -631,14 +621,12 @@ cbor_write_val(struct CborEncoder *enc, const struct cbor_out_val_t *val)
#endif
case CborAttrByteStringType:
- if (val->bytestring.data == NULL &&
- val->bytestring.len != 0) {
+ if (val->bytestring.data == NULL && val->bytestring.len != 0) {
return SYS_EINVAL;
}
- rc = cbor_encode_byte_string(enc, val->bytestring.data,
- val->bytestring.len);
+ rc = cbor_encode_byte_string(enc, val->bytestring.data, val->bytestring.len);
break;
case CborAttrTextStringType:
@@ -688,12 +676,12 @@ cbor_write_attr(struct CborEncoder *enc, const struct cbor_out_attr_t *attr)
rc = cbor_encode_text_string(enc, attr->attribute, len);
if (rc != 0) {
return rc;
- }
+ }
rc = cbor_write_val(enc, &attr->val);
if (rc != 0) {
return rc;
- }
+ }
return 0;
}
@@ -726,8 +714,7 @@ cbor_write_object(struct CborEncoder *enc, const struct cbor_out_attr_t *attrs)
}
int
-cbor_write_object_msys(const struct cbor_out_attr_t *attrs,
- struct os_mbuf **out_om)
+cbor_write_object_msys(const struct cbor_out_attr_t *attrs, struct os_mbuf **out_om)
{
struct cbor_mbuf_writer writer;
struct CborEncoder encoder;
diff --git a/encoding/cborattr/test/src/test_cborattr.h b/encoding/cborattr/test/src/test_cborattr.h
index d423f25e0..b7168fad9 100644
--- a/encoding/cborattr/test/src/test_cborattr.h
+++ b/encoding/cborattr/test/src/test_cborattr.h
@@ -59,4 +59,3 @@ TEST_CASE_DECL(test_cborattr_decode_string_array_bounds);
#endif
#endif /* TEST_CBORATTR_H */
-
diff --git a/encoding/cborattr/test/src/test_cborattr_utils.c b/encoding/cborattr/test/src/test_cborattr_utils.c
index d520e069c..917ae62a1 100644
--- a/encoding/cborattr/test/src/test_cborattr_utils.c
+++ b/encoding/cborattr/test/src/test_cborattr_utils.c
@@ -21,11 +21,9 @@
/*
* {"a": "A", "b": "B", "c": "C", "d": "D", "e": "E"}
*/
-static const uint8_t test_data1[] = {
- 0xa5, 0x61, 0x61, 0x61, 0x41, 0x61, 0x62, 0x61,
- 0x42, 0x61, 0x63, 0x61, 0x43, 0x61, 0x64, 0x61,
- 0x44, 0x61, 0x65, 0x61, 0x45
-};
+static const uint8_t test_data1[] = { 0xa5, 0x61, 0x61, 0x61, 0x41, 0x61, 0x62,
+ 0x61, 0x42, 0x61, 0x63, 0x61, 0x43, 0x61,
+ 0x64, 0x61, 0x44, 0x61, 0x65, 0x61, 0x45 };
const uint8_t *
test_str1(int *len)
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_bool_array.c b/encoding/cborattr/test/src/testcases/cborattr_decode_bool_array.c
index 71520c428..a2e858ce6 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_bool_array.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_bool_array.c
@@ -29,9 +29,7 @@ static int test_cbor_len;
*/
static int test_cbor_wr(struct cbor_encoder_writer *, const char *, int);
static CborEncoder test_encoder;
-static struct cbor_encoder_writer test_writer = {
- .write = test_cbor_wr
-};
+static struct cbor_encoder_writer test_writer = { .write = test_cbor_wr };
static int
test_cbor_wr(struct cbor_encoder_writer *cew, const char *data, int len)
@@ -76,18 +74,14 @@ TEST_CASE(test_cborattr_decode_bool_array)
bool arr_data[5];
int arr_cnt = 0;
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = "a",
- .type = CborAttrArrayType,
- .addr.array.element_type = CborAttrBooleanType,
- .addr.array.arr.booleans.store = arr_data,
- .addr.array.count = &arr_cnt,
- .addr.array.maxlen = sizeof(arr_data) / sizeof(arr_data[0]),
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "a",
+ .type = CborAttrArrayType,
+ .addr.array.element_type = CborAttrBooleanType,
+ .addr.array.arr.booleans.store = arr_data,
+ .addr.array.count = &arr_cnt,
+ .addr.array.maxlen = sizeof(arr_data) / sizeof(arr_data[0]),
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
test_encode_bool_array();
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_int_array.c b/encoding/cborattr/test/src/testcases/cborattr_decode_int_array.c
index fde602cc7..c48ae7026 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_int_array.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_int_array.c
@@ -29,9 +29,7 @@ static int test_cbor_len;
*/
static int test_cbor_wr(struct cbor_encoder_writer *, const char *, int);
static CborEncoder test_encoder;
-static struct cbor_encoder_writer test_writer = {
- .write = test_cbor_wr
-};
+static struct cbor_encoder_writer test_writer = { .write = test_cbor_wr };
static int
test_cbor_wr(struct cbor_encoder_writer *cew, const char *data, int len)
@@ -79,44 +77,32 @@ TEST_CASE(test_cborattr_decode_int_array)
long long int b_int;
int arr_cnt = 0;
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = "a",
- .type = CborAttrArrayType,
- .addr.array.element_type = CborAttrIntegerType,
- .addr.array.arr.integers.store = arr_data,
- .addr.array.count = &arr_cnt,
- .addr.array.maxlen = sizeof(arr_data) / sizeof(arr_data[0]),
- .nodefault = true
- },
- [1] = {
- .attribute = "b",
- .type = CborAttrIntegerType,
- .addr.integer = &b_int,
- .dflt.integer = 1
- },
- [2] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "a",
+ .type = CborAttrArrayType,
+ .addr.array.element_type = CborAttrIntegerType,
+ .addr.array.arr.integers.store = arr_data,
+ .addr.array.count = &arr_cnt,
+ .addr.array.maxlen = sizeof(arr_data) / sizeof(arr_data[0]),
+ .nodefault = true },
+ [1] = { .attribute = "b",
+ .type = CborAttrIntegerType,
+ .addr.integer = &b_int,
+ .dflt.integer = 1 },
+ [2] = { .attribute = NULL }
};
struct cbor_attr_t test_attrs_small[] = {
- [0] = {
- .attribute = "a",
- .type = CborAttrArrayType,
- .addr.array.element_type = CborAttrIntegerType,
- .addr.array.arr.integers.store = arr_data,
- .addr.array.count = &arr_cnt,
- .addr.array.maxlen = 1,
- .nodefault = true
- },
- [1] = {
- .attribute = "b",
- .type = CborAttrIntegerType,
- .addr.integer = &b_int,
- .dflt.integer = 1
- },
- [2] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "a",
+ .type = CborAttrArrayType,
+ .addr.array.element_type = CborAttrIntegerType,
+ .addr.array.arr.integers.store = arr_data,
+ .addr.array.count = &arr_cnt,
+ .addr.array.maxlen = 1,
+ .nodefault = true },
+ [1] = { .attribute = "b",
+ .type = CborAttrIntegerType,
+ .addr.integer = &b_int,
+ .dflt.integer = 1 },
+ [2] = { .attribute = NULL }
};
test_encode_int_array();
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_nesting.c b/encoding/cborattr/test/src/testcases/cborattr_decode_nesting.c
index 4d8524fe6..387c5ce6a 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_nesting.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_nesting.c
@@ -19,7 +19,7 @@
#include "test_cborattr.h"
-#define TEST_NESTING_DEEP 200
+#define TEST_NESTING_DEEP 200
static uint8_t test_nesting_buf[TEST_NESTING_DEEP + 32];
@@ -62,21 +62,21 @@ TEST_CASE_SELF(test_cborattr_decode_nesting)
const struct cbor_attr_t attrs[] = {
{
- .attribute = "a",
- .type = CborAttrIntegerType,
- .addr.integer = &a,
- },
+ .attribute = "a",
+ .type = CborAttrIntegerType,
+ .addr.integer = &a,
+ },
{ 0 },
};
const struct cbor_attr_t arr_attrs[] = {
{
- .attribute = "a",
- .type = CborAttrArrayType,
- .addr.array.element_type = CborAttrIntegerType,
- .addr.array.arr.integers.store = arr,
- .addr.array.count = &arr_cnt,
- .addr.array.maxlen = 1,
- },
+ .attribute = "a",
+ .type = CborAttrArrayType,
+ .addr.array.element_type = CborAttrIntegerType,
+ .addr.array.arr.integers.store = arr,
+ .addr.array.count = &arr_cnt,
+ .addr.array.maxlen = 1,
+ },
{ 0 },
};
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_obj_array.c b/encoding/cborattr/test/src/testcases/cborattr_decode_obj_array.c
index 57c46cdf2..9295cfcae 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_obj_array.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_obj_array.c
@@ -29,9 +29,7 @@ static int test_cbor_len;
*/
static int test_cbor_wr(struct cbor_encoder_writer *, const char *, int);
static CborEncoder test_encoder;
-static struct cbor_encoder_writer test_writer = {
- .write = test_cbor_wr
-};
+static struct cbor_encoder_writer test_writer = { .write = test_cbor_wr };
static int
test_cbor_wr(struct cbor_encoder_writer *cew, const char *data, int len)
@@ -87,18 +85,14 @@ TEST_CASE(test_cborattr_decode_obj_array)
char arr_data[4];
int arr_cnt;
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = "a",
- .type = CborAttrArrayType,
- .addr.array.element_type = CborAttrNullType,
- .addr.array.arr.objects.base = arr_data,
- .addr.array.count = &arr_cnt,
- .addr.array.maxlen = 4,
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "a",
+ .type = CborAttrArrayType,
+ .addr.array.element_type = CborAttrNullType,
+ .addr.array.arr.objects.base = arr_data,
+ .addr.array.count = &arr_cnt,
+ .addr.array.maxlen = 4,
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
test_encode_obj_array();
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_object.c b/encoding/cborattr/test/src/testcases/cborattr_decode_object.c
index 81e6f9231..69008b417 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_object.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_object.c
@@ -29,9 +29,7 @@ static int test_cbor_len;
*/
static int test_cbor_wr(struct cbor_encoder_writer *, const char *, int);
static CborEncoder test_encoder;
-static struct cbor_encoder_writer test_writer = {
- .write = test_cbor_wr
-};
+static struct cbor_encoder_writer test_writer = { .write = test_cbor_wr };
static int
test_cbor_wr(struct cbor_encoder_writer *cew, const char *data, int len)
@@ -112,73 +110,49 @@ TEST_CASE(test_cborattr_decode_object)
int rc;
long long int bm_val = 0;
struct cbor_attr_t test_sub_attr_bm[] = {
- [0] = {
- .attribute = "bm",
- .type = CborAttrIntegerType,
- .addr.integer = &bm_val,
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "bm",
+ .type = CborAttrIntegerType,
+ .addr.integer = &bm_val,
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = "p",
- .type = CborAttrObjectType,
- .addr.obj = test_sub_attr_bm,
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "p",
+ .type = CborAttrObjectType,
+ .addr.obj = test_sub_attr_bm,
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
long long int a_val = 0;
long long int i_val = 0;
struct cbor_attr_t test_sub_sub_attr[] = {
- [0] = {
- .attribute = "i",
- .type = CborAttrIntegerType,
- .addr.integer = &i_val,
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "i",
+ .type = CborAttrIntegerType,
+ .addr.integer = &i_val,
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
struct cbor_attr_t test_sub_attr_d[] = {
- [0] = {
- .attribute = "d",
- .type = CborAttrObjectType,
- .addr.obj = test_sub_sub_attr,
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "d",
+ .type = CborAttrObjectType,
+ .addr.obj = test_sub_sub_attr,
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
struct cbor_attr_t test_attr_complex[] = {
- [0] = {
- .attribute = "c",
- .type = CborAttrObjectType,
- .addr.obj = test_sub_attr_d,
- .nodefault = true
- },
- [1] = {
- .attribute = "a",
- .type = CborAttrIntegerType,
- .addr.integer = &a_val,
- .nodefault = true
- },
- [2] = {
- .attribute = "p",
- .type = CborAttrObjectType,
- .addr.obj = test_sub_attr_bm,
- .nodefault = true
- },
- [3] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "c",
+ .type = CborAttrObjectType,
+ .addr.obj = test_sub_attr_d,
+ .nodefault = true },
+ [1] = { .attribute = "a",
+ .type = CborAttrIntegerType,
+ .addr.integer = &a_val,
+ .nodefault = true },
+ [2] = { .attribute = "p",
+ .type = CborAttrObjectType,
+ .addr.obj = test_sub_attr_bm,
+ .nodefault = true },
+ [3] = { .attribute = NULL }
};
test_encode_data();
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_object_array.c b/encoding/cborattr/test/src/testcases/cborattr_decode_object_array.c
index 82cc34f17..ab5fc9b9c 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_object_array.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_object_array.c
@@ -29,9 +29,7 @@ static int test_cbor_len;
*/
static int test_cbor_wr(struct cbor_encoder_writer *, const char *, int);
static CborEncoder test_encoder;
-static struct cbor_encoder_writer test_writer = {
- .write = test_cbor_wr
-};
+static struct cbor_encoder_writer test_writer = { .write = test_cbor_wr };
static int
test_cbor_wr(struct cbor_encoder_writer *cew, const char *data, int len)
@@ -93,26 +91,18 @@ TEST_CASE(test_cborattr_decode_object_array)
} arr_objs[5];
int arr_cnt = 0;
struct cbor_attr_t sub_attr[] = {
- [0] = {
- .attribute = "h",
- .type = CborAttrTextStringType,
- CBORATTR_STRUCT_OBJECT(struct h_obj, h_data),
- .len = sizeof(arr_objs[0].h_data)
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "h",
+ .type = CborAttrTextStringType,
+ CBORATTR_STRUCT_OBJECT(struct h_obj, h_data),
+ .len = sizeof(arr_objs[0].h_data) },
+ [1] = { .attribute = NULL }
};
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = "a",
- .type = CborAttrArrayType,
- CBORATTR_STRUCT_ARRAY(arr_objs, sub_attr, &arr_cnt),
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "a",
+ .type = CborAttrArrayType,
+ CBORATTR_STRUCT_ARRAY(arr_objs, sub_attr, &arr_cnt),
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
test_encode_object_array();
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_partial.c b/encoding/cborattr/test/src/testcases/cborattr_decode_partial.c
index df0b8d4f5..bb2f6aa39 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_partial.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_partial.c
@@ -28,16 +28,12 @@ TEST_CASE(test_cborattr_decode_partial)
int rc;
char test_str_b[4] = { '\0' };
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = "b",
- .type = CborAttrTextStringType,
- .addr.string = test_str_b,
- .len = sizeof(test_str_b),
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "b",
+ .type = CborAttrTextStringType,
+ .addr.string = test_str_b,
+ .len = sizeof(test_str_b),
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
data = test_str1(&len);
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_simple.c b/encoding/cborattr/test/src/testcases/cborattr_decode_simple.c
index aef3a8078..46bdf8d64 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_simple.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_simple.c
@@ -29,9 +29,7 @@ static int test_cbor_len;
*/
static int test_cbor_wr(struct cbor_encoder_writer *, const char *, int);
static CborEncoder test_encoder;
-static struct cbor_encoder_writer test_writer = {
- .write = test_cbor_wr
-};
+static struct cbor_encoder_writer test_writer = { .write = test_cbor_wr };
static int
test_cbor_wr(struct cbor_encoder_writer *cew, const char *data, int len)
@@ -74,7 +72,6 @@ test_encode_data(void)
/*
* XXX add other data types to encode here.
*/
-
}
/*
@@ -88,28 +85,20 @@ TEST_CASE(test_cborattr_decode_simple)
uint8_t c_data[4];
size_t c_len;
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = "a",
- .type = CborAttrIntegerType,
- .addr.uinteger = &a_val,
- .nodefault = true
- },
- [1] = {
- .attribute = "b",
- .type = CborAttrIntegerType,
- .addr.integer = &b_val,
- .nodefault = true
- },
- [2] = {
- .attribute = "c",
- .type = CborAttrByteStringType,
- .addr.bytestring.data = c_data,
- .addr.bytestring.len = &c_len,
- .len = sizeof(c_data)
- },
- [3] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "a",
+ .type = CborAttrIntegerType,
+ .addr.uinteger = &a_val,
+ .nodefault = true },
+ [1] = { .attribute = "b",
+ .type = CborAttrIntegerType,
+ .addr.integer = &b_val,
+ .nodefault = true },
+ [2] = { .attribute = "c",
+ .type = CborAttrByteStringType,
+ .addr.bytestring.data = c_data,
+ .addr.bytestring.len = &c_len,
+ .len = sizeof(c_data) },
+ [3] = { .attribute = NULL }
};
test_encode_data();
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_string_array.c b/encoding/cborattr/test/src/testcases/cborattr_decode_string_array.c
index d68e8dfaf..bf74135ad 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_string_array.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_string_array.c
@@ -29,9 +29,7 @@ static int test_cbor_len;
*/
static int test_cbor_wr(struct cbor_encoder_writer *, const char *, int);
static CborEncoder test_encoder;
-static struct cbor_encoder_writer test_writer = {
- .write = test_cbor_wr
-};
+static struct cbor_encoder_writer test_writer = { .write = test_cbor_wr };
static int
test_cbor_wr(struct cbor_encoder_writer *cew, const char *data, int len)
@@ -101,20 +99,16 @@ TEST_CASE(test_cborattr_decode_string_array)
char arr_data[256];
int arr_cnt = 0;
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = "a",
- .type = CborAttrArrayType,
- .addr.array.element_type = CborAttrTextStringType,
- .addr.array.arr.strings.ptrs = str_ptrs,
- .addr.array.arr.strings.store = arr_data,
- .addr.array.arr.strings.storelen = sizeof(arr_data),
- .addr.array.count = &arr_cnt,
- .addr.array.maxlen = sizeof(arr_data) / sizeof(arr_data[0]),
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "a",
+ .type = CborAttrArrayType,
+ .addr.array.element_type = CborAttrTextStringType,
+ .addr.array.arr.strings.ptrs = str_ptrs,
+ .addr.array.arr.strings.store = arr_data,
+ .addr.array.arr.strings.storelen = sizeof(arr_data),
+ .addr.array.count = &arr_cnt,
+ .addr.array.maxlen = sizeof(arr_data) / sizeof(arr_data[0]),
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
test_encode_string_array_one();
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_string_array_bounds.c b/encoding/cborattr/test/src/testcases/cborattr_decode_string_array_bounds.c
index b0a2ce432..4e4430ecd 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_string_array_bounds.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_string_array_bounds.c
@@ -68,15 +68,15 @@ TEST_CASE_SELF(test_cborattr_decode_string_array_bounds)
const struct cbor_attr_t attrs[] = {
{
- .attribute = "a",
- .type = CborAttrArrayType,
- .addr.array.element_type = CborAttrTextStringType,
- .addr.array.arr.strings.ptrs = ptrs,
- .addr.array.arr.strings.store = buf.store,
- .addr.array.arr.strings.storelen = sizeof(buf.store),
- .addr.array.count = &cnt,
- .addr.array.maxlen = 3,
- },
+ .attribute = "a",
+ .type = CborAttrArrayType,
+ .addr.array.element_type = CborAttrTextStringType,
+ .addr.array.arr.strings.ptrs = ptrs,
+ .addr.array.arr.strings.store = buf.store,
+ .addr.array.arr.strings.storelen = sizeof(buf.store),
+ .addr.array.count = &cnt,
+ .addr.array.maxlen = 3,
+ },
{ 0 },
};
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_string_bounds.c b/encoding/cborattr/test/src/testcases/cborattr_decode_string_bounds.c
index 8e399e0b2..0d4d99f7a 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_string_bounds.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_string_bounds.c
@@ -66,23 +66,23 @@ TEST_CASE_SELF(test_cborattr_decode_string_bounds)
const struct cbor_attr_t attrs[] = {
{
- .attribute = "s",
- .type = CborAttrTextStringType,
- .addr.string = s,
- .len = sizeof(s),
- },
+ .attribute = "s",
+ .type = CborAttrTextStringType,
+ .addr.string = s,
+ .len = sizeof(s),
+ },
{
- .attribute = "b",
- .type = CborAttrByteStringType,
- .addr.bytestring.data = b,
- .addr.bytestring.len = &b_len,
- .len = sizeof(b),
- },
+ .attribute = "b",
+ .type = CborAttrByteStringType,
+ .addr.bytestring.data = b,
+ .addr.bytestring.len = &b_len,
+ .len = sizeof(b),
+ },
{
- .attribute = "i",
- .type = CborAttrIntegerType,
- .addr.integer = &i,
- },
+ .attribute = "i",
+ .type = CborAttrIntegerType,
+ .addr.integer = &i,
+ },
{ 0 },
};
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_substring_key.c b/encoding/cborattr/test/src/testcases/cborattr_decode_substring_key.c
index 6eee7740c..c73611fad 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_substring_key.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_substring_key.c
@@ -29,9 +29,7 @@ static int test_cbor_len;
*/
static int test_cbor_wr(struct cbor_encoder_writer *, const char *, int);
static CborEncoder test_encoder;
-static struct cbor_encoder_writer test_writer = {
- .write = test_cbor_wr
-};
+static struct cbor_encoder_writer test_writer = { .write = test_cbor_wr };
static int
test_cbor_wr(struct cbor_encoder_writer *cew, const char *data, int len)
@@ -75,30 +73,22 @@ TEST_CASE(test_cborattr_decode_substring_key)
char test_str_2a[4] = { '\0' };
char test_str_3a[4] = { '\0' };
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = "aaa",
- .type = CborAttrTextStringType,
- .addr.string = test_str_3a,
- .len = sizeof(test_str_3a),
- .nodefault = true
- },
- [1] = {
- .attribute = "aa",
- .type = CborAttrTextStringType,
- .addr.string = test_str_2a,
- .len = sizeof(test_str_2a),
- .nodefault = true
- },
- [2] = {
- .attribute = "a",
- .type = CborAttrTextStringType,
- .addr.string = test_str_1a,
- .len = sizeof(test_str_1a),
- .nodefault = true
- },
- [3] = {
- .attribute = NULL
- }
+ [0] = { .attribute = "aaa",
+ .type = CborAttrTextStringType,
+ .addr.string = test_str_3a,
+ .len = sizeof(test_str_3a),
+ .nodefault = true },
+ [1] = { .attribute = "aa",
+ .type = CborAttrTextStringType,
+ .addr.string = test_str_2a,
+ .len = sizeof(test_str_2a),
+ .nodefault = true },
+ [2] = { .attribute = "a",
+ .type = CborAttrTextStringType,
+ .addr.string = test_str_1a,
+ .len = sizeof(test_str_1a),
+ .nodefault = true },
+ [3] = { .attribute = NULL }
};
test_encode_substring_key();
diff --git a/encoding/cborattr/test/src/testcases/cborattr_decode_unnamed_array.c b/encoding/cborattr/test/src/testcases/cborattr_decode_unnamed_array.c
index 0baf4ccb8..a17617213 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_decode_unnamed_array.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_decode_unnamed_array.c
@@ -29,9 +29,7 @@ static int test_cbor_len;
*/
static int test_cbor_wr(struct cbor_encoder_writer *, const char *, int);
static CborEncoder test_encoder;
-static struct cbor_encoder_writer test_writer = {
- .write = test_cbor_wr
-};
+static struct cbor_encoder_writer test_writer = { .write = test_cbor_wr };
static int
test_cbor_wr(struct cbor_encoder_writer *cew, const char *data, int len)
@@ -74,18 +72,14 @@ TEST_CASE(test_cborattr_decode_unnamed_array)
long long int arr_data[5];
int arr_cnt = 0;
struct cbor_attr_t test_attrs[] = {
- [0] = {
- .attribute = CBORATTR_ATTR_UNNAMED,
- .type = CborAttrArrayType,
- .addr.array.element_type = CborAttrIntegerType,
- .addr.array.arr.integers.store = arr_data,
- .addr.array.count = &arr_cnt,
- .addr.array.maxlen = sizeof(arr_data) / sizeof(arr_data[0]),
- .nodefault = true
- },
- [1] = {
- .attribute = NULL
- }
+ [0] = { .attribute = CBORATTR_ATTR_UNNAMED,
+ .type = CborAttrArrayType,
+ .addr.array.element_type = CborAttrIntegerType,
+ .addr.array.arr.integers.store = arr_data,
+ .addr.array.count = &arr_cnt,
+ .addr.array.maxlen = sizeof(arr_data) / sizeof(arr_data[0]),
+ .nodefault = true },
+ [1] = { .attribute = NULL }
};
test_encode_unnamed_array();
diff --git a/encoding/cborattr/test/src/testcases/cborattr_encode_omit.c b/encoding/cborattr/test/src/testcases/cborattr_encode_omit.c
index 7d6b91fc8..a264e102c 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_encode_omit.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_encode_omit.c
@@ -132,8 +132,7 @@ TEST_CASE_SELF(test_cborattr_encode_omit)
{ 0 }
};
const uint8_t exp[] = {
- 0xbf, 0x63, 0x73, 0x74, 0x72, 0x65, 0x6d, 0x79,
- 0x73, 0x74, 0x72, 0xff,
+ 0xbf, 0x63, 0x73, 0x74, 0x72, 0x65, 0x6d, 0x79, 0x73, 0x74, 0x72, 0xff,
};
cborattr_test_util_encode(attrs, exp, sizeof exp);
diff --git a/encoding/cborattr/test/src/testcases/cborattr_encode_simple.c b/encoding/cborattr/test/src/testcases/cborattr_encode_simple.c
index 1ddcf3cac..0a46c2d6b 100644
--- a/encoding/cborattr/test/src/testcases/cborattr_encode_simple.c
+++ b/encoding/cborattr/test/src/testcases/cborattr_encode_simple.c
@@ -122,21 +122,16 @@ TEST_CASE_SELF(test_cborattr_encode_simple)
{ 0 }
};
const uint8_t exp[] = {
- 0xbf, 0x64, 0x6e, 0x75, 0x6c, 0x6c, 0xf6, 0x64,
- 0x62, 0x6f, 0x6f, 0x6c, 0xf5, 0x63, 0x69, 0x6e,
- 0x74, 0x38, 0x62, 0x64, 0x75, 0x69, 0x6e, 0x74,
- 0x19, 0x20, 0xfa, 0x65, 0x66, 0x6c, 0x6f, 0x61,
- 0x74, 0xfa, 0x41, 0x00, 0x00, 0x00, 0x66, 0x64,
- 0x6f, 0x75, 0x62, 0x6c, 0x65, 0xfb, 0x40, 0x30,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x62,
- 0x79, 0x74, 0x65, 0x73, 0x43, 0x01, 0x02, 0x03,
- 0x63, 0x73, 0x74, 0x72, 0x65, 0x6d, 0x79, 0x73,
- 0x74, 0x72, 0x63, 0x61, 0x72, 0x72, 0x82, 0x19,
- 0x11, 0x03, 0xf4, 0x63, 0x6f, 0x62, 0x6a, 0xbf,
- 0x69, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x5f, 0x73,
- 0x74, 0x72, 0x66, 0x6d, 0x79, 0x73, 0x74, 0x72,
- 0x32, 0x69, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x5f,
- 0x69, 0x6e, 0x74, 0x18, 0x7b, 0xff, 0xff,
+ 0xbf, 0x64, 0x6e, 0x75, 0x6c, 0x6c, 0xf6, 0x64, 0x62, 0x6f, 0x6f, 0x6c,
+ 0xf5, 0x63, 0x69, 0x6e, 0x74, 0x38, 0x62, 0x64, 0x75, 0x69, 0x6e, 0x74,
+ 0x19, 0x20, 0xfa, 0x65, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0xfa, 0x41, 0x00,
+ 0x00, 0x00, 0x66, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0xfb, 0x40, 0x30,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x62, 0x79, 0x74, 0x65, 0x73,
+ 0x43, 0x01, 0x02, 0x03, 0x63, 0x73, 0x74, 0x72, 0x65, 0x6d, 0x79, 0x73,
+ 0x74, 0x72, 0x63, 0x61, 0x72, 0x72, 0x82, 0x19, 0x11, 0x03, 0xf4, 0x63,
+ 0x6f, 0x62, 0x6a, 0xbf, 0x69, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x5f, 0x73,
+ 0x74, 0x72, 0x66, 0x6d, 0x79, 0x73, 0x74, 0x72, 0x32, 0x69, 0x69, 0x6e,
+ 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x74, 0x18, 0x7b, 0xff, 0xff,
};
cborattr_test_util_encode(attrs, exp, sizeof exp);