summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-05-18 20:11:27 +0200
committerLennart Poettering <lennart@poettering.net>2020-05-18 20:20:22 +0200
commitce0f7f554685d5d4a2afffca9caf4fc142c5bc8a (patch)
treefdf6ed625eb7d2c75480aac6dd77a1af059c7d07 /src
parentf8b4ae29c74abbabecb8a109689771a2a6ff6a5f (diff)
downloadsystemd-ce0f7f554685d5d4a2afffca9caf4fc142c5bc8a.tar.gz
condition: reverse if check to lower indentation level
No change in behaviour. Let's just prefer early exit over deeper indentation.
Diffstat (limited to 'src')
-rw-r--r--src/shared/condition.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/shared/condition.c b/src/shared/condition.c
index 2e29d4cca7..b25e4f12b1 100644
--- a/src/shared/condition.c
+++ b/src/shared/condition.c
@@ -602,29 +602,27 @@ static int condition_test_needs_update(Condition *c, char **env) {
* AND the target file's nanoseconds == 0
* (otherwise the filesystem supports nsec timestamps, see stat(2)).
*/
- if (usr.st_mtim.tv_nsec > 0 && other.st_mtim.tv_nsec == 0) {
- _cleanup_free_ char *timestamp_str = NULL;
- uint64_t timestamp;
+ if (usr.st_mtim.tv_nsec == 0 || other.st_mtim.tv_nsec > 0)
+ return usr.st_mtim.tv_nsec > other.st_mtim.tv_nsec;
- r = parse_env_file(NULL, p, "TIMESTAMP_NSEC", &timestamp_str);
- if (r < 0) {
- log_debug_errno(r, "Failed to parse timestamp file '%s', using mtime: %m", p);
- return true;
- } else if (r == 0) {
- log_debug("No data in timestamp file '%s', using mtime.", p);
- return true;
- }
-
- r = safe_atou64(timestamp_str, &timestamp);
- if (r < 0) {
- log_debug_errno(r, "Failed to parse timestamp value '%s' in file '%s', using mtime: %m", timestamp_str, p);
- return true;
- }
+ _cleanup_free_ char *timestamp_str = NULL;
+ r = parse_env_file(NULL, p, "TIMESTAMP_NSEC", &timestamp_str);
+ if (r < 0) {
+ log_debug_errno(r, "Failed to parse timestamp file '%s', using mtime: %m", p);
+ return true;
+ } else if (r == 0) {
+ log_debug("No data in timestamp file '%s', using mtime.", p);
+ return true;
+ }
- return timespec_load_nsec(&usr.st_mtim) > timestamp;
+ uint64_t timestamp;
+ r = safe_atou64(timestamp_str, &timestamp);
+ if (r < 0) {
+ log_debug_errno(r, "Failed to parse timestamp value '%s' in file '%s', using mtime: %m", timestamp_str, p);
+ return true;
}
- return usr.st_mtim.tv_nsec > other.st_mtim.tv_nsec;
+ return timespec_load_nsec(&usr.st_mtim) > timestamp;
}
static int condition_test_first_boot(Condition *c, char **env) {