summaryrefslogtreecommitdiff
path: root/src/journal/test-journal-stream.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-17 23:36:25 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-18 19:49:30 -0400
commit763c7aa288485cf5ab627fe1d25ff58e76f9dacb (patch)
tree563130863f8763af93df272c0122c76ef25aaba0 /src/journal/test-journal-stream.c
parenta50d7d4389217c0d3b527ee260eabf89e4a76caa (diff)
journal,shared: add _cleanup_journal_close_
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;