if (r < 0)
return r;
} else {
- if (type > 0 && o->object.type != type)
+ if (type > OBJECT_UNUSED && o->object.type != type)
return -EBADMSG;
}
/* Object types */
enum {
- OBJECT_UNUSED,
+ OBJECT_UNUSED, /* also serves as "any type" or "additional context" */
OBJECT_DATA,
OBJECT_FIELD,
OBJECT_ENTRY,
static unsigned type_to_context(int type) {
/* One context for each type, plus one catch-all for the rest */
- return type > 0 && type < _OBJECT_TYPE_MAX ? type : 0;
+ return type > OBJECT_UNUSED && type < _OBJECT_TYPE_MAX ? type : 0;
}
static int journal_file_move_to(JournalFile *f, int context, bool keep_always, uint64_t offset, uint64_t size, void **ret) {
if (s < minimum_header_size(o))
return -EBADMSG;
- if (type > 0 && o->object.type != type)
+ if (type > OBJECT_UNUSED && o->object.type != type)
return -EBADMSG;
if (s > sizeof(ObjectHeader)) {
void *t;
assert(f);
- assert(type > 0 && type < _OBJECT_TYPE_MAX);
+ assert(type > OBJECT_UNUSED && type < _OBJECT_TYPE_MAX);
assert(size >= sizeof(ObjectHeader));
assert(offset);
assert(ret);
if (p == 0)
p = le64toh(f->header->header_size);
else {
- r = journal_file_move_to_object(f, -1, p, &tail);
+ r = journal_file_move_to_object(f, OBJECT_UNUSED, p, &tail);
if (r < 0)
return r;
p = le64toh(f->header->header_size);
while (p != 0) {
- r = journal_file_move_to_object(f, -1, p, &o);
+ r = journal_file_move_to_object(f, OBJECT_UNUSED, p, &o);
if (r < 0)
goto fail;
if (show_progress)
draw_progress(0x7FFF * p / le64toh(f->header->tail_object_offset), &last_usec);
- r = journal_file_move_to_object(f, -1, p, &o);
+ r = journal_file_move_to_object(f, OBJECT_UNUSED, p, &o);
if (r < 0) {
error(p, "invalid object");
goto fail;
q = last_tag;
while (q <= p) {
- r = journal_file_move_to_object(f, -1, q, &o);
+ r = journal_file_move_to_object(f, OBJECT_UNUSED, q, &o);
if (r < 0)
goto fail;
- r = journal_file_hmac_put_object(f, -1, o, q);
+ r = journal_file_hmac_put_object(f, OBJECT_UNUSED, o, q);
if (r < 0)
goto fail;
}
/* Position might have changed, let's reposition things */
- r = journal_file_move_to_object(f, -1, p, &o);
+ r = journal_file_move_to_object(f, OBJECT_UNUSED, p, &o);
if (r < 0)
goto fail;
continue;
}
- /* We do not use the type context here, but 0 instead,
- * so that we can look at this data object at the same
+ /* We do not use OBJECT_DATA context here, but OBJECT_UNUSED
+ * instead, so that we can look at this data object at the same
* time as one on another file */
- r = journal_file_move_to_object(j->unique_file, 0, j->unique_offset, &o);
+ r = journal_file_move_to_object(j->unique_file, OBJECT_UNUSED, j->unique_offset, &o);
if (r < 0)
return r;