Bug 801803: More nsresult as enum class creates warnings r=me
☠☠ backed out by e54905d168d3 ☠ ☠
authorDavid Zbarsky <dzbarsky@gmail.com>
Mon, 15 Oct 2012 23:37:34 -0400
changeset 110506 368cd30cccda35ed7f2baa5532863d9af543ed0c
parent 110505 fb167937d25b7f274230d714482c332137c22d0a
child 110507 e54905d168d3fe37a29a4b58bae1db70f8283c09
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersme
bugs801803
milestone19.0a1
Bug 801803: More nsresult as enum class creates warnings r=me
js/xpconnect/shell/xpcshell.cpp
netwerk/cache/nsCacheService.cpp
netwerk/test/TestDNS.cpp
netwerk/test/TestIncrementalDownload.cpp
netwerk/test/TestOpen.cpp
netwerk/test/TestPageLoad.cpp
xpcom/sample/program/nsTestSample.cpp
--- a/js/xpconnect/shell/xpcshell.cpp
+++ b/js/xpconnect/shell/xpcshell.cpp
@@ -1845,17 +1845,17 @@ main(int argc, char **argv, char **envp)
             printf("failed to push the current JSContext on the nsThreadJSContextStack!\n");
             return 1;
         }
 
         nsCOMPtr<nsIXPCScriptable> backstagePass;
         nsresult rv = rtsvc->GetBackstagePass(getter_AddRefs(backstagePass));
         if (NS_FAILED(rv)) {
             fprintf(gErrFile, "+++ Failed to get backstage pass from rtsvc: %8x\n",
-                    rv);
+                    static_cast<uint32_t>(rv));
             return 1;
         }
 
         nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
         rv = xpc->InitClassesWithNewWrappedGlobal(cx, backstagePass,
                                                   systemprincipal,
                                                   0,
                                                   getter_AddRefs(holder));
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1541,17 +1541,18 @@ nsCacheService::CreateDiskDevice()
     mDiskDevice->SetCacheParentDirectory(mObserver->DiskCacheParentDirectory());
     mDiskDevice->SetCapacity(mObserver->DiskCacheCapacity());
     mDiskDevice->SetMaxEntrySize(mObserver->DiskCacheMaxEntrySize());
     
     nsresult rv = mDiskDevice->Init();
     if (NS_FAILED(rv)) {
 #if DEBUG
         printf("###\n");
-        printf("### mDiskDevice->Init() failed (0x%.8x)\n", rv);
+        printf("### mDiskDevice->Init() failed (0x%.8x)\n",
+               static_cast<uint32_t>(rv));
         printf("###    - disabling disk cache for this session.\n");
         printf("###\n");
 #endif        
         mEnableDiskDevice = false;
         delete mDiskDevice;
         mDiskDevice = nullptr;
         return rv;
     }
--- a/netwerk/test/TestDNS.cpp
+++ b/netwerk/test/TestDNS.cpp
@@ -29,17 +29,17 @@ public:
         , mIndex(index) {}
     virtual ~myDNSListener() {}
 
     NS_IMETHOD OnLookupComplete(nsICancelable *request,
                                 nsIDNSRecord  *rec,
                                 nsresult       status)
     {
         printf("%d: OnLookupComplete called [host=%s status=%x rec=%p]\n",
-            mIndex, mHost.get(), status, (void*)rec);
+            mIndex, mHost.get(), static_cast<uint32_t>(status), (void*)rec);
 
         if (NS_SUCCEEDED(status)) {
             nsAutoCString buf;
 
             rec->GetCanonicalName(buf);
             printf("%d: canonname=%s\n", mIndex, buf.get());
 
             bool hasMore;
@@ -106,17 +106,18 @@ int main(int argc, char **argv)
 
                 nsCOMPtr<nsIDNSListener> listener = new myDNSListener(argv[i], i);
 
                 nsCOMPtr<nsICancelable> req;
                 nsresult rv = dns->AsyncResolve(hostBuf,
                                                 nsIDNSService::RESOLVE_CANONICAL_NAME,
                                                 listener, nullptr, getter_AddRefs(req));
                 if (NS_FAILED(rv))
-                    printf("### AsyncResolve failed [rv=%x]\n", rv);
+                    printf("### AsyncResolve failed [rv=%x]\n",
+                           static_cast<uint32_t>(rv));
             }
 
             printf("main thread sleeping for %d seconds...\n", sleepLen);
             PR_Sleep(PR_SecondsToInterval(sleepLen));
         }
 
         printf("shutting down main thread...\n");
         dns->Shutdown();
