Bug 398435. Fix prbool bugs in xpcom. r=bsmedberg a=sayrer
authortglek@mozilla.com
Mon, 15 Oct 2007 16:40:09 -0700
changeset 6973 bc454ad46cc3cdc7a4b6e94fae05d2e72896b53a
parent 6972 e74a69ed4a0fee37536d4cb581b4d4d7666b91cd
child 6974 de3edbfe2d962c7cdcede8c39c026888692bb628
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, sayrer
bugs398435
milestone1.9a9pre
Bug 398435. Fix prbool bugs in xpcom. r=bsmedberg a=sayrer
xpcom/ds/nsHashtable.cpp
xpcom/glue/nsBaseHashtable.h
xpcom/glue/nsTHashtable.h
xpcom/glue/nsThreadUtils.cpp
xpcom/io/nsBinaryStream.cpp
xpcom/io/nsEscape.cpp
xpcom/io/nsPipe3.cpp
xpcom/io/nsScriptableInputStream.cpp
xpcom/proxy/src/nsProxyEvent.cpp
xpcom/proxy/src/nsProxyEventPrivate.h
xpcom/reflect/xptinfo/public/xptinfo.h
xpcom/reflect/xptinfo/src/xptiManifest.cpp
xpcom/typelib/xpt/public/xpt_struct.h
--- a/xpcom/ds/nsHashtable.cpp
+++ b/xpcom/ds/nsHashtable.cpp
@@ -790,17 +790,17 @@ nsObjectHashtable::Reset()
     nsHashtable::Reset(mDestroyElementFun, mDestroyElementClosure);
 }
 
 PRBool
 nsObjectHashtable::RemoveAndDelete(nsHashKey *aKey)
 {
     void *value = Remove(aKey);
     if (value && mDestroyElementFun)
-        return (*mDestroyElementFun)(aKey, value, mDestroyElementClosure);
+        return !!(*mDestroyElementFun)(aKey, value, mDestroyElementClosure);
     return PR_FALSE;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsSupportsHashtable: an nsHashtable where the elements are nsISupports*
 
 PRBool PR_CALLBACK
 nsSupportsHashtable::ReleaseElement(nsHashKey *aKey, void *aData, void* aClosure)
--- a/xpcom/glue/nsBaseHashtable.h
+++ b/xpcom/glue/nsBaseHashtable.h
@@ -98,17 +98,17 @@ public:
   PRBool Init(PRUint32 initSize = PL_DHASH_MIN_SIZE)
   { return nsTHashtable<EntryType>::Init(initSize); }
 
   /**
    * Check whether the table has been initialized.
    * This function is especially useful for static hashtables.
    * @return PR_TRUE if the table has been initialized.
    */
-  PRBool IsInitialized() const { return this->mTable.entrySize; }
+  PRBool IsInitialized() const { return !!this->mTable.entrySize; }
 
   /**
    * Return the number of entries in the table.
    * @return    number of entries
    */
   PRUint32 Count() const
   { return nsTHashtable<EntryType>::Count(); }
 
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -123,17 +123,17 @@ public:
    * @return PR_TRUE if the class was initialized properly.
    */
   PRBool Init(PRUint32 initSize = PL_DHASH_MIN_SIZE);
 
   /**
    * Check whether the table has been initialized. This can be useful for static hashtables.
    * @return the initialization state of the class.
    */
-  PRBool IsInitialized() const { return mTable.entrySize; }
+  PRBool IsInitialized() const { return !!mTable.entrySize; }
 
   /**
    * KeyType is typedef'ed for ease of use.
    */
   typedef typename EntryType::KeyType KeyType;
 
   /**
    * KeyTypePointer is typedef'ed for ease of use.
--- a/xpcom/glue/nsThreadUtils.cpp
+++ b/xpcom/glue/nsThreadUtils.cpp
@@ -188,17 +188,17 @@ NS_ProcessPendingEvents(nsIThread *threa
 #endif // XPCOM_GLUE_AVOID_NSPR
 
 PRBool
 NS_HasPendingEvents(nsIThread *thread)
 {
 #ifdef MOZILLA_INTERNAL_API
   if (!thread) {
     thread = NS_GetCurrentThread();
-    NS_ENSURE_STATE(thread);
+    NS_ENSURE_TRUE(thread, PR_FALSE);
   }
 #else
   nsCOMPtr<nsIThread> current;
   if (!thread) {
     NS_GetCurrentThread(getter_AddRefs(current));
     NS_ENSURE_TRUE(current, PR_FALSE);
     thread = current.get();
   }
@@ -208,17 +208,17 @@ NS_HasPendingEvents(nsIThread *thread)
 }
 
 PRBool
 NS_ProcessNextEvent(nsIThread *thread, PRBool mayWait)
 {
 #ifdef MOZILLA_INTERNAL_API
   if (!thread) {
     thread = NS_GetCurrentThread();
-    NS_ENSURE_STATE(thread);
+    NS_ENSURE_TRUE(thread, PR_FALSE);
   }
 #else
   nsCOMPtr<nsIThread> current;
   if (!thread) {
     NS_GetCurrentThread(getter_AddRefs(current));
     NS_ENSURE_TRUE(current, PR_FALSE);
     thread = current.get();
   }
--- a/xpcom/io/nsBinaryStream.cpp
+++ b/xpcom/io/nsBinaryStream.cpp
@@ -470,17 +470,17 @@ nsBinaryInputStream::SetInputStream(nsII
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadBoolean(PRBool* aBoolean)
 {
     PRUint8 byteResult;
     nsresult rv = Read8(&byteResult);
-    *aBoolean = byteResult;
+    *aBoolean = !!byteResult;
     return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::Read8(PRUint8* aByte)
 {
     nsresult rv;
     PRUint32 bytesRead;
--- a/xpcom/io/nsEscape.cpp
+++ b/xpcom/io/nsEscape.cpp
@@ -374,21 +374,21 @@ NS_COM PRBool NS_EscapeURL(const char *p
         NS_NOTREACHED("null pointer");
         return PR_FALSE;
     }
 
     int i = 0;
     static const char hexChars[] = "0123456789ABCDEF";
     if (partLen < 0)
         partLen = strlen(part);
-    PRBool forced = (flags & esc_Forced);
-    PRBool ignoreNonAscii = (flags & esc_OnlyASCII);
-    PRBool ignoreAscii = (flags & esc_OnlyNonASCII);
-    PRBool writing = (flags & esc_AlwaysCopy);
-    PRBool colon = (flags & esc_Colon);
+    PRBool forced = !!(flags & esc_Forced);
+    PRBool ignoreNonAscii = !!(flags & esc_OnlyASCII);
+    PRBool ignoreAscii = !!(flags & esc_OnlyNonASCII);
+    PRBool writing = !!(flags & esc_AlwaysCopy);
+    PRBool colon = !!(flags & esc_Colon);
 
     register const unsigned char* src = (const unsigned char *) part;
 
     char tempBuffer[100];
     unsigned int tempBufferPos = 0;
 
     PRBool previousIsNonASCII = PR_FALSE;
     for (i = 0; i < partLen; i++)
@@ -456,20 +456,20 @@ NS_COM PRBool NS_UnescapeURL(const char 
     if (!str) {
         NS_NOTREACHED("null pointer");
         return PR_FALSE;
     }
 
     if (len < 0)
         len = strlen(str);
 
-    PRBool ignoreNonAscii = (flags & esc_OnlyASCII);
-    PRBool ignoreAscii = (flags & esc_OnlyNonASCII);
-    PRBool writing = (flags & esc_AlwaysCopy);
-    PRBool skipControl = (flags & esc_SkipControl); 
+    PRBool ignoreNonAscii = !!(flags & esc_OnlyASCII);
+    PRBool ignoreAscii = !!(flags & esc_OnlyNonASCII);
+    PRBool writing = !!(flags & esc_AlwaysCopy);
+    PRBool skipControl = !!(flags & esc_SkipControl); 
 
     static const char hexChars[] = "0123456789ABCDEFabcdef";
 
     const char *last = str;
     const char *p = str;
 
     for (int i=0; i<len; ++i, ++p) {
         //printf("%c [i=%d of len=%d]\n", *p, i, len);
--- a/xpcom/io/nsPipe3.cpp
+++ b/xpcom/io/nsPipe3.cpp
@@ -1036,17 +1036,17 @@ nsPipeOutputStream::OnOutputWritable(nsP
 }
 
 PRBool
 nsPipeOutputStream::OnOutputException(nsresult reason, nsPipeEvents &events)
 {
     LOG(("nsPipeOutputStream::OnOutputException [this=%x reason=%x]\n",
         this, reason));
 
-    nsresult result = PR_FALSE;
+    PRBool result = PR_FALSE;
 
     NS_ASSERTION(NS_FAILED(reason), "huh? successful exception");
     mWritable = PR_FALSE;
 
     if (mCallback) {
         events.NotifyOutputReady(this, mCallback);
         mCallback = 0;
         mCallbackFlags = 0;
--- a/xpcom/io/nsScriptableInputStream.cpp
+++ b/xpcom/io/nsScriptableInputStream.cpp
@@ -208,17 +208,17 @@ nsScriptableInputStream::ReadLine(nsAStr
   return cstream->ReadLine(aLine, &mUnicharInputStreamHasMore);
 }
 
 NS_IMETHODIMP
 nsScriptableInputStream::ReadBoolean(PRBool* aBoolean)
 {
   PRUint8 byteResult;
   nsresult rv = Read8(&byteResult);
-  *aBoolean = byteResult;
+  *aBoolean = !!byteResult;
   return rv;
 }
 
 NS_IMETHODIMP
 nsScriptableInputStream::Read8(PRUint8* aVal)
 {
   return ReadFully(sizeof *aVal, reinterpret_cast<char*>(aVal));
 }
--- a/xpcom/proxy/src/nsProxyEvent.cpp
+++ b/xpcom/proxy/src/nsProxyEvent.cpp
@@ -288,17 +288,17 @@ nsProxyObjectCallInfo::CopyStrings(PRBoo
             }
         }
     }
 }
 
 PRBool                
 nsProxyObjectCallInfo::GetCompleted()
 {
-    return (PRBool)mCompleted;
+    return !!mCompleted;
 }
 
 void
 nsProxyObjectCallInfo::SetCompleted()
 {
     PROXY_LOG(("PROXY(%p): SetCompleted\n", this));
     PR_AtomicSet(&mCompleted, 1);
 }
--- a/xpcom/proxy/src/nsProxyEventPrivate.h
+++ b/xpcom/proxy/src/nsProxyEventPrivate.h
@@ -239,17 +239,17 @@ public:
     void                PostCompleted();
 
     void                SetResult(nsresult rv) { mResult = rv; }
     
     nsIEventTarget*     GetCallersTarget();
     void                SetCallersTarget(nsIEventTarget* target);
     PRBool              IsSync() const
     {
-        return mOwner->GetProxyType() & NS_PROXY_SYNC;
+        return !!(mOwner->GetProxyType() & NS_PROXY_SYNC);
     }
 
 private:
     
     nsresult         mResult;                    /* this is the return result of the called function */
     const XPTMethodDescriptor *mMethodInfo;
     PRUint32         mMethodIndex;               /* which method to be called? */
     nsXPTCVariant   *mParameterList;             /* marshalled in parameter buffer */
--- a/xpcom/reflect/xptinfo/public/xptinfo.h
+++ b/xpcom/reflect/xptinfo/public/xptinfo.h
@@ -89,17 +89,17 @@ public:
                return PR_FALSE;
              case T_INTERFACE:
              case T_INTERFACE_IS:
                return PR_TRUE;
            }
         }
 
     PRBool IsArray() const
