compress: make Compression a regular non-sparse enum

Given we have two different types for the journal object flags and the
Compression enum, let's make the latter a regular non-sparse enum, and
thus remove some surprises. We have to convert anyway between the two,
and already do via COMPRESSION_FROM_OBJECT().
This commit is contained in:
Lennart Poettering
2022-04-26 21:55:49 +02:00
parent acc50c92eb
commit 4d698d12de
9 changed files with 44 additions and 22 deletions
+1 -2
View File
@@ -58,11 +58,10 @@ static int zstd_ret_to_errno(size_t ret) {
#define ALIGN_8(l) ALIGN_TO(l, sizeof(size_t))
static const char* const compression_table[_COMPRESSION_MAX] = {
[COMPRESSION_NONE] = "NONE",
[COMPRESSION_XZ] = "XZ",
[COMPRESSION_LZ4] = "LZ4",
[COMPRESSION_ZSTD] = "ZSTD",
/* 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(compression, Compression);
+4 -6
View File
@@ -4,12 +4,10 @@
#include <unistd.h>
typedef enum Compression {
/* These are defined the same way as the relevant object types in journal-def.h,
* i.e. OBJECT_COMPRESSED_XZ, … */
COMPRESSION_NONE = 0,
COMPRESSION_XZ = 1,
COMPRESSION_LZ4 = 2,
COMPRESSION_ZSTD = 4,
COMPRESSION_NONE,
COMPRESSION_XZ,
COMPRESSION_LZ4,
COMPRESSION_ZSTD,
_COMPRESSION_MAX,
_COMPRESSION_INVALID = -EINVAL,
} Compression;