summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-journal/journal-verify.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2022-01-24 14:40:06 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2022-01-26 21:16:00 +0100
commit3a8099a871655ba43aa60389f539f09505260170 (patch)
tree2a9f4578aefd292a2d7f8efdcc286bb7b1d461a2 /src/libsystemd/sd-journal/journal-verify.c
parentMerge pull request #22252 from medhefgo/boot-build (diff)
downloadsystemd-3a8099a871655ba43aa60389f539f09505260170.tar.xz
systemd-3a8099a871655ba43aa60389f539f09505260170.zip
journal: Use offsetof(Object, ...) to retrieve object field offsets
We currently use both offsetof(Object, ...) and offsetof(DataObject, ...). This makes it harder to grep for usages as we have to make sure we grep for both usages. Let's unify these all to use offsetof(Object, ...) to make it easier to grep for usages.
Diffstat (limited to '')
-rw-r--r--src/libsystemd/sd-journal/journal-verify.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/libsystemd/sd-journal/journal-verify.c b/src/libsystemd/sd-journal/journal-verify.c
index 8288ebcd6e..24d3c6b9e1 100644
--- a/src/libsystemd/sd-journal/journal-verify.c
+++ b/src/libsystemd/sd-journal/journal-verify.c
@@ -169,9 +169,9 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
return -EBADMSG;
}
- if (le64toh(o->object.size) - offsetof(DataObject, payload) <= 0) {
+ if (le64toh(o->object.size) - offsetof(Object, data.payload) <= 0) {
error(offset, "Bad object size (<= %zu): %"PRIu64,
- offsetof(DataObject, payload),
+ offsetof(Object, data.payload),
le64toh(o->object.size));
return -EBADMSG;
}
@@ -207,10 +207,10 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
uint64_t h1, h2;
int r;
- if (le64toh(o->object.size) - offsetof(FieldObject, payload) <= 0) {
+ if (le64toh(o->object.size) - offsetof(Object, field.payload) <= 0) {
error(offset,
"Bad field size (<= %zu): %"PRIu64,
- offsetof(FieldObject, payload),
+ offsetof(Object, field.payload),
le64toh(o->object.size));
return -EBADMSG;
}
@@ -239,18 +239,18 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
}
case OBJECT_ENTRY:
- if ((le64toh(o->object.size) - offsetof(EntryObject, items)) % sizeof(EntryItem) != 0) {
+ if ((le64toh(o->object.size) - offsetof(Object, entry.items)) % sizeof(EntryItem) != 0) {
error(offset,
"Bad entry size (<= %zu): %"PRIu64,
- offsetof(EntryObject, items),
+ offsetof(Object, entry.items),
le64toh(o->object.size));
return -EBADMSG;
}
- if ((le64toh(o->object.size) - offsetof(EntryObject, items)) / sizeof(EntryItem) <= 0) {
+ if ((le64toh(o->object.size) - offsetof(Object, entry.items)) / sizeof(EntryItem) <= 0) {
error(offset,
"Invalid number items in entry: %"PRIu64,
- (le64toh(o->object.size) - offsetof(EntryObject, items)) / sizeof(EntryItem));
+ (le64toh(o->object.size) - offsetof(Object, entry.items)) / sizeof(EntryItem));
return -EBADMSG;
}
@@ -290,8 +290,8 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
case OBJECT_DATA_HASH_TABLE:
case OBJECT_FIELD_HASH_TABLE:
- if ((le64toh(o->object.size) - offsetof(HashTableObject, items)) % sizeof(HashItem) != 0 ||
- (le64toh(o->object.size) - offsetof(HashTableObject, items)) / sizeof(HashItem) <= 0) {
+ if ((le64toh(o->object.size) - offsetof(Object, hash_table.items)) % sizeof(HashItem) != 0 ||
+ (le64toh(o->object.size) - offsetof(Object, hash_table.items)) / sizeof(HashItem) <= 0) {
error(offset,
"Invalid %s size: %"PRIu64,
journal_object_type_to_string(o->object.type),
@@ -334,8 +334,8 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
break;
case OBJECT_ENTRY_ARRAY:
- if ((le64toh(o->object.size) - offsetof(EntryArrayObject, items)) % sizeof(le64_t) != 0 ||
- (le64toh(o->object.size) - offsetof(EntryArrayObject, items)) / sizeof(le64_t) <= 0) {
+ if ((le64toh(o->object.size) - offsetof(Object, entry_array.items)) % sizeof(le64_t) != 0 ||
+ (le64toh(o->object.size) - offsetof(Object, entry_array.items)) / sizeof(le64_t) <= 0) {
error(offset,
"Invalid object entry array size: %"PRIu64,
le64toh(o->object.size));
@@ -842,21 +842,21 @@ static int verify_hash_table(
return -EBADMSG;
}
- if (header_offset != p + offsetof(HashTableObject, items)) {
+ if (header_offset != p + offsetof(Object, hash_table.items)) {
error(p,
"Header offset for %s invalid (%" PRIu64 " != %" PRIu64 ")",
journal_object_type_to_string(o->object.type),
header_offset,
- p + offsetof(HashTableObject, items));
+ p + offsetof(Object, hash_table.items));
return -EBADMSG;
}
- if (header_size != le64toh(o->object.size) - offsetof(HashTableObject, items)) {
+ if (header_size != le64toh(o->object.size) - offsetof(Object, hash_table.items)) {
error(p,
"Header size for %s invalid (%" PRIu64 " != %" PRIu64 ")",
journal_object_type_to_string(o->object.type),
header_size,
- le64toh(o->object.size) - offsetof(HashTableObject, items));
+ le64toh(o->object.size) - offsetof(Object, hash_table.items));
return -EBADMSG;
}