From b26334e5f85126a4ebe1c514d4790b98f2c2bbe1 Mon Sep 17 00:00:00 2001 From: Adam Simpkins Date: Wed, 29 Nov 2017 17:35:19 -0800 Subject: [PATCH] logging: add an assert for the FLAG_INHERIT bit Summary: Add a static_assert() to check that the FLAG_INHERIT bit does not conflict with valid LogLevel values. Reviewed By: bolinfest Differential Revision: D6341242 fbshipit-source-id: cec284623c8a612a3c54f1b593d169310790616e --- folly/experimental/logging/LogCategory.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/folly/experimental/logging/LogCategory.h b/folly/experimental/logging/LogCategory.h index e8612526..5a67d9f9 100644 --- a/folly/experimental/logging/LogCategory.h +++ b/folly/experimental/logging/LogCategory.h @@ -221,6 +221,12 @@ class LogCategory { private: enum : uint32_t { FLAG_INHERIT = 0x80000000 }; + // FLAG_INHERIT is the stored in the uppermost bit of the LogLevel field. + // assert that it does not conflict with valid LogLevel values. + static_assert( + static_cast(LogLevel::MAX_LEVEL) < FLAG_INHERIT, + "The FLAG_INHERIT bit must not be set in any valid LogLevel value"); + // Forbidden copy constructor and assignment operator LogCategory(LogCategory const&) = delete; LogCategory& operator=(LogCategory const&) = delete; -- 2.34.1