Skip to content

Commit 186731b

Browse files
committed
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 <[email protected]>
1 parent a12baf8 commit 186731b

File tree

7 files changed

+18
-13
lines changed

7 files changed

+18
-13
lines changed

library/ecp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3639,7 +3639,7 @@ int mbedtls_ecp_self_test(int verbose)
36393639
#if defined(MBEDTLS_TEST_HOOKS)
36403640

36413641
MBEDTLS_STATIC_TESTABLE
3642-
mbedtls_ecp_variant mbedtls_ecp_get_variant()
3642+
mbedtls_ecp_variant mbedtls_ecp_get_variant(void)
36433643
{
36443644
return MBEDTLS_ECP_VARIANT_WITH_MPI_STRUCT;
36453645
}

programs/fuzz/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mbedtls_time_t dummy_constant_time(mbedtls_time_t *time)
1313
}
1414
#endif
1515

16-
void dummy_init()
16+
void dummy_init(void)
1717
{
1818
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
1919
mbedtls_platform_set_time(dummy_constant_time);

programs/fuzz/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ typedef struct fuzzBufferOffset {
1515
#if defined(MBEDTLS_HAVE_TIME)
1616
mbedtls_time_t dummy_constant_time(mbedtls_time_t *time);
1717
#endif
18-
void dummy_init();
18+
void dummy_init(void);
1919

2020
int dummy_send(void *ctx, const unsigned char *buf, size_t len);
2121
int fuzz_recv(void *ctx, unsigned char *buf, size_t len);

programs/ssl/ssl_context_info.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ const char buf_ln_err[] = "Buffer does not have enough data to complete the pars
125125
/*
126126
* Basic printing functions
127127
*/
128-
void print_version()
128+
void print_version(void)
129129
{
130130
printf("%s v%d.%d\n", PROG_NAME, VER_MAJOR, VER_MINOR);
131131
}
132132

133-
void print_usage()
133+
void print_usage(void)
134134
{
135135
print_version();
136136
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, ...)
179179
/*
180180
* Exit from the program in case of error
181181
*/
182-
void error_exit()
182+
void error_exit(void)
183183
{
184184
if (NULL != b64_file) {
185185
fclose(b64_file);

programs/test/udp_proxy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ void delay_packet(packet *delay)
644644
memcpy(&prev[prev_len++], delay, sizeof(packet));
645645
}
646646

647-
int send_delayed()
647+
int send_delayed(void)
648648
{
649649
uint8_t offset;
650650
int ret;

tests/scripts/generate_test_code.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,11 @@ def parse_function_code(funcs_f, dependencies, suite_dependencies):
667667
code = code.replace(name, 'test_' + name, 1)
668668
name = 'test_' + name
669669

670+
# If a test function has no arguments then add 'void' argument to
671+
# avoid "-Wstrict-prototypes" warnings from clang-16
672+
if len(args) == 0:
673+
code = code.replace('()', '(void)', 1)
674+
670675
for line in funcs_f:
671676
if re.search(END_CASE_REGEX, line):
672677
break

tests/scripts/test_generate_test_code.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ def test_return(self, parse_function_arguments_mock,
647647
self.assertEqual(arg, [])
648648
expected = '''#line 1 "test_suite_ut.function"
649649
650-
void test_func()
650+
void test_func(void)
651651
{
652652
ba ba black sheep
653653
have you any wool
@@ -690,7 +690,7 @@ def test_with_exit_label(self, parse_function_arguments_mock,
690690

691691
expected = '''#line 1 "test_suite_ut.function"
692692
693-
void test_func()
693+
void test_func(void)
694694
{
695695
ba ba black sheep
696696
have you any wool
@@ -750,7 +750,7 @@ def test_function_name_on_newline(self, parse_function_arguments_mock,
750750
void
751751
752752
753-
test_func()
753+
test_func(void)
754754
{
755755
ba ba black sheep
756756
have you any wool
@@ -803,7 +803,7 @@ def test_case_starting_with_comment(self, parse_function_arguments_mock,
803803
804804
805805
806-
void test_func()
806+
void test_func(void)
807807
{
808808
ba ba black sheep
809809
have you any wool
@@ -1139,7 +1139,7 @@ def test_parsing(self):
11391139
#if defined(MBEDTLS_ENTROPY_NV_SEED)
11401140
#if defined(MBEDTLS_FS_IO)
11411141
#line 13 "test_suite_ut.function"
1142-
void test_func1()
1142+
void test_func1(void)
11431143
{
11441144
exit:
11451145
;
@@ -1156,7 +1156,7 @@ def test_parsing(self):
11561156
#if defined(MBEDTLS_ENTROPY_NV_SEED)
11571157
#if defined(MBEDTLS_FS_IO)
11581158
#line 19 "test_suite_ut.function"
1159-
void test_func2()
1159+
void test_func2(void)
11601160
{
11611161
exit:
11621162
;

0 commit comments

Comments
 (0)