aboutgitcodelistschat:MatrixIRC
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-02-22 10:40:09 +0100
committerAlice Frosi <afrosi@redhat.com>2023-02-22 10:40:09 +0100
commitba9623361f74be93674f2862903a39ae6d48e96e (patch)
tree518766500b31e8d25dbf5c29fc4a2673685b4e7a
parentd7ecb9bf478d53132540079deceab11dbe750947 (diff)
downloadseitan-ba9623361f74be93674f2862903a39ae6d48e96e.tar
seitan-ba9623361f74be93674f2862903a39ae6d48e96e.tar.gz
seitan-ba9623361f74be93674f2862903a39ae6d48e96e.tar.bz2
seitan-ba9623361f74be93674f2862903a39ae6d48e96e.tar.lz
seitan-ba9623361f74be93674f2862903a39ae6d48e96e.tar.xz
seitan-ba9623361f74be93674f2862903a39ae6d48e96e.tar.zst
seitan-ba9623361f74be93674f2862903a39ae6d48e96e.zip
fix formatting
-rw-r--r--actions.c30
-rw-r--r--actions.h13
-rw-r--r--common.h1
-rw-r--r--eater.c8
-rw-r--r--gluten.h5
-rw-r--r--seitan.c60
-rw-r--r--tests/unit/test_action_call.c142
-rw-r--r--tests/unit/test_actions.c67
8 files changed, 171 insertions, 155 deletions
diff --git a/actions.c b/actions.c
index 35d8e07..bfdd5b1 100644
--- a/actions.c
+++ b/actions.c
@@ -25,7 +25,8 @@ static bool is_cookie_valid(int notifyFd, uint64_t id)
static int send_target(const struct seccomp_notif_resp *resp, int notifyfd)
{
if (!is_cookie_valid(notifyfd, resp->id)) {
- fprintf(stderr, "the response id isn't valid\ncheck if the targets has already terminated\n");
+ fprintf(stderr,
+ "the response id isn't valid\ncheck if the targets has already terminated\n");
return -1;
}
if (ioctl(notifyfd, SECCOMP_IOCTL_NOTIF_SEND, resp) < 0) {
@@ -41,7 +42,8 @@ static int send_inject_target(const struct seccomp_notif_addfd *resp,
int notifyfd)
{
if (!is_cookie_valid(notifyfd, resp->id)) {
- fprintf(stderr, "the response id isn't valid\ncheck if the targets has already terminated\n");
+ fprintf(stderr,
+ "the response id isn't valid\ncheck if the targets has already terminated\n");
return -1;
}
if (ioctl(notifyfd, SECCOMP_IOCTL_NOTIF_ADDFD, resp) < 0) {
@@ -164,8 +166,8 @@ int do_call(struct arg_clone *c)
return 0;
}
-static void set_inject_fields(uint64_t id, void *data,
- const struct action *a,struct seccomp_notif_addfd *resp)
+static void set_inject_fields(uint64_t id, void *data, const struct action *a,
+ struct seccomp_notif_addfd *resp)
{
const struct fd_type *new = &(a->inj).newfd;
const struct fd_type *old = &(a->inj).oldfd;
@@ -176,17 +178,17 @@ static void set_inject_fields(uint64_t id, void *data,
resp->newfd = new->fd;
else
memcpy(&resp->srcfd, (uint16_t *)data + old->fd_off,
- sizeof(resp->srcfd));
+ sizeof(resp->srcfd));
if (old->type == IMMEDIATE)
resp->srcfd = old->fd;
else
memcpy(&resp->srcfd, (uint16_t *)data + old->fd_off,
- sizeof(resp->srcfd));
+ sizeof(resp->srcfd));
resp->newfd_flags = 0;
}
-int do_actions(void *data, struct action actions[], unsigned int n_actions, int pid,
- int notifyfd, uint64_t id)
+int do_actions(void *data, struct action actions[], unsigned int n_actions,
+ int pid, int notifyfd, uint64_t id)
{
struct seccomp_notif_addfd resp_fd;
struct seccomp_notif_resp resp;
@@ -216,8 +218,9 @@ int do_actions(void *data, struct action actions[], unsigned int n_actions, int
* reference
*/
if (actions[i].call.has_ret) {
- memcpy((uint16_t *)data + actions[i].call.ret_off,
- &c.ret, sizeof(c.ret));
+ memcpy((uint16_t *)data +
+ actions[i].call.ret_off,
+ &c.ret, sizeof(c.ret));
}
break;
case A_BLOCK:
@@ -235,9 +238,10 @@ int do_actions(void *data, struct action actions[], unsigned int n_actions, int
if (actions[i].ret.type == IMMEDIATE)
resp.val = actions[i].ret.value;
else
- memcpy(&resp.val, (uint16_t *)data +
- actions[i].ret.value_off,
- sizeof(resp.val));
+ memcpy(&resp.val,
+ (uint16_t *)data +
+ actions[i].ret.value_off,
+ sizeof(resp.val));
if (send_target(&resp, notifyfd) == -1)
return -1;
diff --git a/actions.h b/actions.h
index 521bdaf..c3376b7 100644
--- a/actions.h
+++ b/actions.h
@@ -7,14 +7,13 @@
#define NS_NUM (sizeof(enum ns_type))
struct arg_clone {
- const struct act_call *args;
- pid_t pid;
- long ret;
- int err;
+ const struct act_call *args;
+ pid_t pid;
+ long ret;
+ int err;
};
int do_call(struct arg_clone *c);
-int do_actions(void *data, struct action actions[], unsigned int n_actions, int tpid,
- int notifyfd, uint64_t id);
+int do_actions(void *data, struct action actions[], unsigned int n_actions,
+ int tpid, int notifyfd, uint64_t id);
#endif /* ACTIONS_H */
-
diff --git a/common.h b/common.h
index eb1093d..487032b 100644
--- a/common.h
+++ b/common.h
@@ -4,4 +4,3 @@
int find_fd_seccomp_notifier(const char *pid);
#endif
-
diff --git a/eater.c b/eater.c
index 26250d8..c15c4ee 100644
--- a/eater.c
+++ b/eater.c
@@ -81,7 +81,9 @@ static int seccomp(unsigned int operation, unsigned int flags, void *args)
return syscall(__NR_seccomp, operation, flags, args);
}
-static void signal_handler(__attribute__((unused))int s){}
+static void signal_handler(__attribute__((unused)) int s)
+{
+}
/**
* main() - Entry point
@@ -111,7 +113,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
if (seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_NEW_LISTENER,
- &prog) < 0) {
+ &prog) < 0) {
perror("seccomp");
exit(EXIT_FAILURE);
}
@@ -131,7 +133,7 @@ int main(int argc, char **argv)
pause();
execvpe(argv[arguments.program_index], &argv[arguments.program_index],
- environ);
+ environ);
if (errno != ENOENT) {
perror("execvpe");
exit(EXIT_FAILURE);
diff --git a/gluten.h b/gluten.h
index fab1613..e027923 100644
--- a/gluten.h
+++ b/gluten.h
@@ -53,8 +53,8 @@ enum action_type {
};
enum value_type {
- IMMEDIATE,
- REFERENCE,
+ IMMEDIATE,
+ REFERENCE,
};
struct act_call {
@@ -87,7 +87,6 @@ struct fd_type {
uint32_t fd;
uint16_t fd_off;
};
-
};
struct act_inject {
diff --git a/seitan.c b/seitan.c
index 96662e0..2c67890 100644
--- a/seitan.c
+++ b/seitan.c
@@ -86,23 +86,24 @@ static struct argp argp = { .options = options,
static int nl_init(void)
{
int s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
- struct sockaddr_nl sa = { .nl_family = AF_NETLINK,
- .nl_groups = CN_IDX_PROC,
- .nl_pid = getpid(),
- };
+ struct sockaddr_nl sa = {
+ .nl_family = AF_NETLINK,
+ .nl_groups = CN_IDX_PROC,
+ .nl_pid = getpid(),
+ };
struct req_t {
struct nlmsghdr nlh;
struct cn_msg cnm;
enum proc_cn_mcast_op mop;
- } __attribute__ ((packed, aligned(NLMSG_ALIGNTO))) req = {
- .nlh.nlmsg_type = NLMSG_DONE,
- .nlh.nlmsg_pid = getpid(),
+ } __attribute__((packed, aligned(NLMSG_ALIGNTO))) req = {
+ .nlh.nlmsg_type = NLMSG_DONE,
+ .nlh.nlmsg_pid = getpid(),
- .cnm.id.idx = CN_IDX_PROC,
- .cnm.id.val = CN_VAL_PROC,
- .cnm.len = sizeof(enum proc_cn_mcast_op),
+ .cnm.id.idx = CN_IDX_PROC,
+ .cnm.id.val = CN_VAL_PROC,
+ .cnm.len = sizeof(enum proc_cn_mcast_op),
- .mop = PROC_CN_MCAST_LISTEN,
+ .mop = PROC_CN_MCAST_LISTEN,
};
bind(s, (struct sockaddr *)&sa, sizeof(sa));
@@ -172,12 +173,13 @@ struct table {
static struct table t[16];
static int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
- unsigned int flags)
+ unsigned int flags)
{
return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags);
}
-static void unblock_eater(int pidfd){
+static void unblock_eater(int pidfd)
+{
if (pidfd_send_signal(pidfd, SIGCONT, NULL, 0) == -1) {
perror("pidfd_send_signal");
exit(EXIT_FAILURE);
@@ -197,10 +199,10 @@ int handle(struct seccomp_notif *req, int notifyfd)
break;
}
- if (i == sizeof(t) / sizeof(t[0])) /* Not found */
+ if (i == sizeof(t) / sizeof(t[0])) /* Not found */
return 1;
- if (t[i].type != FD1_UNIX) /* Not implemented yet */
+ if (t[i].type != FD1_UNIX) /* Not implemented yet */
return 1;
/* FD1_UNIX here */
@@ -215,9 +217,13 @@ int handle(struct seccomp_notif *req, int notifyfd)
if (!strcmp(s_un.sun_path, t[i].arg[0])) {
int own_fd = socket(AF_UNIX, SOCK_STREAM, 0);
- struct seccomp_notif_addfd addfd = { .id = req->id,
- .flags = SECCOMP_ADDFD_FLAG_SEND | SECCOMP_ADDFD_FLAG_SETFD,
- .srcfd = own_fd, .newfd = fd_unix, };
+ struct seccomp_notif_addfd addfd = {
+ .id = req->id,
+ .flags = SECCOMP_ADDFD_FLAG_SEND |
+ SECCOMP_ADDFD_FLAG_SETFD,
+ .srcfd = own_fd,
+ .newfd = fd_unix,
+ };
connect(own_fd, &s_un, sizeof(s_un));
ioctl(notifyfd, SECCOMP_IOCTL_NOTIF_ADDFD, &addfd);
@@ -229,7 +235,6 @@ int handle(struct seccomp_notif *req, int notifyfd)
int main(int argc, char **argv)
{
-
int s = nl_init(), ret, pidfd, notifier;
char resp_b[BUFSIZ], req_b[BUFSIZ];
struct epoll_event ev, events[EPOLL_EVENTS];
@@ -240,7 +245,7 @@ int main(int argc, char **argv)
bool running = true;
int fd, epollfd;
int notifierfd;
- int nevents,i;
+ int nevents, i;
arguments.pid = -1;
argp_parse(&argp, argc, argv, 0, 0, &arguments);
@@ -249,7 +254,8 @@ int main(int argc, char **argv)
close(fd);
if (arguments.pid < 0)
- while ((ret = event(s)) == -EAGAIN);
+ while ((ret = event(s)) == -EAGAIN)
+ ;
else
ret = arguments.pid;
@@ -262,7 +268,7 @@ int main(int argc, char **argv)
sleep(1);
snprintf(path, sizeof(path), "/proc/%d/fd", ret);
- if ((notifierfd = find_fd_seccomp_notifier(path)) < 0){
+ if ((notifierfd = find_fd_seccomp_notifier(path)) < 0) {
fprintf(stderr, "failed getting fd of the notifier\n");
exit(EXIT_FAILURE);
}
@@ -278,15 +284,15 @@ int main(int argc, char **argv)
ev.events = EPOLLIN;
ev.data.fd = notifier;
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, notifier, &ev) == -1) {
- perror("epoll_ctl: notifier");
- exit(EXIT_FAILURE);
- }
+ perror("epoll_ctl: notifier");
+ exit(EXIT_FAILURE);
+ }
/* Unblock seitan-loader */
unblock_eater(pidfd);
- while(running) {
+ while (running) {
nevents = epoll_wait(epollfd, events, EPOLL_EVENTS, -1);
- if (nevents < 0 ) {
+ if (nevents < 0) {
perror("epoll_wait");
exit(EXIT_FAILURE);
}
diff --git a/tests/unit/test_action_call.c b/tests/unit/test_action_call.c
index b039c8a..8621174 100644
--- a/tests/unit/test_action_call.c
+++ b/tests/unit/test_action_call.c
@@ -21,14 +21,13 @@ struct args_write_file {
ssize_t size;
};
-
static void write_file(char *file, char *t, ssize_t size)
{
int fd;
- fd = open(file, O_CREAT | O_RDWR, S_IWUSR |S_IRUSR);
+ fd = open(file, O_CREAT | O_RDWR, S_IWUSR | S_IRUSR);
ck_assert_int_ge(fd, -1);
- write(fd,t, size);
+ write(fd, t, size);
close(fd);
}
@@ -37,9 +36,9 @@ static int write_file_get_fd(char *file, char *t, ssize_t size)
int fd;
write_file(file, t, size);
- fd = open(file, O_RDONLY, S_IWUSR);
- unlink(file);
- return fd;
+ fd = open(file, O_RDONLY, S_IWUSR);
+ unlink(file);
+ return fd;
}
static int write_file_clone(void *a)
@@ -57,44 +56,44 @@ static pid_t create_func_ns(int (*fn)(void *), void *arg, struct ns_spec ns[])
int flags = SIGCHLD;
unsigned int i;
- for (i=0; i < sizeof(sizeof(enum ns_type)); i++)
- {
+ for (i = 0; i < sizeof(sizeof(enum ns_type)); i++) {
if (ns[i].type == NS_NONE)
continue;
- switch(i){
- case NS_CGROUP:
- flags |= CLONE_NEWCGROUP;
- break;
- case NS_IPC:
- flags |= CLONE_NEWIPC;
- break;
- case NS_NET:
- flags |= CLONE_NEWNET;
- break;
- case NS_MOUNT:
- flags |= CLONE_NEWNS;
- break;
- case NS_PID:
- flags |= CLONE_NEWPID;
- break;
- case NS_USER:
- flags |= CLONE_NEWUSER;
- break;
- case NS_UTS:
- flags |= CLONE_NEWUTS;
- break;
- case NS_TIME:
- fprintf(stderr, "option NS_TIME not suppoted by clone\n");
- break;
- default:
- fprintf(stderr, "unrecognized option %d\n", i);
+ switch (i) {
+ case NS_CGROUP:
+ flags |= CLONE_NEWCGROUP;
+ break;
+ case NS_IPC:
+ flags |= CLONE_NEWIPC;
+ break;
+ case NS_NET:
+ flags |= CLONE_NEWNET;
+ break;
+ case NS_MOUNT:
+ flags |= CLONE_NEWNS;
+ break;
+ case NS_PID:
+ flags |= CLONE_NEWPID;
+ break;
+ case NS_USER:
+ flags |= CLONE_NEWUSER;
+ break;
+ case NS_UTS:
+ flags |= CLONE_NEWUTS;
+ break;
+ case NS_TIME:
+ fprintf(stderr,
+ "option NS_TIME not suppoted by clone\n");
+ break;
+ default:
+ fprintf(stderr, "unrecognized option %d\n", i);
}
}
child = clone(fn, stack + sizeof(stack), flags, arg);
- if (child == -1) {
- perror("clone");
- exit(EXIT_FAILURE);
- }
+ if (child == -1) {
+ perror("clone");
+ exit(EXIT_FAILURE);
+ }
return child;
}
@@ -102,10 +101,9 @@ START_TEST(test_with_open_read_ns)
{
char test_file[] = "/tmp/test.txt";
char t[PATH_MAX] = "Hello Test";
- struct args_write_file args = {
- test_file, t, sizeof(t)};
+ struct args_write_file args = { test_file, t, sizeof(t) };
struct act_call call;
- int flags = O_RDWR;
+ int flags = O_RDWR;
struct arg_clone c;
char buf[PATH_MAX];
unsigned i;
@@ -114,29 +112,28 @@ START_TEST(test_with_open_read_ns)
int ret;
c.args = &call;
- count = sizeof(buf);
- for(i = 0; i < sizeof(enum ns_type); i++)
+ count = sizeof(buf);
+ for (i = 0; i < sizeof(enum ns_type); i++)
call.context.ns[i].type = NS_NONE;
call.context.ns[NS_MOUNT].type = NS_SPEC_PID;
pid = create_func_ns(write_file_clone, (void *)&args, call.context.ns);
call.context.ns[NS_MOUNT].pid = pid;
- call.nr = SYS_open;
- call.args[0] = (void *)&test_file;
- call.args[1] = (void *)(long)flags;
+ call.nr = SYS_open;
+ call.args[0] = (void *)&test_file;
+ call.args[1] = (void *)(long)flags;
ret = do_call(&c);
ck_assert_int_eq(ret, 0);
ck_assert_msg(c.ret >= 0, "expect ret %ld should be nonegative", c.ret);
- call.nr = SYS_read;
- call.args[0] = (void *)(long) c.ret;
- call.args[1] = (void *)&buf;
- call.args[2] = (void *)count;
+ call.nr = SYS_read;
+ call.args[0] = (void *)(long)c.ret;
+ call.args[1] = (void *)&buf;
+ call.args[2] = (void *)count;
ret = do_call(&c);
kill(pid, SIGCONT);
ck_assert_int_eq(ret, 0);
- ck_assert_msg(c.ret == count,
- "expect ret %ld to be %ld",c.ret, count);
+ ck_assert_msg(c.ret == count, "expect ret %ld to be %ld", c.ret, count);
ck_assert_str_eq(t, buf);
}
END_TEST
@@ -154,13 +151,13 @@ START_TEST(test_with_read)
c.args = &call;
fd = write_file_get_fd(test_file, t, sizeof(t));
- count = sizeof(buf);
- for(i = 0; i < sizeof(enum ns_type); i++)
+ count = sizeof(buf);
+ for (i = 0; i < sizeof(enum ns_type); i++)
call.context.ns[i].type = NS_NONE;
- call.nr = SYS_read;
- call.args[0] = (void *)(long) fd;
- call.args[1] = (void *)&buf;
- call.args[2] = (void *)count;
+ call.nr = SYS_read;
+ call.args[0] = (void *)(long)fd;
+ call.args[1] = (void *)&buf;
+ call.args[2] = (void *)count;
ret = do_call(&c);
ck_assert_int_eq(ret, 0);
@@ -174,34 +171,35 @@ START_TEST(test_with_getppid)
struct act_call call;
struct arg_clone c;
unsigned i;
- long pid = (long) getpid();
+ long pid = (long)getpid();
int ret;
- for(i = 0; i < sizeof(enum ns_type); i++)
+ for (i = 0; i < sizeof(enum ns_type); i++)
call.context.ns[i].type = NS_NONE;
- call.nr = SYS_getppid;
+ call.nr = SYS_getppid;
c.args = &call;
ret = do_call(&c);
ck_assert_int_eq(ret, 0);
- ck_assert_msg(c.ret == pid, "expect ret %ld to be equal to %ld", c.ret, pid);
+ ck_assert_msg(c.ret == pid, "expect ret %ld to be equal to %ld", c.ret,
+ pid);
}
END_TEST
Suite *action_call_suite(void)
{
- Suite *s;
- TCase *tactions;
+ Suite *s;
+ TCase *tactions;
- s = suite_create("Perform actions call");
- tactions = tcase_create("action calls");
+ s = suite_create("Perform actions call");
+ tactions = tcase_create("action calls");
- tcase_add_test(tactions, test_with_getppid);
- tcase_add_test(tactions, test_with_read);
- tcase_add_test(tactions,test_with_open_read_ns);
+ tcase_add_test(tactions, test_with_getppid);
+ tcase_add_test(tactions, test_with_read);
+ tcase_add_test(tactions, test_with_open_read_ns);
- suite_add_tcase(s, tactions);
+ suite_add_tcase(s, tactions);
- return s;
+ return s;
}
int main(void)
diff --git a/tests/unit/test_actions.c b/tests/unit/test_actions.c
index c6fc022..8893722 100644
--- a/tests/unit/test_actions.c
+++ b/tests/unit/test_actions.c
@@ -70,7 +70,7 @@ static int install_notification_filter()
static int create_test_fd()
{
- return open("/tmp", O_RDWR| O_TMPFILE );
+ return open("/tmp", O_RDWR | O_TMPFILE);
}
static int target()
@@ -133,9 +133,8 @@ static void check_target_result(long ret, int err, bool ignore_ret)
read(pipefd[0], &buf, 1);
if (!ignore_ret)
ck_assert_msg(at->ret == ret,
- "expect return value %ld to be equal to %ld",
- at->ret,
- ret);
+ "expect return value %ld to be equal to %ld",
+ at->ret, ret);
ck_assert_int_eq(at->err, err);
ck_assert_int_eq(close(pipefd[0]), 0);
}
@@ -153,7 +152,7 @@ void target_exit()
static bool has_fd(int pid, int fd)
{
- char path[PATH_MAX + 1];
+ char path[PATH_MAX + 1];
snprintf(path, sizeof(path), "/proc/%d/fd/%d", pid, fd);
return access(path, F_OK) == 0;
@@ -172,11 +171,11 @@ void setup(bool check_fd)
{
int ret;
- signal (SIGCHLD, target_exit);
+ signal(SIGCHLD, target_exit);
ck_assert_int_ne(pipe(pipefd), -1);
at = mmap(NULL, sizeof(struct args_target), PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
- at-> check_fd = check_fd;
+ at->check_fd = check_fd;
pid = do_clone(target, NULL);
ck_assert_int_ge(pid, 0);
@@ -213,8 +212,9 @@ START_TEST(test_act_continue)
struct action actions[] = {
{ .type = A_CONT },
};
- int ret = do_actions(NULL, actions, sizeof(actions) / sizeof(actions[0]), -1,
- notifyfd, req.id);
+ int ret = do_actions(NULL, actions,
+ sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ req.id);
ck_assert_msg(ret == 0, strerror(errno));
ck_assert_int_eq(at->err, 0);
}
@@ -228,8 +228,9 @@ START_TEST(test_act_block)
.block = { .error = -1 },
},
};
- int ret = do_actions(NULL, actions, sizeof(actions) / sizeof(actions[0]), -1,
- notifyfd, req.id);
+ int ret = do_actions(NULL, actions,
+ sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ req.id);
ck_assert_msg(ret == 0, strerror(errno));
check_target_result(-1, 0, false);
}
@@ -243,8 +244,9 @@ START_TEST(test_act_return)
.ret = { .type = IMMEDIATE, .value = 1 },
},
};
- int ret = do_actions(NULL, actions, sizeof(actions) / sizeof(actions[0]), -1,
- notifyfd, req.id);
+ int ret = do_actions(NULL, actions,
+ sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ req.id);
ck_assert_msg(ret == 0, strerror(errno));
check_target_result(1, 0, false);
}
@@ -262,8 +264,9 @@ START_TEST(test_act_return_ref)
};
memcpy((uint16_t *)&tmp_data + offset, &v, sizeof(v));
- int ret = do_actions(&tmp_data, actions, sizeof(actions) / sizeof(actions[0]), -1,
- notifyfd, req.id);
+ int ret = do_actions(&tmp_data, actions,
+ sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ req.id);
ck_assert_msg(ret == 0, strerror(errno));
check_target_result(v, 0, false);
}
@@ -278,8 +281,9 @@ START_TEST(test_act_call)
},
{ .type = A_CONT },
};
- int ret = do_actions(NULL, actions, sizeof(actions) / sizeof(actions[0]), -1,
- notifyfd, req.id);
+ int ret = do_actions(NULL, actions,
+ sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ req.id);
ck_assert_msg(ret == 0, strerror(errno));
check_target_result(1, 0, true);
}
@@ -290,12 +294,15 @@ START_TEST(test_act_call_ret)
struct action actions[] = {
{
.type = A_CALL,
- .call = { .nr = __NR_getppid, .has_ret = true, .ret_off = 2 },
+ .call = { .nr = __NR_getppid,
+ .has_ret = true,
+ .ret_off = 2 },
},
{ .type = A_CONT },
};
- int ret = do_actions(&tmp_data, actions, sizeof(actions) / sizeof(actions[0]), -1,
- notifyfd, req.id);
+ int ret = do_actions(&tmp_data, actions,
+ sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ req.id);
long r;
ck_assert_msg(ret == 0, strerror(errno));
check_target_result(1, 0, true);
@@ -312,10 +319,12 @@ static void test_inject(struct action actions[], int n, bool reference)
int ret;
fd_inj = create_test_fd();
- ck_assert_int_ge(fd_inj,0);
+ ck_assert_int_ge(fd_inj, 0);
if (reference) {
- memcpy((uint16_t *)&tmp_data + new_off, &fd_inj, sizeof(fd_inj));
- memcpy((uint16_t *)&tmp_data + old_off, &test_fd, sizeof(test_fd));
+ memcpy((uint16_t *)&tmp_data + new_off, &fd_inj,
+ sizeof(fd_inj));
+ memcpy((uint16_t *)&tmp_data + old_off, &test_fd,
+ sizeof(test_fd));
actions[0].inj.newfd.fd_off = new_off;
actions[0].inj.newfd.type = REFERENCE;
@@ -335,29 +344,29 @@ static void test_inject(struct action actions[], int n, bool reference)
START_TEST(test_act_inject_a)
{
- struct action actions[] = {{.type = A_INJECT_A} };
+ struct action actions[] = { { .type = A_INJECT_A } };
test_inject(actions, sizeof(actions) / sizeof(actions[0]), false);
}
END_TEST
START_TEST(test_act_inject_a_ref)
{
- struct action actions[] = {{.type = A_INJECT_A} };
+ struct action actions[] = { { .type = A_INJECT_A } };
test_inject(actions, sizeof(actions) / sizeof(actions[0]), true);
}
END_TEST
START_TEST(test_act_inject)
{
- struct action actions[] = { { .type = A_INJECT }};
- test_inject(actions,sizeof(actions) / sizeof(actions[0]), false);
+ struct action actions[] = { { .type = A_INJECT } };
+ test_inject(actions, sizeof(actions) / sizeof(actions[0]), false);
}
END_TEST
START_TEST(test_act_inject_ref)
{
- struct action actions[] = { { .type = A_INJECT }};
- test_inject(actions,sizeof(actions) / sizeof(actions[0]), true);
+ struct action actions[] = { { .type = A_INJECT } };
+ test_inject(actions, sizeof(actions) / sizeof(actions[0]), true);
}
END_TEST