Skip to content

Commit

Permalink
Fix build warnings
Browse files Browse the repository at this point in the history
It looks like once you start using the FOLLY_NULLABLE or FOLLY_NONNULL macros in
a class, it's all or nothing or you get build warnings. This change addresses
that based on the assumptions of the underlying code.
  • Loading branch information
rcari committed Feb 25, 2022
1 parent 7056684 commit 9f08f11
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions folly/logging/LoggerDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class LoggerDB {
* This creates the LogCategory for the specified name if it does not exist
* already.
*/
LogCategory* getCategory(folly::StringPiece name);
LogCategory* FOLLY_NONNULL getCategory(folly::StringPiece name);

/**
* Get the LogCategory for the specified name, if it already exists.
Expand All @@ -80,7 +80,10 @@ class LoggerDB {
* use a less verbose level than its parent categories.)
*/
void setLevel(folly::StringPiece name, LogLevel level, bool inherit = true);
void setLevel(LogCategory* category, LogLevel level, bool inherit = true);
void setLevel(
LogCategory* FOLLY_NONNULL category,
LogLevel level,
bool inherit = true);

/**
* Get a LogConfig object describing the current state of the LoggerDB.
Expand Down Expand Up @@ -170,12 +173,12 @@ class LoggerDB {
*/
LogLevel xlogInit(
folly::StringPiece categoryName,
std::atomic<LogLevel>* xlogCategoryLevel,
LogCategory** xlogCategory);
LogCategory* xlogInitCategory(
std::atomic<LogLevel>* FOLLY_NONNULL xlogCategoryLevel,
LogCategory* FOLLY_NULLABLE * FOLLY_NULLABLE xlogCategory);
LogCategory* FOLLY_NONNULL xlogInitCategory(
folly::StringPiece categoryName,
LogCategory** xlogCategory,
std::atomic<bool>* isInitialized);
LogCategory* FOLLY_NONNULL * FOLLY_NONNULL xlogCategory,
std::atomic<bool>* FOLLY_NONNULL isInitialized);

enum TestConstructorArg { TESTING };

Expand Down Expand Up @@ -240,7 +243,8 @@ class LoggerDB {
* Windows, and prints the message to stderr on other platforms. It also
* rate limits messages if they are arriving too quickly.
*/
static void setInternalWarningHandler(InternalWarningHandler handler);
static void setInternalWarningHandler(
InternalWarningHandler FOLLY_NULLABLE handler);

private:
using LoggerNameMap = std::unordered_map<
Expand Down Expand Up @@ -274,12 +278,12 @@ class LoggerDB {
LoggerDB& operator=(LoggerDB const&) = delete;

LoggerDB();
LogCategory* getOrCreateCategoryLocked(
LogCategory* FOLLY_NONNULL getOrCreateCategoryLocked(
LoggerNameMap& loggersByName, folly::StringPiece name);
LogCategory* createCategoryLocked(
LogCategory* FOLLY_NONNULL createCategoryLocked(
LoggerNameMap& loggersByName,
folly::StringPiece name,
LogCategory* parent);
LogCategory* FOLLY_NONNULL parent);

using NewHandlerMap =
std::unordered_map<std::string, std::shared_ptr<LogHandler>>;
Expand All @@ -289,12 +293,12 @@ class LoggerDB {
void startConfigUpdate(
const Synchronized<HandlerInfo>::LockedPtr& handlerInfo,
const LogConfig& config,
NewHandlerMap* handlers,
OldToNewHandlerMap* oldToNewHandlerMap);
NewHandlerMap* FOLLY_NONNULL handlers,
OldToNewHandlerMap* FOLLY_NONNULL oldToNewHandlerMap);
void finishConfigUpdate(
const Synchronized<HandlerInfo>::LockedPtr& handlerInfo,
NewHandlerMap* handlers,
OldToNewHandlerMap* oldToNewHandlerMap);
NewHandlerMap* FOLLY_NONNULL handlers,
OldToNewHandlerMap* FOLLY_NONNULL oldToNewHandlerMap);
std::vector<std::shared_ptr<LogHandler>> buildCategoryHandlerList(
const NewHandlerMap& handlerMap,
StringPiece categoryName,
Expand Down

0 comments on commit 9f08f11

Please sign in to comment.