Bug 1316978 - Suppress nullptr-to-bool cast warning - r?froydnj draft
authorGerald Squelart <gsquelart@mozilla.com>
Sat, 12 Nov 2016 09:53:39 +1100
changeset 437955 ddda7746f41851d72584be6bdc884f1da5033221
parent 437797 5d1c54f240d077b6b8e141fd44b52a3b694a5dfd
child 536770 706b9573ebf8ff2e03433f740318f3ac817d7a29
push id35560
push usergsquelart@mozilla.com
push dateFri, 11 Nov 2016 23:30:36 +0000
reviewersfroydnj
bugs1316978
milestone52.0a1
Bug 1316978 - Suppress nullptr-to-bool cast warning - r?froydnj MozReview-Commit-ID: BweUO5stduw
xpcom/glue/nsISupportsImpl.h
--- a/xpcom/glue/nsISupportsImpl.h
+++ b/xpcom/glue/nsISupportsImpl.h
@@ -125,19 +125,21 @@ do {                                    
 
 #define MOZ_LOG_DTOR(_ptr, _name, _size) \
 do {                                     \
   NS_LogDtor((void*)_ptr, _name, _size); \
 } while (0)
 
 /* nsCOMPtr.h allows these macros to be defined by clients
  * These logging functions require dynamic_cast<void*>, so they don't
- * do anything useful if we don't have dynamic_cast<void*>. */
+ * do anything useful if we don't have dynamic_cast<void*>.
+ * Note: The explicit comparison to nullptr is needed to avoid warnings
+ *       when _p is a nullptr itself. */
 #define NSCAP_LOG_ASSIGNMENT(_c, _p)                                \
-  if (_p)                                                           \
+  if (_p != nullptr)                                                \
     NS_LogCOMPtrAddRef((_c),static_cast<nsISupports*>(_p))
 
 #define NSCAP_LOG_RELEASE(_c, _p)                                   \
   if (_p)                                                           \
     NS_LogCOMPtrRelease((_c), static_cast<nsISupports*>(_p))
 
 #else /* !NS_BUILD_REFCNT_LOGGING */