Skip to content

Commit

Permalink
testcases/containers: clone_args switch to named initializers
Browse files Browse the repository at this point in the history
After the addition of cgroup into the clone_args we got a bunch of
warnings, this commit fixes all of them.

The code was fixed with following coccinelle spatch:

@@
expression f;
identifier var;
@@
-const struct tst_clone_args var = { f, SIGCHLD };
+const struct tst_clone_args var = {
+	.flags = f,
+	.exit_signal = SIGCHLD,
+};

Fixes: 45f6916 ("clone3: Add clone3's clone_args cgroup")
Signed-off-by: Cyril Hrubis <[email protected]>
  • Loading branch information
metan-ucw committed Sep 14, 2023
1 parent a12f2c1 commit 688a7d1
Show file tree
Hide file tree
Showing 30 changed files with 122 additions and 32 deletions.
5 changes: 4 additions & 1 deletion testcases/kernel/containers/mountns/mountns01.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWNS, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWNS,
.exit_signal = SIGCHLD,
};

SAFE_UNSHARE(CLONE_NEWNS);

Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/mountns/mountns02.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWNS, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWNS,
.exit_signal = SIGCHLD,
};

SAFE_UNSHARE(CLONE_NEWNS);

Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/mountns/mountns03.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWNS, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWNS,
.exit_signal = SIGCHLD,
};

SAFE_UNSHARE(CLONE_NEWNS);

Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/mqns/mqns_01.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ static char *str_op;

static void run(void)
{
const struct tst_clone_args clone_args = { CLONE_NEWIPC, SIGCHLD };
const struct tst_clone_args clone_args = {
.flags = CLONE_NEWIPC,
.exit_signal = SIGCHLD,
};

tst_res(TINFO, "Checking namespaces isolation from parent to child");

Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/mqns/mqns_02.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ static void isolated_child(void)

static void run(void)
{
const struct tst_clone_args clone_args = { CLONE_NEWIPC, SIGCHLD };
const struct tst_clone_args clone_args = {
.flags = CLONE_NEWIPC,
.exit_signal = SIGCHLD,
};

tst_res(TINFO, "Checking namespaces isolation from parent to child");

Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns01.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};

if (!SAFE_CLONE(&args)) {
child_func();
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns02.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};

if (!SAFE_CLONE(&args)) {
child_func();
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns03.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ static void cleanup(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};

if (!SAFE_CLONE(&args)) {
child_func();
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns04.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};
pid_t pid;

pid = SAFE_CLONE(&args);
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns06.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ static void child_func(int pid)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};
pid_t pid = getpid();

if (!SAFE_CLONE(&args)) {
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns10.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};

if (!SAFE_CLONE(&args)) {
child_func();
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns12.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};
int pid;

pid = SAFE_CLONE(&args);
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns13.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ static void child_fn(unsigned int cinit_no)

static void run(void)
{
const struct tst_clone_args cargs = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args cargs = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};

SAFE_PIPE(pipe_fd);

Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns16.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};
pid_t pid;

signal_pid = -1;
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns17.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};

if (!SAFE_CLONE(&args)) {
child_func();
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns20.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ static void child_func(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};
int pid;

pid = SAFE_CLONE(&args);
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns30.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ static void cleanup(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};

remove_mqueue(mqd);
received = 0;
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns31.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ static void run(void)
pid_t cpid;
struct sigaction sa;
struct sigevent notif;
const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};

remove_mqueue(mqd);
received = 0;
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/pidns/pidns32.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

#define MAXNEST 32

static const struct tst_clone_args args = { CLONE_NEWPID, SIGCHLD };
static const struct tst_clone_args args = {
.flags = CLONE_NEWPID,
.exit_signal = SIGCHLD,
};
static int *level;

static pid_t child_func(void)
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/sysvipc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ static inline int get_clone_unshare_enum(const char *str_op)

static void clone_test(unsigned long clone_flags, void (*fn1)())
{
const struct tst_clone_args clone_args = { clone_flags, SIGCHLD };
const struct tst_clone_args clone_args = {
.flags = clone_flags,
.exit_signal = SIGCHLD,
};
int pid;

pid = SAFE_CLONE(&clone_args);
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/userns/userns01.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ static void setup(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWUSER, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWUSER,
.exit_signal = SIGCHLD,
};

if (!SAFE_CLONE(&args)) {
child_fn1();
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/userns/userns02.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ static void child_fn1(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWUSER, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWUSER,
.exit_signal = SIGCHLD,
};
int childpid;
int parentuid;
int parentgid;
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/userns/userns03.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ static void child_fn2(int cpid1, int parentuid, int parentgid)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWUSER, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWUSER,
.exit_signal = SIGCHLD,
};
pid_t cpid1, cpid2;
uid_t parentuid;
gid_t parentgid;
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/userns/userns04.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ static void child_fn2(int fd)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWUSER, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWUSER,
.exit_signal = SIGCHLD,
};
pid_t cpid1, cpid2, cpid3;
char path[BUFSIZ];
int fd;
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/userns/userns05.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ static unsigned int getusernsidbypid(int pid)
static void run(void)
{
const struct tst_clone_args args1 = { .exit_signal = SIGCHLD };
const struct tst_clone_args args2 = { CLONE_NEWUSER, SIGCHLD };
const struct tst_clone_args args2 = {
.flags = CLONE_NEWUSER,
.exit_signal = SIGCHLD,
};
int cpid1, cpid2, cpid3;
unsigned int parentuserns, cpid1userns, cpid2userns, newparentuserns;

Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/userns/userns06.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ static void child_fn2(void)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWUSER, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWUSER,
.exit_signal = SIGCHLD,
};
pid_t cpid1;
pid_t cpid2;
int parentuid;
Expand Down
10 changes: 8 additions & 2 deletions testcases/kernel/containers/userns/userns07.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

static void child_fn1(const int level)
{
const struct tst_clone_args args = { CLONE_NEWUSER, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWUSER,
.exit_signal = SIGCHLD,
};
pid_t cpid;
int parentuid;
int parentgid;
Expand Down Expand Up @@ -53,7 +56,10 @@ static void child_fn1(const int level)

static void run(void)
{
const struct tst_clone_args args = { CLONE_NEWUSER, SIGCHLD };
const struct tst_clone_args args = {
.flags = CLONE_NEWUSER,
.exit_signal = SIGCHLD,
};
pid_t cpid;
int parentuid;
int parentgid;
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/containers/userns/userns08.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
static pid_t clone_newuser(void)
{
const struct tst_clone_args cargs = {
CLONE_NEWUSER,
SIGCHLD
.flags = CLONE_NEWUSER,
.exit_signal = SIGCHLD,
};

return SAFE_CLONE(&cargs);
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/utsname/utsname03.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ static void child2_run(void)

static void run(void)
{
const struct tst_clone_args cargs = { CLONE_NEWUTS, SIGCHLD };
const struct tst_clone_args cargs = {
.flags = CLONE_NEWUTS,
.exit_signal = SIGCHLD,
};

memset(hostname1, 0, HOST_NAME_MAX);
memset(hostname2, 0, HOST_NAME_MAX);
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/containers/utsname/utsname04.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ static char *str_op;

static void run(void)
{
const struct tst_clone_args cargs = { CLONE_NEWUTS, SIGCHLD };
const struct tst_clone_args cargs = {
.flags = CLONE_NEWUTS,
.exit_signal = SIGCHLD,
};
struct passwd *pw;

tst_res(TINFO, "Dropping root privileges");
Expand Down

0 comments on commit 688a7d1

Please sign in to comment.