summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-06 23:30:46 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-10 10:10:07 -0400
commitbc3029268ca0077f2e176724d7d124cec4265575 (patch)
tree6e51011b45a00de9e4be7bd87c214581cdaed0ce /src
parent87011c25d96e9fbcd8a465ba758fa037c7d08203 (diff)
journal: change direction tests to use the same convention (cp </> np)
The order was different in various places, which makes it harder to read to code. Also consistently use ternany for all direction checks. Remove one free(NULL).
Diffstat (limited to 'src')
-rw-r--r--src/journal/sd-journal.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 4c4cc2d21c..1e70739295 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -163,7 +163,7 @@ static bool same_field(const void *_a, size_t s, const void *_b, size_t t) {
return true;
}
- return true;
+ assert_not_reached("\"=\" not found");
}
static Match *match_new(Match *p, MatchType t) {
@@ -371,10 +371,8 @@ static char *match_make_string(Match *m) {
p = k;
enclose = true;
- } else {
- free(p);
+ } else
p = t;
- }
}
if (enclose) {
@@ -587,11 +585,14 @@ static int next_for_match(
if (r < 0)
return r;
else if (r > 0) {
- if (np == 0 || (direction == DIRECTION_DOWN ? np > cp : np < cp))
+ if (np == 0 || (direction == DIRECTION_DOWN ? cp < np : cp > np))
np = cp;
}
}
+ if (np == 0)
+ return 0;
+
} else if (m->type == MATCH_AND_TERM) {
Match *i, *last_moved;
@@ -624,8 +625,7 @@ static int next_for_match(
}
}
- if (np == 0)
- return 0;
+ assert(np > 0);
r = journal_file_move_to_object(f, OBJECT_ENTRY, np, &n);
if (r < 0)
@@ -730,7 +730,7 @@ static int find_location_for_match(
if (r <= 0)
return r;
- if (np == 0 || (direction == DIRECTION_DOWN ? np < cp : np > cp))
+ if (np == 0 || (direction == DIRECTION_DOWN ? cp > np : cp < np))
np = cp;
}
@@ -826,7 +826,7 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
return r;
}
- /* OK, we found the spot, now let's advance until to an entry
+ /* OK, we found the spot, now let's advance until an entry
* that is actually different from what we were previously
* looking at. This is necessary to handle entries which exist
* in two (or more) journal files, and which shall all be
@@ -888,10 +888,7 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
k = compare_entry_order(f, o, new_file, new_offset);
- if (direction == DIRECTION_DOWN)
- found = k < 0;
- else
- found = k > 0;
+ found = direction == DIRECTION_DOWN ? k < 0 : k > 0;
}
if (found) {