diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-07-12 07:37:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-12 07:37:44 +0200 |
commit | 27dd6e1b1204fbea507f50e9aadde1c5b5f0ac18 (patch) | |
tree | 2cd51a99eee377aa89b55049fd6a51ce8d9415af /src/test | |
parent | Merge pull request #13031 from yuwata/network-route-type-local-12975-2 (diff) | |
parent | shared/ask-password-api: backspace all chars at once (diff) | |
download | systemd-27dd6e1b1204fbea507f50e9aadde1c5b5f0ac18.tar.xz systemd-27dd6e1b1204fbea507f50e9aadde1c5b5f0ac18.zip |
Merge pull request #13022 from keszybz/coverity-cleanups
Coverity cleanups
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-alloc-util.c | 2 | ||||
-rw-r--r-- | src/test/test-copy.c | 6 | ||||
-rw-r--r-- | src/test/test-fileio.c | 4 | ||||
-rw-r--r-- | src/test/test-process-util.c | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/test/test-alloc-util.c b/src/test/test-alloc-util.c index cf69436d26..71ecda0b99 100644 --- a/src/test/test-alloc-util.c +++ b/src/test/test-alloc-util.c @@ -139,7 +139,7 @@ static void test_auto_erase_memory(void) { assert_se(p1 = new(uint8_t, 1024)); assert_se(p2 = new(uint8_t, 1024)); - genuine_random_bytes(p1, 1024, RANDOM_BLOCK); + assert_se(genuine_random_bytes(p1, 1024, RANDOM_BLOCK) == 0); /* before we exit the scope, do something with this data, so that the compiler won't optimize this away */ memcpy(p2, p1, 1024); diff --git a/src/test/test-copy.c b/src/test/test-copy.c index bfe6cea41c..5f7b9e5ce8 100644 --- a/src/test/test-copy.c +++ b/src/test/test-copy.c @@ -52,8 +52,8 @@ static void test_copy_file_fd(void) { char in_fn[] = "/tmp/test-copy-file-fd-XXXXXX"; char out_fn[] = "/tmp/test-copy-file-fd-XXXXXX"; _cleanup_close_ int in_fd = -1, out_fd = -1; - char text[] = "boohoo\nfoo\n\tbar\n"; - char buf[64] = {0}; + const char *text = "boohoo\nfoo\n\tbar\n"; + char buf[64] = {}; log_info("%s", __func__); @@ -67,7 +67,7 @@ static void test_copy_file_fd(void) { assert_se(copy_file_fd(in_fn, out_fd, COPY_REFLINK) >= 0); assert_se(lseek(out_fd, SEEK_SET, 0) == 0); - assert_se(read(out_fd, buf, sizeof(buf)) == sizeof(text) - 1); + assert_se(read(out_fd, buf, sizeof buf) == (ssize_t) strlen(text)); assert_se(streq(buf, text)); unlink(in_fn); diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index 211def88eb..1ad47a4aa3 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -427,7 +427,7 @@ static void test_write_string_file(void) { static void test_write_string_file_no_create(void) { _cleanup_(unlink_tempfilep) char fn[] = "/tmp/test-write_string_file_no_create-XXXXXX"; _cleanup_close_ int fd; - char buf[64] = {0}; + char buf[64] = {}; fd = mkostemp_safe(fn); assert_se(fd >= 0); @@ -435,7 +435,7 @@ static void test_write_string_file_no_create(void) { assert_se(write_string_file("/a/file/which/does/not/exists/i/guess", "boohoo", 0) < 0); assert_se(write_string_file(fn, "boohoo", 0) == 0); - assert_se(read(fd, buf, sizeof(buf)) == STRLEN("boohoo\n")); + assert_se(read(fd, buf, sizeof buf) == (ssize_t) strlen("boohoo\n")); assert_se(streq(buf, "boohoo\n")); } diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index 9b644c09bb..8dc9fdda50 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -524,14 +524,14 @@ static void test_getpid_measure(void) { (void) getpid(); q = now(CLOCK_MONOTONIC) - t; - log_info(" glibc getpid(): %llu/s\n", (unsigned long long) (MEASURE_ITERATIONS*USEC_PER_SEC/q)); + log_info(" glibc getpid(): %lf µs each\n", (double) q / MEASURE_ITERATIONS); t = now(CLOCK_MONOTONIC); for (i = 0; i < MEASURE_ITERATIONS; i++) (void) getpid_cached(); q = now(CLOCK_MONOTONIC) - t; - log_info("getpid_cached(): %llu/s\n", (unsigned long long) (MEASURE_ITERATIONS*USEC_PER_SEC/q)); + log_info("getpid_cached(): %lf µs each\n", (double) q / MEASURE_ITERATIONS); } static void test_safe_fork(void) { |