-        {return (PRBool) TagPart() == T_ARRAY;}
+        {return TagPart() == T_ARRAY;}
 
     // 'Dependent' means that params of this type are dependent upon other 
     // params. e.g. an T_INTERFACE_IS is dependent upon some other param at 
     // runtime to say what the interface type of this param really is.
     PRBool IsDependent() const
         {  switch (TagPart()) {
              default:
                return PR_FALSE;
--- a/xpcom/reflect/xptinfo/src/xptiManifest.cpp
+++ b/xpcom/reflect/xptinfo/src/xptiManifest.cpp
@@ -97,24 +97,24 @@ xpti_InterfaceWriter(PLDHashTable *table
     PRFileDesc* fd = (PRFileDesc*)  arg;
 
     char* iidStr = entry->GetTheIID()->ToString();
     if(!iidStr)
         return PL_DHASH_STOP;
 
     const xptiTypelib& typelib = entry->GetTypelibRecord();
 
-    PRBool success =  PR_fprintf(fd, "%d,%s,%s,%d,%d,%d\n",
-                                 (int) number,
-                                 entry->GetTheName(),
-                                 iidStr,
-                                 (int) typelib.GetFileIndex(),
-                                 (int) (typelib.IsZip() ? 
-                                 typelib.GetZipItemIndex() : -1),
-                                 (int) entry->GetScriptableFlag());
+    PRBool success =  !!PR_fprintf(fd, "%d,%s,%s,%d,%d,%d\n",
+                                   (int) number,
+                                   entry->GetTheName(),
+                                   iidStr,
+                                   (int) typelib.GetFileIndex(),
+                                   (int) (typelib.IsZip() ? 
+                                   typelib.GetZipItemIndex() : -1),
+                                   (int) entry->GetScriptableFlag());
 
     nsCRT::free(iidStr);
 
     return success ? PL_DHASH_NEXT : PL_DHASH_STOP;
 }
 
 
 // static
--- a/xpcom/typelib/xpt/public/xpt_struct.h
+++ b/xpcom/typelib/xpt/public/xpt_struct.h
@@ -263,18 +263,18 @@ struct XPTInterfaceDescriptor {
 };
 
 #define XPT_ID_SCRIPTABLE           0x80
 #define XPT_ID_FUNCTION             0x40
 #define XPT_ID_FLAGMASK             0xc0
 #define XPT_ID_TAGMASK              (~XPT_ID_FLAGMASK)
 #define XPT_ID_TAG(id)              ((id).flags & XPT_ID_TAGMASK)
 
-#define XPT_ID_IS_SCRIPTABLE(flags) (flags & XPT_ID_SCRIPTABLE)
-#define XPT_ID_IS_FUNCTION(flags) (flags & XPT_ID_FUNCTION)
+#define XPT_ID_IS_SCRIPTABLE(flags) (!!(flags & XPT_ID_SCRIPTABLE))
+#define XPT_ID_IS_FUNCTION(flags) (!!(flags & XPT_ID_FUNCTION))
 
 extern XPT_PUBLIC_API(PRBool)
 XPT_GetInterfaceIndexByName(XPTInterfaceDirectoryEntry *ide_block,
                             PRUint16 num_interfaces, char *name, 
                             PRUint16 *indexp);
 
 extern XPT_PUBLIC_API(XPTInterfaceDescriptor *)
 XPT_NewInterfaceDescriptor(XPTArena *arena,