Bug 676188 - Misc misuses of PRBool caught by the compiler, r=jimm,jst,bz,dougt,roc,mak
authorMichael Wu <mwu@mozilla.com>
Tue, 30 Aug 2011 11:55:14 -0700
changeset 76621 a513e2816eaf5d55964ddd990c86c768da0ec520
parent 76620 4d07f8ccbbaf941d9506bcf092ebcee978f1c594
child 76622 0cf9208a2bb55fb47c3c0eb0efe3783a8f51e198
push idunknown
push userunknown
push dateunknown
reviewersjimm, jst, bz, dougt, roc, mak
bugs676188
milestone9.0a1
Bug 676188 - Misc misuses of PRBool caught by the compiler, r=jimm,jst,bz,dougt,roc,mak
browser/components/shell/src/nsWindowsShellService.cpp
extensions/cookie/nsCookiePermission.cpp
extensions/cookie/nsCookiePromptService.cpp
layout/tables/nsTableRowFrame.h
modules/libreg/include/VerReg.h
netwerk/base/src/nsAutodialWin.cpp
netwerk/base/src/nsStandardURL.h
parser/htmlparser/src/CNavDTD.cpp
toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
toolkit/components/places/nsNavHistory.cpp
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -339,19 +339,21 @@ nsWindowsShellService::IsDefaultBrowserV
   
   HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
                                 NULL,
                                 CLSCTX_INPROC,
                                 IID_IApplicationAssociationRegistration,
                                 (void**)&pAAR);
 
   if (SUCCEEDED(hr)) {
+    BOOL res;
     hr = pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE,
                                     APP_REG_NAME,
-                                    aIsDefaultBrowser);
+                                    &res);
+    *aIsDefaultBrowser = res;
 
     pAAR->Release();
     return PR_TRUE;
   }
 #endif  
   return PR_FALSE;
 }
 
--- a/extensions/cookie/nsCookiePermission.cpp
+++ b/extensions/cookie/nsCookiePermission.cpp
@@ -362,26 +362,28 @@ nsCookiePermission::CanSetCookie(nsIURI 
       if (!foundCookie && !*aIsSession && delta <= 0) {
         // the cookie has already expired. accept it, and let the backend figure
         // out it's expired, so that we get correct logging & notifications.
         *aResult = PR_TRUE;
         return rv;
       }
 
       PRBool rememberDecision = PR_FALSE;
+      PRInt32 dialogRes = nsICookiePromptService::DENY_COOKIE;
       rv = cookiePromptService->CookieDialog(parent, aCookie, hostPort, 
                                              countFromHost, foundCookie,
-                                             &rememberDecision, aResult);
+                                             &rememberDecision, &dialogRes);
       if (NS_FAILED(rv)) return rv;
