Bug 398435 - "PRBool misuse bugs in xpcom/" [p=taras r=bsmedberg a1.9=sayrer]

This commit is contained in:
reed@reedloden.com 2007-10-19 16:26:52 -07:00
parent fbef483d10
commit 59d2451ae9
13 changed files with 30 additions and 30 deletions

View File

@ -795,7 +795,7 @@ nsObjectHashtable::RemoveAndDelete(nsHashKey *aKey)
{
void *value = Remove(aKey);
if (value && mDestroyElementFun)
return (*mDestroyElementFun)(aKey, value, mDestroyElementClosure);
return !!(*mDestroyElementFun)(aKey, value, mDestroyElementClosure);
return PR_FALSE;
}

View File

@ -103,7 +103,7 @@ public:
* 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.

View File

@ -128,7 +128,7 @@ public:
* 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.

View File

@ -193,7 +193,7 @@ 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;
@ -213,7 +213,7 @@ 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;

View File

@ -475,7 +475,7 @@ nsBinaryInputStream::ReadBoolean(PRBool* aBoolean)
{
PRUint8 byteResult;
nsresult rv = Read8(&byteResult);
*aBoolean = byteResult;
*aBoolean = !!byteResult;
return rv;
}

View File

@ -379,11 +379,11 @@ NS_COM PRBool NS_EscapeURL(const char *part,
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;
@ -461,10 +461,10 @@ NS_COM PRBool NS_UnescapeURL(const char *str, PRInt32 len, PRUint32 flags, nsACS
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";

View File

@ -1041,7 +1041,7 @@ 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;

View File

@ -213,7 +213,7 @@ nsScriptableInputStream::ReadBoolean(PRBool* aBoolean)
{
PRUint8 byteResult;
nsresult rv = Read8(&byteResult);
*aBoolean = byteResult;
*aBoolean = !!byteResult;
return rv;
}

View File

@ -293,7 +293,7 @@ nsProxyObjectCallInfo::CopyStrings(PRBool copy)
PRBool
nsProxyObjectCallInfo::GetCompleted()
{
return (PRBool)mCompleted;
return !!mCompleted;
}
void

View File

@ -244,7 +244,7 @@ public:
void SetCallersTarget(nsIEventTarget* target);
PRBool IsSync() const
{
return mOwner->GetProxyType() & NS_PROXY_SYNC;
return !!(mOwner->GetProxyType() & NS_PROXY_SYNC);
}
private:

View File

@ -94,7 +94,7 @@ public:
}
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

View File

@ -102,14 +102,14 @@ xpti_InterfaceWriter(PLDHashTable *table, PLDHashEntryHdr *hdr,
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);

View File

@ -268,8 +268,8 @@ struct XPTInterfaceDescriptor {
#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,