mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
journal: consistently use OBJECT_<type> names instead of numbers
Note that numbers 0 and -1 are both replaced with OBJECT_UNUSED, because they are treated the same everywhere (e.g. type_to_context() translates them both to 0).
This commit is contained in:
parent
2df65e7d96
commit
d05089d86e
@ -246,7 +246,7 @@ int journal_file_hmac_put_object(JournalFile *f, int type, Object *o, uint64_t p
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else {
|
||||
if (type > 0 && o->object.type != type)
|
||||
if (type > OBJECT_UNUSED && o->object.type != type)
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ typedef struct FSSHeader FSSHeader;
|
||||
|
||||
/* Object types */
|
||||
enum {
|
||||
OBJECT_UNUSED,
|
||||
OBJECT_UNUSED, /* also serves as "any type" or "additional context" */
|
||||
OBJECT_DATA,
|
||||
OBJECT_FIELD,
|
||||
OBJECT_ENTRY,
|
||||
|
@ -376,7 +376,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
|
||||
|
||||
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) {
|
||||
@ -446,7 +446,7 @@ int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Objec
|
||||
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)) {
|
||||
@ -494,7 +494,7 @@ int journal_file_append_object(JournalFile *f, int type, uint64_t size, Object *
|
||||
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);
|
||||
@ -507,7 +507,7 @@ int journal_file_append_object(JournalFile *f, int type, uint64_t size, Object *
|
||||
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;
|
||||
|
||||
@ -2294,7 +2294,7 @@ void journal_file_dump(JournalFile *f) {
|
||||
|
||||
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;
|
||||
|
||||
|
@ -865,7 +865,7 @@ int journal_file_verify(
|
||||
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;
|
||||
@ -1085,11 +1085,11 @@ int journal_file_verify(
|
||||
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;
|
||||
|
||||
@ -1097,7 +1097,7 @@ int journal_file_verify(
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
|
@ -2588,10 +2588,10 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user