From e60dd0f6c5ca07bd141f4d2f9aefb6115cb95de6 Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 18 Jul 2014 18:39:37 +0100 Subject: [PATCH] osdc: refactor JOURNAL_FORMAT_* constants to enum ...so that the upper limit doesn't have to be updated by hand. Signed-off-by: John Spray --- src/osdc/Journaler.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/osdc/Journaler.h b/src/osdc/Journaler.h index 0a0c868f8239..19e724d38094 100644 --- a/src/osdc/Journaler.h +++ b/src/osdc/Journaler.h @@ -63,16 +63,22 @@ class PerfCounters; typedef __u8 stream_format_t; // Legacy envelope is leading uint32_t size -#define JOURNAL_FORMAT_LEGACY 0 +enum StreamFormat { + JOURNAL_FORMAT_LEGACY = 0, + JOURNAL_FORMAT_RESILIENT = 1, + // Insert new formats here, before COUNT + JOURNAL_FORMAT_COUNT +}; + +// Highest journal format version that we support +#define JOURNAL_FORMAT_MAX (JOURNAL_FORMAT_COUNT - 1) + +// Legacy envelope is leading uint32_t size #define JOURNAL_ENVELOPE_LEGACY (sizeof(uint32_t)) // Resilient envelope is leading uint64_t sentinel, uint32_t size, trailing uint64_t start_ptr -#define JOURNAL_FORMAT_RESILIENT 1 #define JOURNAL_ENVELOPE_RESILIENT (sizeof(uint32_t) + sizeof(uint64_t) + sizeof(uint64_t)) -// Most recent format which we may try to read -#define JOURNAL_FORMAT_MAX 1 - /** * Represents a collection of entries serialized in a byte stream. * -- 2.47.3