journal: fix definition of _OBJECT_COMPRESSED_MAX

The object flags field is a bitmask, hence don't sloppily define
_OBJECT_COMPRESSED_MAX as one mor than the previous flag. That worked OK
as long as we only had two flags, but will fall apart as soon as we have
three. Let's fix this.

(It's kinda sloppy how the string table is built here, as it will be
quite sparse as soon as we have more enum entries, but let's keep it for
now.)
This commit is contained in:
Lennart Poettering
2020-06-25 15:00:37 +02:00
parent d1d8f0f369
commit e9ece6a0e3
2 changed files with 11 additions and 9 deletions
+4 -2
View File
@@ -57,8 +57,10 @@ static int zstd_ret_to_errno(size_t ret) {
#define ALIGN_8(l) ALIGN_TO(l, sizeof(size_t))
static const char* const object_compressed_table[_OBJECT_COMPRESSED_MAX] = {
[OBJECT_COMPRESSED_XZ] = "XZ",
[OBJECT_COMPRESSED_LZ4] = "LZ4",
[OBJECT_COMPRESSED_XZ] = "XZ",
[OBJECT_COMPRESSED_LZ4] = "LZ4",
/* If we add too many more entries here, it's going to grow quite large (and be mostly sparse), since
* the array key is actually a bitmask, not a plain enum */
};
DEFINE_STRING_TABLE_LOOKUP(object_compressed, int);
+7 -7
View File
@@ -44,12 +44,12 @@ typedef enum ObjectType {
/* Object flags */
enum {
OBJECT_COMPRESSED_XZ = 1 << 0,
OBJECT_COMPRESSED_LZ4 = 1 << 1,
_OBJECT_COMPRESSED_MAX
OBJECT_COMPRESSED_XZ = 1 << 0,
OBJECT_COMPRESSED_LZ4 = 1 << 1,
OBJECT_COMPRESSION_MASK = (OBJECT_COMPRESSED_XZ | OBJECT_COMPRESSED_LZ4),
_OBJECT_COMPRESSED_MAX = OBJECT_COMPRESSION_MASK,
};
#define OBJECT_COMPRESSION_MASK (OBJECT_COMPRESSED_XZ | OBJECT_COMPRESSED_LZ4)
struct ObjectHeader {
uint8_t type;
@@ -145,8 +145,8 @@ enum {
/* Header flags */
enum {
HEADER_INCOMPATIBLE_COMPRESSED_XZ = 1 << 0,
HEADER_INCOMPATIBLE_COMPRESSED_LZ4 = 1 << 1,
HEADER_INCOMPATIBLE_COMPRESSED_XZ = 1 << 0,
HEADER_INCOMPATIBLE_COMPRESSED_LZ4 = 1 << 1,
};
#define HEADER_INCOMPATIBLE_ANY (HEADER_INCOMPATIBLE_COMPRESSED_XZ|HEADER_INCOMPATIBLE_COMPRESSED_LZ4)
@@ -162,7 +162,7 @@ enum {
#endif
enum {
HEADER_COMPATIBLE_SEALED = 1
HEADER_COMPATIBLE_SEALED = 1 << 0,
};
#define HEADER_COMPATIBLE_ANY HEADER_COMPATIBLE_SEALED