-      
-      if (*aResult == nsICookiePromptService::ACCEPT_SESSION_COOKIE)
+
+      *aResult = !!dialogRes;
+      if (dialogRes == nsICookiePromptService::ACCEPT_SESSION_COOKIE)
         *aIsSession = PR_TRUE;
 
       if (rememberDecision) {
-        switch (*aResult) {
+        switch (dialogRes) {
           case nsICookiePromptService::DENY_COOKIE:
             mPermMgr->Add(aURI, kPermissionType, (PRUint32) nsIPermissionManager::DENY_ACTION,
                           nsIPermissionManager::EXPIRE_NEVER, 0);
             break;
           case nsICookiePromptService::ACCEPT_COOKIE:
             mPermMgr->Add(aURI, kPermissionType, (PRUint32) nsIPermissionManager::ALLOW_ACTION,
                           nsIPermissionManager::EXPIRE_NEVER, 0);
             break;
--- a/extensions/cookie/nsCookiePromptService.cpp
+++ b/extensions/cookie/nsCookiePromptService.cpp
@@ -109,17 +109,17 @@ nsCookiePromptService::CookieDialog(nsID
   // avoids unwanted tab switches (see bug 405239).
   rv = wwatcher->OpenWindow(parent, "chrome://cookie/content/cookieAcceptDialog.xul", "_blank",
                             "centerscreen,chrome,modal,titlebar", arguments,
                             getter_AddRefs(dialog));
 
   if (NS_FAILED(rv)) return rv;
 
   // get back output parameters
-  PRBool tempValue;
+  PRInt32 tempValue;
   block->GetInt(nsICookieAcceptDialog::ACCEPT_COOKIE, &tempValue);
   *aAccept = tempValue;
   
   // GetInt returns a PRInt32; we need to sanitize it into PRBool
   block->GetInt(nsICookieAcceptDialog::REMEMBER_DECISION, &tempValue);
   *aRememberDecision = (tempValue == 1);
 
   return rv;
--- a/layout/tables/nsTableRowFrame.h
+++ b/layout/tables/nsTableRowFrame.h
@@ -199,18 +199,18 @@ public:
                        PRInt32           aColIndex);
 
   nsresult CalculateCellActualHeight(nsTableCellFrame* aCellFrame,
                                      nscoord&          aDesiredHeight);
 
   PRBool IsFirstInserted() const;
   void   SetFirstInserted(PRBool aValue);
 
-  PRBool GetContentHeight() const;
-  void   SetContentHeight(nscoord aTwipValue);
+  nscoord GetContentHeight() const;
+  void    SetContentHeight(nscoord aTwipValue);
 
   PRBool HasStyleHeight() const;
 
   PRBool HasFixedHeight() const;
   void   SetHasFixedHeight(PRBool aValue);
 
   PRBool HasPctHeight() const;
   void   SetHasPctHeight(PRBool aValue);
--- a/modules/libreg/include/VerReg.h
+++ b/modules/libreg/include/VerReg.h
@@ -89,17 +89,17 @@ VR_INTERFACE(REGERR) VR_SetDefaultDirect
 VR_INTERFACE(REGERR) VR_UninstallCreateNode(char *regPackageName, char *userPackageName);
 VR_INTERFACE(REGERR) VR_UninstallAddFileToList(char *regPackageName, char *vrName);
 VR_INTERFACE(REGERR) VR_UninstallFileExistsInList(char *regPackageName, char *vrName);
 VR_INTERFACE(REGERR) VR_UninstallEnumSharedFiles(char *component_path, REGENUM *state, char *buffer, uint32 buflen);
 VR_INTERFACE(REGERR) VR_UninstallDeleteFileFromList(char *component_path, char *vrName);
 VR_INTERFACE(REGERR) VR_UninstallDeleteSharedFilesKey(char *regPackageName);
 VR_INTERFACE(REGERR) VR_UninstallDestroy(char *regPackageName);
 VR_INTERFACE(REGERR) VR_EnumUninstall(REGENUM *state, char* userPackageName,
-                                    int32 len1, char*regPackageName, int32 len2, PRBool bSharedList);
+                                    int32 len1, char*regPackageName, int32 len2, XP_Bool bSharedList);
 VR_INTERFACE(REGERR) VR_GetUninstallUserName(char *regPackageName, char *outbuf, uint32 buflen);
 
 PR_END_EXTERN_C
 
 #endif   /* _VERREG_H_ */
 
 /* EOF: VerReg.h */
 
--- a/netwerk/base/src/nsAutodialWin.cpp
+++ b/netwerk/base/src/nsAutodialWin.cpp
@@ -372,17 +372,17 @@ nsresult nsAutodial::DialDefault(const P
 PRBool nsAutodial::IsRASConnected()
 {
     DWORD connections;
     RASCONN rasConn;
     rasConn.dwSize = sizeof(rasConn);
     DWORD structSize = sizeof(rasConn);
 
     if (!LoadRASapi32DLL())
-        return NS_ERROR_NULL_POINTER;
+        return PR_FALSE;
 
     DWORD result = (*mpRasEnumConnections)(&rasConn, &structSize, &connections);
 
     // ERROR_BUFFER_TOO_SMALL is OK because we only need one struct.
     if (result == ERROR_SUCCESS || result == ERROR_BUFFER_TOO_SMALL)
     {
         return (connections > 0);
     }
@@ -666,17 +666,17 @@ int nsAutodial::GetCurrentLocation()
 PRBool nsAutodial::IsAutodialServiceEnabled(int location)
 {
     if (location < 0)
         return PR_FALSE;
 
     if (!LoadRASapi32DLL())
         return PR_FALSE;
 
-    PRBool enabled;
+    BOOL enabled;
     if ((*mpRasGetAutodialEnable)(location, &enabled) != ERROR_SUCCESS)
     {
         LOGE(("Autodial: Error calling RasGetAutodialEnable()"));
         return PR_FALSE;
     }
 
     return enabled;
 }
--- a/netwerk/base/src/nsStandardURL.h
+++ b/netwerk/base/src/nsStandardURL.h
@@ -333,17 +333,17 @@ nsStandardURL::Prepath()
 {
     PRUint32 len = 0;
     if (mAuthority.mLen >= 0)
         len = mAuthority.mPos + mAuthority.mLen;
     return Substring(mSpec, 0, len);
 }
 
 inline const nsDependentCSubstring
-nsStandardURL::Userpass(int includeDelim)
+nsStandardURL::Userpass(PRBool includeDelim)
 {
     PRUint32 pos=0, len=0;
     // if there is no username, then there can be no password
     if (mUsername.mLen > 0) {
         pos = mUsername.mPos;
         len = mUsername.mLen;
         if (mPassword.mLen >= 0)
             len += (mPassword.mLen + 1);
--- a/parser/htmlparser/src/CNavDTD.cpp
+++ b/parser/htmlparser/src/CNavDTD.cpp
@@ -877,17 +877,17 @@ CNavDTD::HandleDefaultStartToken(CToken*
   nsresult  result = NS_OK;
   PRBool  theChildIsContainer = nsHTMLElement::IsContainer(aChildTag);
 
   // Client of parser is spefically trying to parse a fragment that
   // may lack required context.  Suspend containment rules if so.
   if (mParserCommand != eViewFragment) {
     PRBool  theChildAgrees = PR_TRUE;
     PRInt32 theIndex = mBodyContext->GetCount();
-    PRBool  theParentContains = PR_FALSE;
+    PRInt32 theParentContains = 0;
 
     do {
       eHTMLTags theParentTag = mBodyContext->TagAt(--theIndex);
       if (theParentTag == eHTMLTag_userdefined) {
         continue;
       }
 
       // Figure out whether this is a hidden input inside a
--- a/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
+++ b/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
@@ -228,20 +228,24 @@ nsParentalControlsServiceWin::RequestURI
   HWND hWnd = nsnull;
   // If we have a native window, use its handle instead
   nsCOMPtr<nsIWidget> widget(do_GetInterface(aWindowContext));
   if (widget)
     hWnd = (HWND)widget->GetNativeData(NS_NATIVE_WINDOW);
   if (hWnd == nsnull)
     hWnd = GetDesktopWindow();
 
+  BOOL ret;
   nsRefPtr<IWPCWebSettings> wpcws;
-  if (SUCCEEDED(mPC->GetWebSettings(NULL, getter_AddRefs(wpcws))))
+  if (SUCCEEDED(mPC->GetWebSettings(NULL, getter_AddRefs(wpcws)))) {
     wpcws->RequestURLOverride(hWnd, NS_ConvertUTF8toUTF16(spec).get(),
-                              0, NULL, _retval);
+                              0, NULL, &ret);
+    *_retval = ret;
+  }
+
 
   return NS_OK;
 }
 
 // Override a web page
 NS_IMETHODIMP
 nsParentalControlsServiceWin::RequestURIOverrides(nsIArray *aTargets, nsIInterfaceRequestor *aWindowContext, PRBool *_retval)
 {
@@ -303,21 +307,24 @@ nsParentalControlsServiceWin::RequestURI
     if (!arrUrls[uriIdx])
       continue;
 
     uriIdx++;
   }
 
   if (!uriIdx)
     return NS_ERROR_INVALID_ARG;
- 
+
+  BOOL ret; 
   nsRefPtr<IWPCWebSettings> wpcws;
-  if (SUCCEEDED(mPC->GetWebSettings(NULL, getter_AddRefs(wpcws))))
+  if (SUCCEEDED(mPC->GetWebSettings(NULL, getter_AddRefs(wpcws)))) {
     wpcws->RequestURLOverride(hWnd, NS_ConvertUTF8toUTF16(rootSpec).get(),
-                             uriIdx, (LPCWSTR*)arrUrls.get(), _retval);
+                             uriIdx, (LPCWSTR*)arrUrls.get(), &ret);
+   *_retval = ret;
+  }
 
   // Free up the allocated strings in our array
   for (idx = 0; idx < uriIdx; idx++)
     NS_Free((void*)arrUrls[idx]);
 
   return NS_OK;
 }
 
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -2675,17 +2675,17 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRT
     PRInt32 oldVisitCount = 0;
     rv = stmt->GetInt32(1, &oldVisitCount);
     NS_ENSURE_SUCCESS(rv, rv);
 
     PRInt32 oldTypedState = 0;
     rv = stmt->GetInt32(2, &oldTypedState);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    PRBool oldHiddenState = 0;
+    PRInt32 oldHiddenState = 0;
     rv = stmt->GetInt32(3, &oldHiddenState);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = stmt->GetUTF8String(4, guid);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // free the previous statement before we make a new one
     stmt->Reset();