diff options
author | Paul Moore <paul@paul-moore.com> | 2019-03-12 11:54:22 -0400 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2019-03-12 11:54:22 -0400 |
commit | 1b914c3db514bf2ed73a9335c6e8a36f231af70f (patch) | |
tree | 616224d020846ce39c295604b3697213a267ec90 /tests | |
parent | 1ab1f211bae9635064a87819036d01b2b789563a (diff) | |
download | libseccomp-1b914c3db514bf2ed73a9335c6e8a36f231af70f.tar.gz |
tests: fix some issues found by coverity
None of these are major, and they are all part of the tests, but we
should fix them regardless.
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/44-live-a2_order.c | 4 | ||||
-rw-r--r-- | tests/47-live-kill_process.c | 15 |
2 files changed, 8 insertions, 11 deletions
diff --git a/tests/44-live-a2_order.c b/tests/44-live-a2_order.c index 9d12791..4af0b89 100644 --- a/tests/44-live-a2_order.c +++ b/tests/44-live-a2_order.c @@ -65,7 +65,7 @@ static const struct size_and_rc test_cases[] = { static int do_read(int sz, int expected_rc) { char *buf = NULL; - int rc = -1000, zero_fd; + int rc = -1000, zero_fd = -1; zero_fd = open("/dev/zero", O_RDONLY); if (zero_fd <= 0) @@ -85,7 +85,7 @@ static int do_read(int sz, int expected_rc) } error: - if (zero_fd) + if (zero_fd >= 0) close(zero_fd); if (buf) free(buf); diff --git a/tests/47-live-kill_process.c b/tests/47-live-kill_process.c index 0311855..7da407f 100644 --- a/tests/47-live-kill_process.c +++ b/tests/47-live-kill_process.c @@ -53,24 +53,21 @@ static const unsigned int whitelist[] = { */ void *child_start(void *param) { - int fd, *i = (int *)param; - - *i = 1; + int fd; /* make a disallowed syscall */ fd = open("/dev/null", O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); /* we should never get here. seccomp should kill the entire - * process when open() is called. - */ - if (fd < 0) - *i = fd; + * process when open() is called. */ + if (fd >= 0) + close(fd); return NULL; } int main(int argc, char *argv[]) { - int rc, i, param = 0; + int rc, i; scmp_filter_ctx ctx = NULL; pthread_t child_thread; @@ -88,7 +85,7 @@ int main(int argc, char *argv[]) if (rc != 0) goto out; - rc = pthread_create(&child_thread, NULL, child_start, ¶m); + rc = pthread_create(&child_thread, NULL, child_start, NULL); if (rc != 0) goto out; |