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.
case OBJECT_DATA:
/* All but hash and payload are mutable */
gcry_md_write(f->hmac, &o->data.hash, sizeof(o->data.hash));
- gcry_md_write(f->hmac, o->data.payload, le64toh(o->object.size) - offsetof(DataObject, payload));
+ gcry_md_write(f->hmac, o->data.payload, le64toh(o->object.size) - offsetof(Object, data.payload));
break;
case OBJECT_FIELD:
/* Same here */
gcry_md_write(f->hmac, &o->field.hash, sizeof(o->field.hash));
- gcry_md_write(f->hmac, o->field.payload, le64toh(o->object.size) - offsetof(FieldObject, payload));
+ gcry_md_write(f->hmac, o->field.payload, le64toh(o->object.size) - offsetof(Object, field.payload));
break;
case OBJECT_ENTRY:
/* All */
- gcry_md_write(f->hmac, &o->entry.seqnum, le64toh(o->object.size) - offsetof(EntryObject, seqnum));
+ gcry_md_write(f->hmac, &o->entry.seqnum, le64toh(o->object.size) - offsetof(Object, entry.seqnum));
break;
case OBJECT_FIELD_HASH_TABLE:
le64toh(o->data.n_entries),
offset);
- if (le64toh(o->object.size) <= offsetof(DataObject, payload))
+ if (le64toh(o->object.size) <= offsetof(Object, data.payload))
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
"Bad object size (<= %zu): %" PRIu64 ": %" PRIu64,
- offsetof(DataObject, payload),
+ offsetof(Object, data.payload),
le64toh(o->object.size),
offset);
break;
case OBJECT_FIELD:
- if (le64toh(o->object.size) <= offsetof(FieldObject, payload))
+ if (le64toh(o->object.size) <= offsetof(Object, field.payload))
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
"Bad field size (<= %zu): %" PRIu64 ": %" PRIu64,
- offsetof(FieldObject, payload),
+ offsetof(Object, field.payload),
le64toh(o->object.size),
offset);
uint64_t sz;
sz = le64toh(READ_NOW(o->object.size));
- if (sz < offsetof(EntryObject, items) ||
- (sz - offsetof(EntryObject, items)) % sizeof(EntryItem) != 0)
+ if (sz < offsetof(Object, entry.items) ||
+ (sz - offsetof(Object, entry.items)) % sizeof(EntryItem) != 0)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
"Bad entry size (<= %zu): %" PRIu64 ": %" PRIu64,
- offsetof(EntryObject, items),
+ offsetof(Object, entry.items),
sz,
offset);
- if ((sz - offsetof(EntryObject, items)) / sizeof(EntryItem) <= 0)
+ if ((sz - offsetof(Object, entry.items)) / sizeof(EntryItem) <= 0)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
"Invalid number items in entry: %" PRIu64 ": %" PRIu64,
- (sz - offsetof(EntryObject, items)) / sizeof(EntryItem),
+ (sz - offsetof(Object, entry.items)) / sizeof(EntryItem),
offset);
if (le64toh(o->entry.seqnum) <= 0)
uint64_t sz;
sz = le64toh(READ_NOW(o->object.size));
- if (sz < offsetof(HashTableObject, items) ||
- (sz - offsetof(HashTableObject, items)) % sizeof(HashItem) != 0 ||
- (sz - offsetof(HashTableObject, items)) / sizeof(HashItem) <= 0)
+ if (sz < offsetof(Object, hash_table.items) ||
+ (sz - offsetof(Object, hash_table.items)) % sizeof(HashItem) != 0 ||
+ (sz - offsetof(Object, hash_table.items)) / sizeof(HashItem) <= 0)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
"Invalid %s hash table size: %" PRIu64 ": %" PRIu64,
o->object.type == OBJECT_DATA_HASH_TABLE ? "data" : "field",
uint64_t sz;
sz = le64toh(READ_NOW(o->object.size));
- if (sz < offsetof(EntryArrayObject, items) ||
- (sz - offsetof(EntryArrayObject, items)) % sizeof(le64_t) != 0 ||
- (sz - offsetof(EntryArrayObject, items)) / sizeof(le64_t) <= 0)
+ if (sz < offsetof(Object, entry_array.items) ||
+ (sz - offsetof(Object, entry_array.items)) % sizeof(le64_t) != 0 ||
+ (sz - offsetof(Object, entry_array.items)) / sizeof(le64_t) <= 0)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
"Invalid object entry array size: %" PRIu64 ": %" PRIu64,
sz,
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;
}
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;
}
}
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;
}
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),
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));
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;
}