Skip to content

Commit

Permalink
Merge pull request systemd#2769 from martinpitt/adjtime
Browse files Browse the repository at this point in the history
Fixes for adjtime parsing
  • Loading branch information
poettering committed Feb 29, 2016
2 parents 95979cb + 07edd3b commit ecb7c44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/test/test-clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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[]) {
Expand Down
4 changes: 2 additions & 2 deletions src/timedate/timedated.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit ecb7c44

Please sign in to comment.