Fix warnings from clang-16

Running clang-16 on mbedtls reports warnings of type "-Wstrict-prototypes".
This patch fixes these warnings by adding void to functions with no
arguments. The generate_test_code.py is modified to insert void into test
functions with no arguments in *.function files.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
This commit is contained in:
Gowtham Suresh Kumar 2023-07-26 15:47:45 +01:00
parent a12baf8c5f
commit 186731b22a
7 changed files with 18 additions and 13 deletions

View file

@ -3639,7 +3639,7 @@ cleanup:
#if defined(MBEDTLS_TEST_HOOKS) #if defined(MBEDTLS_TEST_HOOKS)
MBEDTLS_STATIC_TESTABLE MBEDTLS_STATIC_TESTABLE
mbedtls_ecp_variant mbedtls_ecp_get_variant() mbedtls_ecp_variant mbedtls_ecp_get_variant(void)
{ {
return MBEDTLS_ECP_VARIANT_WITH_MPI_STRUCT; return MBEDTLS_ECP_VARIANT_WITH_MPI_STRUCT;
} }

View file

@ -13,7 +13,7 @@ mbedtls_time_t dummy_constant_time(mbedtls_time_t *time)
} }
#endif #endif
void dummy_init() void dummy_init(void)
{ {
#if defined(MBEDTLS_PLATFORM_TIME_ALT) #if defined(MBEDTLS_PLATFORM_TIME_ALT)
mbedtls_platform_set_time(dummy_constant_time); mbedtls_platform_set_time(dummy_constant_time);

View file

@ -15,7 +15,7 @@ typedef struct fuzzBufferOffset {
#if defined(MBEDTLS_HAVE_TIME) #if defined(MBEDTLS_HAVE_TIME)
mbedtls_time_t dummy_constant_time(mbedtls_time_t *time); mbedtls_time_t dummy_constant_time(mbedtls_time_t *time);
#endif #endif
void dummy_init(); void dummy_init(void);
int dummy_send(void *ctx, const unsigned char *buf, size_t len); int dummy_send(void *ctx, const unsigned char *buf, size_t len);
int fuzz_recv(void *ctx, unsigned char *buf, size_t len); int fuzz_recv(void *ctx, unsigned char *buf, size_t len);

View file

@ -125,12 +125,12 @@ const char buf_ln_err[] = "Buffer does not have enough data to complete the pars
/* /*
* Basic printing functions * Basic printing functions
*/ */
void print_version() void print_version(void)
{ {
printf("%s v%d.%d\n", PROG_NAME, VER_MAJOR, VER_MINOR); printf("%s v%d.%d\n", PROG_NAME, VER_MAJOR, VER_MINOR);
} }
void print_usage() void print_usage(void)
{ {
print_version(); print_version();
printf("\nThis program is used to deserialize an Mbed TLS SSL session from the base64 code provided\n" printf("\nThis program is used to deserialize an Mbed TLS SSL session from the base64 code provided\n"
@ -179,7 +179,7 @@ void printf_err(const char *str, ...)
/* /*
* Exit from the program in case of error * Exit from the program in case of error
*/ */
void error_exit() void error_exit(void)
{ {
if (NULL != b64_file) { if (NULL != b64_file) {
fclose(b64_file); fclose(b64_file);

View file

@ -644,7 +644,7 @@ void delay_packet(packet *delay)
memcpy(&prev[prev_len++], delay, sizeof(packet)); memcpy(&prev[prev_len++], delay, sizeof(packet));
} }
int send_delayed() int send_delayed(void)
{ {
uint8_t offset; uint8_t offset;
int ret; int ret;

View file

@ -667,6 +667,11 @@ def parse_function_code(funcs_f, dependencies, suite_dependencies):
code = code.replace(name, 'test_' + name, 1) code = code.replace(name, 'test_' + name, 1)
name = 'test_' + name name = 'test_' + name
# If a test function has no arguments then add 'void' argument to
# avoid "-Wstrict-prototypes" warnings from clang-16
if len(args) == 0:
code = code.replace('()', '(void)', 1)
for line in funcs_f: for line in funcs_f:
if re.search(END_CASE_REGEX, line): if re.search(END_CASE_REGEX, line):
break break

View file

@ -647,7 +647,7 @@ void func()
self.assertEqual(arg, []) self.assertEqual(arg, [])
expected = '''#line 1 "test_suite_ut.function" expected = '''#line 1 "test_suite_ut.function"
void test_func() void test_func(void)
{ {
ba ba black sheep ba ba black sheep
have you any wool have you any wool
@ -690,7 +690,7 @@ exit:
expected = '''#line 1 "test_suite_ut.function" expected = '''#line 1 "test_suite_ut.function"
void test_func() void test_func(void)
{ {
ba ba black sheep ba ba black sheep
have you any wool have you any wool
@ -750,7 +750,7 @@ exit:
void void
test_func() test_func(void)
{ {
ba ba black sheep ba ba black sheep
have you any wool have you any wool
@ -803,7 +803,7 @@ exit:
void test_func() void test_func(void)
{ {
ba ba black sheep ba ba black sheep
have you any wool have you any wool
@ -1139,7 +1139,7 @@ void func2()
#if defined(MBEDTLS_ENTROPY_NV_SEED) #if defined(MBEDTLS_ENTROPY_NV_SEED)
#if defined(MBEDTLS_FS_IO) #if defined(MBEDTLS_FS_IO)
#line 13 "test_suite_ut.function" #line 13 "test_suite_ut.function"
void test_func1() void test_func1(void)
{ {
exit: exit:
; ;
@ -1156,7 +1156,7 @@ void test_func1_wrapper( void ** params )
#if defined(MBEDTLS_ENTROPY_NV_SEED) #if defined(MBEDTLS_ENTROPY_NV_SEED)
#if defined(MBEDTLS_FS_IO) #if defined(MBEDTLS_FS_IO)
#line 19 "test_suite_ut.function" #line 19 "test_suite_ut.function"
void test_func2() void test_func2(void)
{ {
exit: exit:
; ;