Skip to content

Commit

Permalink
Properly format changed code
Browse files Browse the repository at this point in the history
Make clang-format happy about the changes introduced in the last commit.
  • Loading branch information
rettichschnidi committed Mar 22, 2023
1 parent acf171a commit 0ef0a08
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 85 deletions.
3 changes: 1 addition & 2 deletions examples/client/lwm2mclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,7 @@ static void update_bootstrap_info(lwm2m_client_state_t * previousBootstrapState,
}
}

static void close_backup_object(void)
{
static void close_backup_object(void) {
int i;
for (i = 0; i < BACKUP_OBJECT_COUNT; i++) {
if (NULL != backupObjectArray[i]) {
Expand Down
3 changes: 1 addition & 2 deletions examples/client/object_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,7 @@ void display_device_object(lwm2m_object_t * object)
}
}

lwm2m_object_t * get_object_device(void)
{
lwm2m_object_t *get_object_device(void) {
/*
* The get_object_device function create the object itself and return a pointer to the structure that represent it.
*/
Expand Down
5 changes: 1 addition & 4 deletions examples/client/system_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ void init_value_change(lwm2m_context_t * lwm2m)
{
}

void system_reboot(void)
{
exit(1);
}
void system_reboot(void) { exit(1); }

#endif
3 changes: 1 addition & 2 deletions examples/lightclient/object_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ static uint8_t prv_device_execute(lwm2m_context_t * contextP,
return COAP_405_METHOD_NOT_ALLOWED;
}

lwm2m_object_t * get_object_device(void)
{
lwm2m_object_t *get_object_device(void) {
/*
* The get_object_device function create the object itself and return a pointer to the structure that represent it.
*/
Expand Down
3 changes: 1 addition & 2 deletions examples/lightclient/object_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ static uint8_t prv_security_read(lwm2m_context_t * contextP,
return result;
}

lwm2m_object_t * get_security_object(void)
{
lwm2m_object_t *get_security_object(void) {
lwm2m_object_t * securityObj;

securityObj = (lwm2m_object_t *)lwm2m_malloc(sizeof(lwm2m_object_t));
Expand Down
3 changes: 1 addition & 2 deletions examples/lightclient/object_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ static uint8_t prv_server_create(lwm2m_context_t * contextP,
return result;
}

lwm2m_object_t * get_server_object(void)
{
lwm2m_object_t *get_server_object(void) {
lwm2m_object_t * serverObj;

serverObj = (lwm2m_object_t *)lwm2m_malloc(sizeof(lwm2m_object_t));
Expand Down
17 changes: 7 additions & 10 deletions tests/convert_numbers_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,16 +462,13 @@ static struct TestTable table[] = {
{ NULL, NULL },
};

CU_ErrorCode create_convert_numbers_suit(void)
{
CU_pSuite pSuite = NULL;
CU_ErrorCode create_convert_numbers_suit(void) {
CU_pSuite pSuite = NULL;

pSuite = CU_add_suite("Suite_ConvertNumbers", NULL, NULL);
if (NULL == pSuite) {
return CU_get_error();
}
pSuite = CU_add_suite("Suite_ConvertNumbers", NULL, NULL);
if (NULL == pSuite) {
return CU_get_error();
}

return add_tests(pSuite, table);
return add_tests(pSuite, table);
}


17 changes: 7 additions & 10 deletions tests/tlv_json_lwm2m_data_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,13 @@ static struct TestTable table[] = {
{ NULL, NULL },
};

CU_ErrorCode create_tlv_json_suit(void)
{
CU_pSuite pSuite = NULL;
CU_ErrorCode create_tlv_json_suit(void) {
CU_pSuite pSuite = NULL;

pSuite = CU_add_suite("Suite_TLV_JSON", NULL, NULL);
if (NULL == pSuite) {
return CU_get_error();
}
pSuite = CU_add_suite("Suite_TLV_JSON", NULL, NULL);
if (NULL == pSuite) {
return CU_get_error();
}

return add_tests(pSuite, table);
return add_tests(pSuite, table);
}


43 changes: 18 additions & 25 deletions tests/tlvtests.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,16 @@ static void test_tlv_free(void)
lwm2m_data_free(10, dataP);
}

static void test_decodeTLV(void)
{
static void test_decodeTLV(void) {
uint8_t data1[] = {0xC3, 55, 1, 2, 3};
uint8_t data2[] = {0x28, 2, 3, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
uint8_t data3[0x194] = {0x90, 33, 1, 0x90 };
uint8_t data2[] = {0x28, 2, 3, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9};
uint8_t data3[0x194] = {0x90, 33, 1, 0x90};
lwm2m_data_type_t type;
uint16_t id = 0;
size_t index = 0;
size_t length = 0;
size_t index = 0;
size_t length = 0;
int result;


result = lwm2m_decode_TLV(data1, sizeof(data1) - 1, &type, &id, &index, &length);
CU_ASSERT_EQUAL(result, 0)

Expand Down Expand Up @@ -89,12 +87,13 @@ static void test_decodeTLV(void)
CU_ASSERT_EQUAL(length, 0x190)
}

static void test_tlv_parse(void)
{
static void test_tlv_parse(void) {
// Resource 55 {1, 2, 3}
uint8_t data1[] = {0xC3, 55, 1, 2, 3};
// Instance 0x203 {Resource 55 {1, 2, 3}, Resource 66 {4, 5, 6, 7, 8, 9, 10, 11, 12 } }
uint8_t data2[] = {0x28, 2, 3, 17, 0xC3, 55, 1, 2, 3, 0xC8, 66, 9, 4, 5, 6, 7, 8, 9, 10, 11, 12, };
uint8_t data2[] = {
0x28, 2, 3, 17, 0xC3, 55, 1, 2, 3, 0xC8, 66, 9, 4, 5, 6, 7, 8, 9, 10, 11, 12,
};
// Instance 11 {MultiResource 11 {ResourceInstance 0 {1, 2, 3}, ResourceInstance 1 {4, 5, 6, 7, 8, 9, ... } }
uint8_t data3[174] = {0x08, 11, 171, 0x88, 77, 168, 0x43, 0, 1, 2, 3, 0x48, 1, 160, 4, 5, 6, 7, 8, 9};
int result;
Expand Down Expand Up @@ -157,17 +156,14 @@ static void test_tlv_parse(void)
lwm2m_data_free(result, dataP);
}

static void test_tlv_serialize(void)
{
static void test_tlv_serialize(void) {
int result;
lwm2m_data_t *dataP;
lwm2m_data_t *tlvSubP;
lwm2m_data_t *tlvRscInstP;
uint8_t data1[] = {1, 2, 3, 4};
uint8_t data2[170] = {5, 6, 7, 8};
uint8_t* buffer;


uint8_t *buffer;

tlvSubP = lwm2m_data_new(2);
CU_ASSERT_PTR_NOT_NULL_FATAL(tlvSubP)
Expand Down Expand Up @@ -494,16 +490,13 @@ static struct TestTable table[] = {
{ NULL, NULL },
};

CU_ErrorCode create_tlv_suit(void)
{
CU_pSuite pSuite = NULL;
CU_ErrorCode create_tlv_suit(void) {
CU_pSuite pSuite = NULL;

pSuite = CU_add_suite("Suite_TLV", NULL, NULL);
if (NULL == pSuite) {
return CU_get_error();
}
pSuite = CU_add_suite("Suite_TLV", NULL, NULL);
if (NULL == pSuite) {
return CU_get_error();
}

return add_tests(pSuite, table);
return add_tests(pSuite, table);
}


33 changes: 16 additions & 17 deletions tests/unittests.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,28 @@ CU_ErrorCode add_tests(CU_pSuite pSuite, struct TestTable* testTable)
return CUE_SUCCESS;
}

int main(void)
{
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
int main(void) {
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();

if (CUE_SUCCESS != create_block1_suit())
goto exit;
if (CUE_SUCCESS != create_block1_suit())
goto exit;

if (CUE_SUCCESS != create_block2_suit())
goto exit;
if (CUE_SUCCESS != create_block2_suit())
goto exit;

if (CUE_SUCCESS != create_convert_numbers_suit())
goto exit;
if (CUE_SUCCESS != create_convert_numbers_suit())
goto exit;

if (CUE_SUCCESS != create_tlv_json_suit())
goto exit;
if (CUE_SUCCESS != create_tlv_json_suit())
goto exit;

if (CUE_SUCCESS != create_tlv_suit())
goto exit;
if (CUE_SUCCESS != create_tlv_suit())
goto exit;

if (CUE_SUCCESS != create_uri_suit())
goto exit;
if (CUE_SUCCESS != create_uri_suit())
goto exit;

#ifdef LWM2M_SUPPORT_SENML_JSON
if (CUE_SUCCESS != create_senml_json_suit())
Expand Down
16 changes: 7 additions & 9 deletions tests/uritests.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,13 @@ static struct TestTable table[] = {
{ NULL, NULL },
};

CU_ErrorCode create_uri_suit(void)
{
CU_pSuite pSuite = NULL;
CU_ErrorCode create_uri_suit(void) {
CU_pSuite pSuite = NULL;

pSuite = CU_add_suite("Suite_URI", NULL, NULL);
if (NULL == pSuite) {
return CU_get_error();
}
pSuite = CU_add_suite("Suite_URI", NULL, NULL);
if (NULL == pSuite) {
return CU_get_error();
}

return add_tests(pSuite, table);
return add_tests(pSuite, table);
}

0 comments on commit 0ef0a08

Please sign in to comment.