summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-06-02 00:26:34 +0200
committerLennart Poettering <lennart@poettering.net>2020-06-25 15:00:37 +0200
commite9ece6a0e39b5af0055729d6d9feb90cf5d65289 (patch)
tree1476a445f6b7fa64937a4424a6e3ad64b5177211 /src
parentd1d8f0f369ce386878e79d56b2795397902bc221 (diff)
downloadsystemd-e9ece6a0e39b5af0055729d6d9feb90cf5d65289.tar.gz
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.)
Diffstat (limited to 'src')
-rw-r--r--src/journal/compress.c6
-rw-r--r--src/journal/journal-def.h14
2 files changed, 11 insertions, 9 deletions
diff --git a/src/journal/compress.c b/src/journal/compress.c
index 2bbfc7644a..6e3d350c6f 100644
--- a/src/journal/compress.c
+++ b/src/journal/compress.c
@@ -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);
diff --git a/src/journal/journal-def.h b/src/journal/journal-def.h
index ff4e71a31b..3f981e4e39 100644
--- a/src/journal/journal-def.h
+++ b/src/journal/journal-def.h
@@ -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