summaryrefslogtreecommitdiff
path: root/src/journal/test-journal-stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal/test-journal-stream.c')
-rw-r--r--src/journal/test-journal-stream.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c
index b3e816db70..4b73ac7906 100644
--- a/src/journal/test-journal-stream.c
+++ b/src/journal/test-journal-stream.c
@@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
JournalFile *one, *two, *three;
char t[] = "/tmp/journal-stream-XXXXXX";
unsigned i;
- sd_journal *j;
+ sd_journal _cleanup_journal_close_ *j = NULL;
char *z;
const void *data;
size_t l;
@@ -126,25 +126,23 @@ int main(int argc, char *argv[]) {
assert_se(sd_journal_add_match(j, "MAGIC=quux", 0) >= 0);
SD_JOURNAL_FOREACH_BACKWARDS(j) {
- char *c;
+ char _cleanup_free_ *c;
assert_se(sd_journal_get_data(j, "NUMBER", &data, &l) >= 0);
printf("\t%.*s\n", (int) l, (const char*) data);
assert_se(sd_journal_get_cursor(j, &c) >= 0);
assert_se(sd_journal_test_cursor(j, c) > 0);
- free(c);
}
SD_JOURNAL_FOREACH(j) {
- char *c;
+ char _cleanup_free_ *c;
assert_se(sd_journal_get_data(j, "NUMBER", &data, &l) >= 0);
printf("\t%.*s\n", (int) l, (const char*) data);
assert_se(sd_journal_get_cursor(j, &c) >= 0);
assert_se(sd_journal_test_cursor(j, c) > 0);
- free(c);
}
sd_journal_flush_matches(j);
@@ -177,8 +175,6 @@ int main(int argc, char *argv[]) {
SD_JOURNAL_FOREACH_UNIQUE(j, data, l)
printf("%.*s\n", (int) l, (const char*) data);
- sd_journal_close(j);
-
assert_se(rm_rf_dangerous(t, false, true, false) >= 0);
return 0;