Bug 1302401 - Finds integer literals which are cast to bool. r=Waldo
authorSylvestre Ledru <sylvestre@debian.org>
Tue, 13 Sep 2016 14:22:49 +0200
changeset 315766 7c71ddd0c30fa3f9de28f00297097a9a4b7de89a
parent 315765 f0aae2c2bdd0d43f346eb7ff741c04d3453e96af
child 315767 3d533ce7453235cb8796d7b3bef70a44b89ba0d3
push id20634
push usercbook@mozilla.com
push dateFri, 30 Sep 2016 10:10:13 +0000
treeherderfx-team@afe79b010d13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1302401
milestone52.0a1
Bug 1302401 - Finds integer literals which are cast to bool. r=Waldo MozReview-Commit-ID: DkzKx4FnVTV
js/src/ctypes/CTypes.cpp
js/src/frontend/ParseNode.h
js/src/vm/TraceLoggingGraph.cpp
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -3898,17 +3898,17 @@ BuildTypeName(JSContext* cx, JSObject* t
 
   // Walk the hierarchy of types, outermost to innermost, building up the type
   // string. This consists of the base type, which goes on the left.
   // Derived type modifiers (* and []) build from the inside outward, with
   // pointers on the left and arrays on the right. An excellent description
   // of the rules for building C type declarations can be found at:
   // http://unixwiz.net/techtips/reading-cdecl.html
   TypeCode prevGrouping = CType::GetTypeCode(typeObj), currentGrouping;
-  while (1) {
+  while (true) {
     currentGrouping = CType::GetTypeCode(typeObj);
     switch (currentGrouping) {
     case TYPE_pointer: {
       // Pointer types go on the left.
       PrependString(result, "*");
 
       typeObj = PointerType::GetBaseType(typeObj);
       prevGrouping = currentGrouping;
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -447,29 +447,29 @@ class ParseNode
     ParseNode(const ParseNode& other) = delete;
     void operator=(const ParseNode& other) = delete;
 
   public:
     ParseNode(ParseNodeKind kind, JSOp op, ParseNodeArity arity)
       : pn_type(kind),
         pn_op(op),
         pn_arity(arity),
-        pn_parens(0),
+        pn_parens(false),
         pn_pos(0, 0),
         pn_next(nullptr)
     {
         MOZ_ASSERT(kind < PNK_LIMIT);
         memset(&pn_u, 0, sizeof pn_u);
     }
 
     ParseNode(ParseNodeKind kind, JSOp op, ParseNodeArity arity, const TokenPos& pos)
       : pn_type(kind),
         pn_op(op),
         pn_arity(arity),
-        pn_parens(0),
+        pn_parens(false),
         pn_pos(pos),
         pn_next(nullptr)
     {
         MOZ_ASSERT(kind < PNK_LIMIT);
         memset(&pn_u, 0, sizeof pn_u);
     }
 
     JSOp getOp() const                     { return JSOp(pn_op); }
--- a/js/src/vm/TraceLoggingGraph.cpp
+++ b/js/src/vm/TraceLoggingGraph.cpp
@@ -278,25 +278,25 @@ TraceLoggerGraph::~TraceLoggerGraph()
 
         dictFile = nullptr;
     }
 
     if (!failed && treeFile) {
         // Make sure every start entry has a corresponding stop value.
         // We temporarily enable logging for this. Stop doesn't need any extra data,
         // so is safe to do even when we have encountered OOM.
-        enabled = 1;
+        enabled = true;
         while (stack.size() > 1)
             stopEvent(0);
-        enabled = 0;
+        enabled = false;
     }
 
     if (!failed && !flush()) {
         fprintf(stderr, "TraceLogging: Couldn't write the data to disk.\n");
-        enabled = 0;
+        enabled = false;
         failed = true;
     }
 
     if (treeFile) {
         fclose(treeFile);
         treeFile = nullptr;
     }
 
@@ -359,26 +359,26 @@ TraceLoggerGraph::startEvent(uint32_t id
 {
     if (failed || enabled == 0)
         return;
 
     if (!tree.hasSpaceForAdd()) {
         if (tree.size() >= treeSizeFlushLimit() || !tree.ensureSpaceBeforeAdd()) {
             if (!flush()) {
                 fprintf(stderr, "TraceLogging: Couldn't write the data to disk.\n");
-                enabled = 0;
+                enabled = false;
                 failed = true;
                 return;
             }
         }
     }
 
     if (!startEventInternal(id, timestamp)) {
         fprintf(stderr, "TraceLogging: Failed to start an event.\n");
-        enabled = 0;
+        enabled = false;
         failed = true;
         return;
     }
 }
 
 TraceLoggerGraph::StackEntry&
 TraceLoggerGraph::getActiveAncestor()
 {
@@ -457,17 +457,17 @@ TraceLoggerGraph::stopEvent(uint32_t id,
 }
 
 void
 TraceLoggerGraph::stopEvent(uint64_t timestamp)
 {
     if (enabled && stack.lastEntry().active()) {
         if (!updateStop(stack.lastEntry().treeId(), timestamp)) {
             fprintf(stderr, "TraceLogging: Failed to stop an event.\n");
-            enabled = 0;
+            enabled = false;
             failed = true;
             return;
         }
     }
     if (stack.size() == 1) {
         if (!enabled)
             return;