--- a/netwerk/test/TestIncrementalDownload.cpp
+++ b/netwerk/test/TestIncrementalDownload.cpp
@@ -52,17 +52,18 @@ FetchObserver::OnStatus(nsIRequest *requ
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 FetchObserver::OnStopRequest(nsIRequest *request, nsISupports *context,
                              nsresult status)
 {
-  printf("FetchObserver::OnStopRequest [status=%x]\n", status);
+  printf("FetchObserver::OnStopRequest [status=%x]\n",
+         static_cast<uint32_t>(status));
 
   QuitPumpingEvents();
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 
 static nsresult
@@ -116,13 +117,14 @@ main(int argc, char **argv)
   if (NS_FAILED(rv))
     return -1;
 
   int32_t chunkSize = atoi(argv[3]);
   int32_t interval = atoi(argv[4]);
 
   rv = DoIncrementalFetch(argv[1], argv[2], chunkSize, interval);
   if (NS_FAILED(rv))
-    fprintf(stderr, "ERROR: DoIncrementalFetch failed [%x]\n", rv);
+    fprintf(stderr, "ERROR: DoIncrementalFetch failed [%x]\n",
+            static_cast<uint32_t>(rv));
 
   NS_ShutdownXPCOM(nullptr);
   return 0;
 }
--- a/netwerk/test/TestOpen.cpp
+++ b/netwerk/test/TestOpen.cpp
@@ -19,17 +19,17 @@ using namespace mozilla;
 
 /*
  * Test synchronous Open.
  */
 
 #define RETURN_IF_FAILED(rv, what) \
     PR_BEGIN_MACRO \
     if (NS_FAILED(rv)) { \
-        printf(what ": failed - %08x\n", rv); \
+        printf(what ": failed - %08x\n", static_cast<uint32_t>(rv)); \
         return -1; \
     } \
     PR_END_MACRO
 
 int
 main(int argc, char **argv)
 {
     if (test_common_init(&argc, &argv) != 0)
--- a/netwerk/test/TestPageLoad.cpp
+++ b/netwerk/test/TestPageLoad.cpp
@@ -175,17 +175,18 @@ MyListener::OnDataAvailable(nsIRequest *
       while (count) {
         uint32_t amount = NS_MIN<uint32_t>(count, sizeof(buf));
         rv = stream->Read(buf, amount, &bytesRead);  
         count -= bytesRead;
       }
     }
 
     if (NS_FAILED(rv)) {
-      printf(">>> stream->Read failed with rv=%x\n", rv);
+      printf(">>> stream->Read failed with rv=%x\n",
+             static_cast<uint32_t>(rv));
       return rv;
     }
 
     return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // NotificationCallbacks implementation
--- a/xpcom/sample/program/nsTestSample.cpp
+++ b/xpcom/sample/program/nsTestSample.cpp
@@ -28,62 +28,66 @@ main(void)
 
     XPCOMGlueStartup(nullptr);
 
     // Initialize XPCOM
     nsCOMPtr<nsIServiceManager> servMan;
     rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
     if (NS_FAILED(rv))
     {
-        printf("ERROR: XPCOM intialization error [%x].\n", rv);
+        printf("ERROR: XPCOM intialization error [%x].\n",
+               static_cat<uint32_t>(rv));
         return -1;
     }
 
     nsCOMPtr<nsIComponentManager> manager = do_QueryInterface(servMan);
-    
+
     // Create an instance of our component
     nsCOMPtr<nsISample> mysample;
     rv = manager->CreateInstanceByContractID(NS_SAMPLE_CONTRACTID,
                                              nullptr,
                                              NS_GET_IID(nsISample),
                                              getter_AddRefs(mysample));
     if (NS_FAILED(rv))
     {
         printf("ERROR: Cannot create instance of component " NS_SAMPLE_CONTRACTID " [%x].\n"
                "Debugging hint:\n"
                "\tsetenv NSPR_LOG_MODULES nsComponentManager:5\n"
                "\tsetenv NSPR_LOG_FILE xpcom.log\n"
                "\t./nsTestSample\n"
                "\t<check the contents for xpcom.log for possible cause of error>.\n",
-               rv);
+               static_cast<uint32_t>(rv));
         return -2;
     }
 
     // Call methods on our sample to test it out.
     rv = mysample->WriteValue("Inital print:");
     if (NS_FAILED(rv))
     {
-        printf("ERROR: Calling nsISample::WriteValue() [%x]\n", rv);
+        printf("ERROR: Calling nsISample::WriteValue() [%x]\n",
+               static_cast<uint32_t>(rv));
         return -3;
     }
 
     const char *testValue = "XPCOM defies gravity";
     rv = mysample->SetValue(testValue);
     if (NS_FAILED(rv))
     {
-        printf("ERROR: Calling nsISample::SetValue() [%x]\n", rv);
+        printf("ERROR: Calling nsISample::SetValue() [%x]\n",
+               static_cast<uint32_t>(rv));
         return -3;
     }
     printf("Set value to: %s\n", testValue);
     char *str;
     rv = mysample->GetValue(&str);
 
     if (NS_FAILED(rv))
     {
-        printf("ERROR: Calling nsISample::GetValue() [%x]\n", rv);
+        printf("ERROR: Calling nsISample::GetValue() [%x]\n",
+               static_cast<uint32_t>(rv));
         return -3;
     }
     if (strcmp(str, testValue))
     {
         printf("Test FAILED.\n");
         return -4;
     }