From: Adam Simpkins Date: Thu, 30 Nov 2017 01:35:19 +0000 (-0800) Subject: logging: add an assert for the FLAG_INHERIT bit X-Git-Tag: v2017.12.04.00~15 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b26334e5f85126a4ebe1c514d4790b98f2c2bbe1;hp=89353dca07263ccb9d78e618584f94daa25c371a;p=folly.git 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 --- 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;