Skip to content

Commit

Permalink
Enforce prototypes on functions
Browse files Browse the repository at this point in the history
This is the first warning we actually enforce. Hopefully, many more will
follow.
  • Loading branch information
rettichschnidi committed Mar 22, 2023
1 parent 0f3267f commit acf171a
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion coap/er-coap-13/er-coap-13.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ coap_get_variable(const uint8_t *buffer, size_t length, const char *name, const

/*-----------------------------------------------------------------------------------*/
uint16_t
coap_get_mid()
coap_get_mid(void)
{
return ++current_mid;
}
Expand Down
2 changes: 1 addition & 1 deletion core/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool lwm2m_set_coap_block_size(const uint16_t coap_block_size_arg) {
return false;
}

uint16_t lwm2m_get_coap_block_size() { return coap_block_size; }
uint16_t lwm2m_get_coap_block_size(void) { return coap_block_size; }

static void handle_reset(lwm2m_context_t * contextP,
void * fromSessionH,
Expand Down
2 changes: 1 addition & 1 deletion examples/client/lwm2mclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ static void update_bootstrap_info(lwm2m_client_state_t * previousBootstrapState,
}
}

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

lwm2m_object_t * get_object_device()
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
2 changes: 1 addition & 1 deletion examples/client/system_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void init_value_change(lwm2m_context_t * lwm2m)
{
}

void system_reboot()
void system_reboot(void)
{
exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lightclient/object_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static uint8_t prv_device_execute(lwm2m_context_t * contextP,
return COAP_405_METHOD_NOT_ALLOWED;
}

lwm2m_object_t * get_object_device()
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
2 changes: 1 addition & 1 deletion examples/lightclient/object_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static uint8_t prv_security_read(lwm2m_context_t * contextP,
return result;
}

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

Expand Down
2 changes: 1 addition & 1 deletion examples/lightclient/object_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static uint8_t prv_server_create(lwm2m_context_t * contextP,
return result;
}

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

Expand Down
2 changes: 1 addition & 1 deletion tests/block1tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static struct TestTable table[] = {
{NULL, NULL},
};

CU_ErrorCode create_block1_suit() {
CU_ErrorCode create_block1_suit(void) {
CU_pSuite pSuite = NULL;
pSuite = CU_add_suite("Suite_block1", NULL, NULL);

Expand Down
2 changes: 1 addition & 1 deletion tests/block2tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static struct TestTable table[] = {
{NULL, NULL},
};

CU_ErrorCode create_block2_suit() {
CU_ErrorCode create_block2_suit(void) {
CU_pSuite pSuite = NULL;
pSuite = CU_add_suite("Suite_block2", NULL, NULL);

Expand Down
2 changes: 1 addition & 1 deletion tests/convert_numbers_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ static struct TestTable table[] = {
{ NULL, NULL },
};

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

Expand Down
16 changes: 8 additions & 8 deletions tests/tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ struct TestTable {
};

CU_ErrorCode add_tests(CU_pSuite pSuite, struct TestTable* testTable);
CU_ErrorCode create_uri_suit();
CU_ErrorCode create_tlv_suit();
CU_ErrorCode create_object_read_suit();
CU_ErrorCode create_convert_numbers_suit();
CU_ErrorCode create_tlv_json_suit();
CU_ErrorCode create_block1_suit();
CU_ErrorCode create_uri_suit(void);
CU_ErrorCode create_tlv_suit(void);
CU_ErrorCode create_object_read_suit(void);
CU_ErrorCode create_convert_numbers_suit(void);
CU_ErrorCode create_tlv_json_suit(void);
CU_ErrorCode create_block1_suit(void);
CU_ErrorCode create_block2_suit(void);
#ifdef LWM2M_SUPPORT_SENML_JSON
CU_ErrorCode create_senml_json_suit();
CU_ErrorCode create_senml_json_suit(void);
#endif
CU_ErrorCode create_er_coap_parse_message_suit();
CU_ErrorCode create_er_coap_parse_message_suit(void);

#endif /* TESTS_H_ */
2 changes: 1 addition & 1 deletion tests/tlv_json_lwm2m_data_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static struct TestTable table[] = {
{ NULL, NULL },
};

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

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

static void test_decodeTLV()
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 };
Expand Down Expand Up @@ -89,7 +89,7 @@ static void test_decodeTLV()
CU_ASSERT_EQUAL(length, 0x190)
}

static void test_tlv_parse()
static void test_tlv_parse(void)
{
// Resource 55 {1, 2, 3}
uint8_t data1[] = {0xC3, 55, 1, 2, 3};
Expand Down Expand Up @@ -157,7 +157,7 @@ static void test_tlv_parse()
lwm2m_data_free(result, dataP);
}

static void test_tlv_serialize()
static void test_tlv_serialize(void)
{
int result;
lwm2m_data_t *dataP;
Expand Down Expand Up @@ -494,7 +494,7 @@ static struct TestTable table[] = {
{ NULL, NULL },
};

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

Expand Down
2 changes: 1 addition & 1 deletion tests/unittests.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ CU_ErrorCode add_tests(CU_pSuite pSuite, struct TestTable* testTable)
return CUE_SUCCESS;
}

int main()
int main(void)
{
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
Expand Down
2 changes: 1 addition & 1 deletion tests/uritests.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static struct TestTable table[] = {
{ NULL, NULL },
};

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

Expand Down
5 changes: 5 additions & 0 deletions wakaama.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ add_compile_options(
-pedantic
)

# Turn certain warnings into errors
add_compile_options(
-Werror=strict-prototypes
)

# The maximum buffer size that is provided for resource responses and must be respected due to the limited IP buffer.
# Larger data must be handled by the resource and will be sent chunk-wise through a TCP stream or CoAP blocks. Block
# size is set to 1024 bytes if not specified otherwise to avoid block transfers in common use cases.
Expand Down

0 comments on commit acf171a

Please sign in to comment.