diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-20 23:40:44 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-22 10:54:38 +0100 |
commit | baaa35ad706419ae5aacc11d2bece5bd8b73ee42 (patch) | |
tree | bb4b9c576fc56b3237d59e959ded7c245917fcd7 /src/journal/sd-journal.c | |
parent | 52d86690d68779b120a4380f7cc740825827fb0d (diff) | |
download | systemd-baaa35ad706419ae5aacc11d2bece5bd8b73ee42.tar.gz |
coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.
I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r-- | src/journal/sd-journal.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 1edabbde72..a81e0e94c7 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2825,31 +2825,30 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_ return r; /* Let's do the type check by hand, since we used 0 context above. */ - if (o->object.type != OBJECT_DATA) { - log_debug("%s:offset " OFSfmt ": object has type %d, expected %d", - j->unique_file->path, j->unique_offset, - o->object.type, OBJECT_DATA); - return -EBADMSG; - } + if (o->object.type != OBJECT_DATA) + return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), + "%s:offset " OFSfmt ": object has type %d, expected %d", + j->unique_file->path, + j->unique_offset, + o->object.type, OBJECT_DATA); r = return_data(j, j->unique_file, o, &odata, &ol); if (r < 0) return r; /* Check if we have at least the field name and "=". */ - if (ol <= k) { - log_debug("%s:offset " OFSfmt ": object has size %zu, expected at least %zu", - j->unique_file->path, j->unique_offset, - ol, k + 1); - return -EBADMSG; - } - - if (memcmp(odata, j->unique_field, k) || ((const char*) odata)[k] != '=') { - log_debug("%s:offset " OFSfmt ": object does not start with \"%s=\"", - j->unique_file->path, j->unique_offset, - j->unique_field); - return -EBADMSG; - } + if (ol <= k) + return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), + "%s:offset " OFSfmt ": object has size %zu, expected at least %zu", + j->unique_file->path, + j->unique_offset, ol, k + 1); + + if (memcmp(odata, j->unique_field, k) || ((const char*) odata)[k] != '=') + return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), + "%s:offset " OFSfmt ": object does not start with \"%s=\"", + j->unique_file->path, + j->unique_offset, + j->unique_field); /* OK, now let's see if we already returned this data * object by checking if it exists in the earlier @@ -2980,10 +2979,11 @@ _public_ int sd_journal_enumerate_fields(sd_journal *j, const char **field) { return r; /* Because we used OBJECT_UNUSED above, we need to do our type check manually */ - if (o->object.type != OBJECT_FIELD) { - log_debug("%s:offset " OFSfmt ": object has type %i, expected %i", f->path, j->fields_offset, o->object.type, OBJECT_FIELD); - return -EBADMSG; - } + if (o->object.type != OBJECT_FIELD) + return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), + "%s:offset " OFSfmt ": object has type %i, expected %i", + f->path, j->fields_offset, + o->object.type, OBJECT_FIELD); sz = le64toh(o->object.size) - offsetof(Object, field.payload); |