Message ID | c6447da51a94babc1931711a43e2ceecb135c93d.1721713597.git.tony.ambardar@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | ec4fe2f0fa12fd2d0115df7e58414dc26899cc5e |
Headers | show |
Series | selftests/bpf: Improve libc portability / musl support (part 1) | expand |
On Mon, 2024-07-22 at 22:54 -0700, Tony Ambardar wrote: > Use pid_t rather than __pid_t when allocating memory for > 'worker_pids' in > 'struct test_env', as this is its declared type and also avoids > compile > errors seen building against musl libc on mipsel64: > > test_progs.c:1738:49: error: '__pid_t' undeclared (first use in > this function); did you mean 'pid_t'? > 1738 | env.worker_pids = calloc(sizeof(__pid_t), > env.workers); > | ^~~~~~~ > | pid_t > test_progs.c:1738:49: note: each undeclared identifier is reported > only once for each function it appears in > > Fixes: 91b2c0afd00c ("selftests/bpf: Add parallelism to test_progs") > Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com> > --- > tools/testing/selftests/bpf/test_progs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/bpf/test_progs.c > b/tools/testing/selftests/bpf/test_progs.c > index 1677f6f1eaae..091b49bf671a 100644 > --- a/tools/testing/selftests/bpf/test_progs.c > +++ b/tools/testing/selftests/bpf/test_progs.c > @@ -1738,7 +1738,7 @@ int main(int argc, char **argv) > /* launch workers if requested */ > env.worker_id = -1; /* main process */ > if (env.workers) { > - env.worker_pids = calloc(sizeof(__pid_t), > env.workers); > + env.worker_pids = calloc(sizeof(pid_t), > env.workers); Yes, "pid_t" is much better. "worker_pids" dose define as "pid_t" in test_progs.h: struct test_env { ... ... pid_t *worker_pids; /* array of worker pids */ ... ... }; Acked-by: Geliang Tang <geliang@kernel.org> > env.worker_socks = calloc(sizeof(int), env.workers); > if (env.debug) > fprintf(stdout, "Launching %d workers.\n", > env.workers);
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index 1677f6f1eaae..091b49bf671a 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -1738,7 +1738,7 @@ int main(int argc, char **argv) /* launch workers if requested */ env.worker_id = -1; /* main process */ if (env.workers) { - env.worker_pids = calloc(sizeof(__pid_t), env.workers); + env.worker_pids = calloc(sizeof(pid_t), env.workers); env.worker_socks = calloc(sizeof(int), env.workers); if (env.debug) fprintf(stdout, "Launching %d workers.\n", env.workers);
Use pid_t rather than __pid_t when allocating memory for 'worker_pids' in 'struct test_env', as this is its declared type and also avoids compile errors seen building against musl libc on mipsel64: test_progs.c:1738:49: error: '__pid_t' undeclared (first use in this function); did you mean 'pid_t'? 1738 | env.worker_pids = calloc(sizeof(__pid_t), env.workers); | ^~~~~~~ | pid_t test_progs.c:1738:49: note: each undeclared identifier is reported only once for each function it appears in Fixes: 91b2c0afd00c ("selftests/bpf: Add parallelism to test_progs") Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com> --- tools/testing/selftests/bpf/test_progs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)