From: Christopher Dykes <cdykes@fb.com>
Date: Tue, 7 Feb 2017 19:27:44 +0000 (-0800)
Subject: Make a few coersions to bool explicit
X-Git-Tag: v2017.03.06.00~50
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0e4a41d08b742f799c7a2ea8224bbd87c214b715;p=folly.git

Make a few coersions to bool explicit

Summary: MSVC has warning 4800 which is triggered on implicit coercions to `bool` when not in use as the condition to a control-flow statement.

Reviewed By: yfeldblum

Differential Revision: D4518465

fbshipit-source-id: 858ab9e68215a2a667cb3ea55daf51b74368174d
---

diff --git a/folly/CpuId.h b/folly/CpuId.h
index 24d4d97e..5e06513c 100644
--- a/folly/CpuId.h
+++ b/folly/CpuId.h
@@ -99,7 +99,7 @@ class CpuId {
 
 #define X(name, r, bit)                   \
   FOLLY_ALWAYS_INLINE bool name() const { \
-    return (r) & (1U << bit);             \
+    return ((r) & (1U << bit)) != 0;      \
   }
 
 // cpuid(1): Processor Info and Feature Bits.
diff --git a/folly/FormatArg.h b/folly/FormatArg.h
index 5257285c..48311e3d 100644
--- a/folly/FormatArg.h
+++ b/folly/FormatArg.h
@@ -244,7 +244,7 @@ inline StringPiece FormatArg::doSplitKey() {
   if (e[-1] == ']') {
     --e;
     p = static_cast<const char*>(memchr(b, '[', size_t(e - b)));
-    enforce(p, "unmatched ']'");
+    enforce(p != nullptr, "unmatched ']'");
   } else {
     p = static_cast<const char*>(memchr(b, '.', size_t(e - b)));
   }
diff --git a/folly/dynamic-inl.h b/folly/dynamic-inl.h
index 984b7a4c..41352ad0 100644
--- a/folly/dynamic-inl.h
+++ b/folly/dynamic-inl.h
@@ -342,15 +342,29 @@ inline dynamic::IterableProxy<dynamic::const_item_iterator> dynamic::items()
 }
 
 inline bool dynamic::isString() const {
-  return get_nothrow<std::string>();
-}
-inline bool dynamic::isObject() const { return get_nothrow<ObjectImpl>(); }
-inline bool dynamic::isBool()   const { return get_nothrow<bool>(); }
-inline bool dynamic::isArray()  const { return get_nothrow<Array>(); }
-inline bool dynamic::isDouble() const { return get_nothrow<double>(); }
-inline bool dynamic::isInt()    const { return get_nothrow<int64_t>(); }
-inline bool dynamic::isNull()   const { return get_nothrow<void*>(); }
-inline bool dynamic::isNumber() const { return isInt() || isDouble(); }
+  return get_nothrow<std::string>() != nullptr;
+}
+inline bool dynamic::isObject() const {
+  return get_nothrow<ObjectImpl>() != nullptr;
+}
+inline bool dynamic::isBool() const {
+  return get_nothrow<bool>() != nullptr;
+}
+inline bool dynamic::isArray() const {
+  return get_nothrow<Array>() != nullptr;
+}
+inline bool dynamic::isDouble() const {
+  return get_nothrow<double>() != nullptr;
+}
+inline bool dynamic::isInt() const {
+  return get_nothrow<int64_t>() != nullptr;
+}
+inline bool dynamic::isNull() const {
+  return get_nothrow<void*>() != nullptr;
+}
+inline bool dynamic::isNumber() const {
+  return isInt() || isDouble();
+}
 
 inline dynamic::Type dynamic::type() const {
   return type_;