Re: [PATCH v2 06/10] selftests/nolibc: make functions static if possible

From: Willy Tarreau
Date: Tue Aug 01 2023 - 02:52:32 EST


On Tue, Aug 01, 2023 at 07:30:13AM +0200, Thomas Weißschuh wrote:
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index 1555759bb164..53a3773c7790 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -80,7 +80,7 @@ char *itoa(int i)
> /* returns the error name (e.g. "ENOENT") for common errors, "SUCCESS" for 0,
> * or the decimal value for less common ones.
> */
> -const char *errorname(int err)
> +static const char *errorname(int err)
> {
> switch (err) {
> case 0: return "SUCCESS";

OK for this one, even desired for such a use case.

> @@ -593,7 +593,7 @@ int expect_strne(const char *expr, int llen, const char *cmp)
> #define CASE_TEST(name) \
> case __LINE__: llen += printf("%d %s", test, #name);
>
> -int run_startup(int min, int max)
> +static int run_startup(int min, int max)
> {
> int test;
> int ret = 0;
> @@ -640,7 +640,7 @@ int run_startup(int min, int max)
>
>
> /* used by some syscall tests below */
> -int test_getdents64(const char *dir)
> +static int test_getdents64(const char *dir)
> {
> char buffer[4096];
> int fd, ret;
> @@ -734,7 +734,7 @@ static int test_stat_timestamps(void)
> return 0;
> }
>
> -int test_mmap_munmap(void)
> +static int test_mmap_munmap(void)
> {
> int ret, fd, i;
> void *mem;
> @@ -796,7 +796,7 @@ int test_mmap_munmap(void)
> /* Run syscall tests between IDs <min> and <max>.
> * Return 0 on success, non-zero on failure.
> */
> -int run_syscall(int min, int max)
> +static int run_syscall(int min, int max)
> {
> struct timeval tv;
> struct timezone tz;
> @@ -907,7 +907,7 @@ int run_syscall(int min, int max)
> return ret;
> }
>
> -int run_stdlib(int min, int max)
> +static int run_stdlib(int min, int max)
> {
> int test;
> int ret = 0;
> @@ -1141,7 +1141,7 @@ static int run_protection(int min, int max)
> }
>
> /* prepare what needs to be prepared for pid 1 (stdio, /dev, /proc, etc) */
> -int prepare(void)
> +static int prepare(void)
> {
> struct stat stat_buf;
>
> @@ -1208,7 +1208,7 @@ static const struct test test_names[] = {
> { 0 }
> };

For these ones it will prevent gcc from putting breakpoints there, which
is counter-productive.

> -int is_setting_valid(char *test)
> +static int is_setting_valid(char *test)
> {
> int idx, len, test_len, valid = 0;
> char delimiter;

OK for this one.

Willy