From cb971cc0317e6767a3394f721eac6efa99f51fed Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 29 Feb 2016 15:16:03 +0100 Subject: [PATCH 1/3] timedated: trivial stylistic fix Don't use {} for single-line "then" blocks. --- src/timedate/timedated.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 9406d28abe..0febc36af8 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -131,10 +131,10 @@ static int context_write_data_local_rtc(Context *c) { size_t a, b; p = strchrnul(s, '\n'); - if (*p == '\0') { + if (*p == '\0') /* only one line, no \n terminator */ prepend = "\n0\n"; - } else if (p[1] == '\0') { + else if (p[1] == '\0') { /* only one line, with \n terminator */ ++p; prepend = "0\n"; From d69d951b11e80dbcc7f62938951832638119bdd9 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 29 Feb 2016 15:16:11 +0100 Subject: [PATCH 2/3] test-clock: fix assertions Use assert_se() to ensure that they don't get optimized away. --- src/test/test-clock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/test-clock.c b/src/test/test-clock.c index b049d97ce7..0949793e5f 100644 --- a/src/test/test-clock.c +++ b/src/test/test-clock.c @@ -56,10 +56,10 @@ static void test_clock_is_localtime(void) { assert_se(clock_is_localtime("/nonexisting/adjtime") == 0); fd = mkostemp_safe(adjtime, O_WRONLY|O_CLOEXEC); - assert(fd > 0); + assert_se(fd >= 0); log_info("adjtime test file: %s", adjtime); f = fdopen(fd, "w"); - assert(f); + assert_se(f); for (size_t i = 0; i < ELEMENTSOF(scenarios); ++i) { log_info("scenario #%zu:, expected result %i", i, scenarios[i].expected_result); @@ -82,10 +82,10 @@ static void test_clock_is_localtime_system(void) { log_info("/etc/adjtime exists, clock_is_localtime() == %i", r); /* if /etc/adjtime exists we expect some answer, no error or * crash */ - assert(r == 0 || r == 1); + assert_se(r == 0 || r == 1); } else /* default is UTC if there is no /etc/adjtime */ - assert(r == 0); + assert_se(r == 0); } int main(int argc, char *argv[]) { From 07edd3b9e5855332a02ef7b91602c93aa12c1fd1 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 29 Feb 2016 17:40:08 +0100 Subject: [PATCH 3/3] test-clock: fix FILE* leak Close the FILE* instead of the underlying fd. --- src/test/test-clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/test-clock.c b/src/test/test-clock.c index 0949793e5f..84f775e5bc 100644 --- a/src/test/test-clock.c +++ b/src/test/test-clock.c @@ -28,8 +28,8 @@ static void test_clock_is_localtime(void) { char adjtime[] = "/tmp/test-adjtime.XXXXXX"; - _cleanup_close_ int fd = -1; - FILE* f; + int fd = -1; + _cleanup_fclose_ FILE* f = NULL; static const struct scenario { const char* contents;