Bug 792581 - part 16: Replace LL_L2UI macro with uint32_t cast. r=ehsan
authorAndrew Quartey <andrew.quartey@gmail.com>
Fri, 12 Oct 2012 13:29:11 -0400
changeset 110251 14cef04d0b3455b4337d286683f7ebe291de26d1
parent 110250 6857ec16567d206eba481cd8e907da16f9a23c7d
child 110252 7ed2340f0df6ad4f1f53a453c15134d46b38e379
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersehsan
bugs792581
milestone19.0a1
Bug 792581 - part 16: Replace LL_L2UI macro with uint32_t cast. r=ehsan
content/base/src/nsXMLHttpRequest.cpp
extensions/pref/autoconfig/src/nsAutoConfig.cpp
js/xpconnect/loader/mozJSComponentLoader.cpp
netwerk/base/src/nsProtocolProxyService.cpp
netwerk/cache/nsCache.cpp
netwerk/dns/nsHostResolver.cpp
netwerk/test/TestPageLoad.cpp
rdf/base/src/nsRDFService.cpp
security/manager/ssl/src/nsNSSComponent.cpp
tools/trace-malloc/spacetrace.c
tools/trace-malloc/tmfrags.c
tools/trace-malloc/tmstats.c
widget/xpwidgets/nsTransferable.cpp
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -4105,25 +4105,25 @@ nsXMLHttpProgressEvent::WarnAboutLSProgr
   }
   document->WarnOnceAbout(aOperation);
 }
 
 NS_IMETHODIMP nsXMLHttpProgressEvent::GetPosition(uint32_t *aPosition)
 {
   WarnAboutLSProgressEvent(nsIDocument::ePosition);
   // XXX can we change the iface?
-  LL_L2UI(*aPosition, mCurProgress);
+  *aPosition = uint32_t(mCurProgress);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXMLHttpProgressEvent::GetTotalSize(uint32_t *aTotalSize)
 {
   WarnAboutLSProgressEvent(nsIDocument::eTotalSize);
   // XXX can we change the iface?
-  LL_L2UI(*aTotalSize, mMaxProgress);
+  *aTotalSize = uint32_t(mMaxProgress);
   return NS_OK;
 }
 
 // nsXMLHttpRequestXPCOMifier implementation
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXMLHttpRequestXPCOMifier)
   NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
   NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
   NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
--- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp
+++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp
@@ -413,23 +413,23 @@ nsresult nsAutoConfig::evaluateLocalFile
     nsresult rv;
     nsCOMPtr<nsIInputStream> inStr;
     
     rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), file);
     if (NS_FAILED(rv)) 
         return rv;
         
     int64_t fileSize;
-    uint32_t fs, amt=0;
     file->GetFileSize(&fileSize);
-    LL_L2UI(fs, fileSize); // Converting 64 bit structure to unsigned int
+    uint32_t fs = fileSize; // Converting 64 bit structure to unsigned int
     char *buf = (char *)PR_Malloc(fs * sizeof(char));
     if (!buf) 
         return NS_ERROR_OUT_OF_MEMORY;
-    
+
+    uint32_t amt = 0;
     rv = inStr->Read(buf, fs, &amt);
     if (NS_SUCCEEDED(rv)) {
       EvaluateAdminConfigScript(buf, fs, nullptr, false, 
                                 true, false);
     }
     inStr->Close();
     PR_Free(buf);
     return rv;
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -765,18 +765,17 @@ mozJSComponentLoader::GlobalForLocation(
                 NS_ERROR("Failed to create file map");
                 JS_SetOptions(cx, oldopts);
                 return NS_ERROR_FAILURE;
             }
 
             // Make sure the file map is closed, no matter how we return.
             FileMapAutoCloser mapCloser(map);
 
-            uint32_t fileSize32;
-            LL_L2UI(fileSize32, fileSize);
+            uint32_t fileSize32 = fileSize;
 
             char *buf = static_cast<char*>(PR_MemMap(map, 0, fileSize32));
             if (!buf) {
                 NS_WARNING("Failed to map file");
                 JS_SetOptions(cx, oldopts);
                 return NS_ERROR_FAILURE;
             }
 
--- a/netwerk/base/src/nsProtocolProxyService.cpp
+++ b/netwerk/base/src/nsProtocolProxyService.cpp
@@ -781,21 +781,18 @@ nsProtocolProxyService::SecondsSinceSess
     // get time elapsed since session start
     int64_t diff = now - mSessionStart;
 
     // convert microseconds to seconds
     PRTime ups;
     LL_I2L(ups, PR_USEC_PER_SEC);
     diff /= ups;
 
-    // convert to 32 bit value
-    uint32_t dsec;
-    LL_L2UI(dsec, diff);
-
-    return dsec;
+    // return converted 32 bit value
+    return uint32_t(diff);
 }
 
 void
 nsProtocolProxyService::EnableProxy(nsProxyInfo *pi)
 {
     nsAutoCString key;
     GetProxyKey(pi, key);
     mFailedProxies.Remove(key);
--- a/netwerk/cache/nsCache.cpp
+++ b/netwerk/cache/nsCache.cpp
@@ -40,23 +40,19 @@ CacheLogPrintPath(PRLogModuleLevel level
 }
 
 #endif
 
 
 uint32_t
 SecondsFromPRTime(PRTime prTime)
 {
-  int64_t  microSecondsPerSecond, intermediateResult;
-  uint32_t seconds;
-
+  int64_t  microSecondsPerSecond;
   LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
-  intermediateResult = prTime / microSecondsPerSecond;
-  LL_L2UI(seconds, intermediateResult);
-  return seconds;
+  return uint32_t(prTime / microSecondsPerSecond);
 }
 
 
 PRTime
 PRTimeFromSeconds(uint32_t seconds)
 {
   int64_t microSecondsPerSecond, intermediateResult;
   PRTime  prTime;
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -83,22 +83,19 @@ MoveCList(PRCList &from, PRCList &to)
         to.prev->next = &to;
         PR_INIT_CLIST(&from);
     }             
 }
 
 static uint32_t
 NowInMinutes()
 {
-    PRTime now = PR_Now(), minutes, factor;
+    PRTime now = PR_Now(), factor;
     LL_I2L(factor, 60 * PR_USEC_PER_SEC);
-    minutes = now / factor;
-    uint32_t result;
-    LL_L2UI(result, minutes);
-    return result;
+    return uint32_t(now / factor);
 }
 
 //----------------------------------------------------------------------------
 
 #if defined(RES_RETRY_ON_FAILURE)
 
 // this class represents the resolver state for a given thread.  if we
 // encounter a lookup failure, then we can invoke the Reset method on an
--- a/netwerk/test/TestPageLoad.cpp
+++ b/netwerk/test/TestPageLoad.cpp
@@ -347,19 +347,17 @@ int main(int argc, char **argv)
         printf("Starting clock ... \n");
         start = PR_Now();
         rv = chan->AsyncOpen(listener, nullptr);
         RETURN_IF_FAILED(rv, -1, "AsyncOpen");
 
         PumpEvents();
 
         finish = PR_Now();
-        uint32_t totalTime32;
-        uint64_t totalTime64 = finish - start;
-        LL_L2UI(totalTime32, totalTime64);
+        uint32_t totalTime32 = uint32_t(finish - start);
 
         printf("\n\n--------------------\nAll done:\nnum found:%d\nnum start:%d\n", numFound, numStart);
 
         printf("\n\n>>PageLoadTime>>%u>>\n\n", totalTime32);
     } // this scopes the nsCOMPtrs
     // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
     rv = NS_ShutdownXPCOM(nullptr);
     NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
--- a/rdf/base/src/nsRDFService.cpp
+++ b/rdf/base/src/nsRDFService.cpp
@@ -1007,17 +1007,17 @@ static int32_t kShift = 6;
         // Start it at a semi-unique value, just to minimize the
         // chance that we get into a situation where
         //
         // 1. An anonymous resource gets serialized out in a graph
         // 2. Reboot
         // 3. The same anonymous resource gets requested, and refers
         //    to something completely different.
         // 4. The serialization is read back in.
-        LL_L2UI(gCounter, PR_Now());
+        gCounter = uint32_t(PR_Now());
     }
 
     nsresult rv;
     nsAutoCString s;
 
     do {
         // Ugh, this is a really sloppy way to do this; I copied the
         // implementation from the days when it lived outside the RDF
--- a/security/manager/ssl/src/nsNSSComponent.cpp
+++ b/security/manager/ssl/src/nsNSSComponent.cpp
@@ -1380,17 +1380,16 @@ nsNSSComponent::RemoveCrlFromList(nsAuto
   return NS_OK;
 }
 
 nsresult
 nsNSSComponent::DefineNextTimer()
 {
   PRTime nextFiring;
   PRTime now = PR_Now();
-  uint64_t diff;
   uint32_t interval;
   uint32_t primaryDelay = CRL_AUTOUPDATE_DEFAULT_DELAY;
   nsresult rv;
 
   if(!mTimer){
     mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
     if(NS_FAILED(rv))
       return rv;
@@ -1411,18 +1410,17 @@ nsNSSComponent::DefineNextTimer()
   //If there are no more crls to be updated any time in future
   if(NS_FAILED(rv)){
     // Return - no error - just implies nothing to schedule
     return NS_OK;
   }
      
   //Define the firing interval, from NOW
   if ( now < nextFiring) {
-    diff = nextFiring - now;
-    LL_L2UI(interval, diff);
+    interval = uint32_t(nextFiring - now);
     //Now, we are doing 32 operations - so, don't need LL_ functions...
     interval = interval/PR_USEC_PER_MSEC;
   }else {
     interval = primaryDelay;
   }
   
   mTimer->InitWithCallback(static_cast<nsITimerCallback*>(this), 
                            interval,
--- a/tools/trace-malloc/spacetrace.c
+++ b/tools/trace-malloc/spacetrace.c
@@ -106,27 +106,25 @@ showHelp(void)
 ** ticks2xsec
 **
 ** Convert platform specific ticks to second units
 ** Returns 0 on success.
 */
 uint32_t
 ticks2xsec(tmreader * aReader, uint32_t aTicks, uint32_t aResolution)
 {
-    uint32_t retval = 0;
     uint64_t bigone;
     uint64_t tmp64;
 
     LL_UI2L(bigone, aResolution);
     LL_UI2L(tmp64, aTicks);
     bigone *= tmp64;
     LL_UI2L(tmp64, aReader->ticksPerSec);
     bigone /= tmp64;
-    LL_L2UI(retval, bigone);
-    return retval;
+    return (uint32)bigone;
 }
 
 #define ticks2msec(reader, ticks) ticks2xsec((reader), (ticks), 1000)
 #define ticks2usec(reader, ticks) ticks2xsec((reader), (ticks), 1000000)
 
 /*
 ** initOptions
 **
--- a/tools/trace-malloc/tmfrags.c
+++ b/tools/trace-malloc/tmfrags.c
@@ -411,27 +411,25 @@ int initOptions(Options* outOptions, int
 }
 
 
 uint32_t ticks2xsec(tmreader* aReader, uint32_t aTicks, uint32_t aResolution)
 /*
 ** Convert platform specific ticks to second units
 */
 {
-    uint32_t retval = 0;
     uint64_t bigone;
     uint64_t tmp64;
 
     LL_UI2L(bigone, aResolution);
     LL_UI2L(tmp64, aTicks);
     bigone *= tmp64;
     LL_UI2L(tmp64, aReader->ticksPerSec);
     bigone /= tmp64;
-    LL_L2UI(retval, bigone);
-    return retval;
+    return uint32(bigone);
 }
 
 
 void cleanOptions(Options* inOptions)
 /*
 **  Clean up any open handles.
 */
 {
--- a/tools/trace-malloc/tmstats.c
+++ b/tools/trace-malloc/tmstats.c
@@ -527,28 +527,25 @@ unsigned actualByteSize(Options* inOptio
 
 
 uint32_t ticks2xsec(tmreader* aReader, uint32_t aTicks, uint32_t aResolution)
 /*
 ** Convert platform specific ticks to second units
 ** Returns 0 on success.
 */
 {
-    uint32_t retval = 0;
     uint64_t bigone;
     uint64_t tmp64;
 
     LL_UI2L(bigone, aResolution);
     LL_UI2L(tmp64, aTicks);
     bigone *= tmp64;
     LL_UI2L(tmp64, aReader->ticksPerSec);
     bigone /= tmp64;
-    LL_L2UI(retval, bigone);
-
-    return retval;
+    return (uint32_t)bigone;
 }
 #define ticks2msec(reader, ticks) ticks2xsec((reader), (ticks), 1000)
 
 
 void tmEventHandler(tmreader* inReader, tmevent* inEvent)
 /*
 **  Callback from the tmreader_eventloop.
 **  Keep it simple in here, this is where we'll spend the most time.
--- a/widget/xpwidgets/nsTransferable.cpp
+++ b/widget/xpwidgets/nsTransferable.cpp
@@ -175,19 +175,18 @@ DataStruct::ReadCache(nsISupports** aDat
   bool exists;
   if ( cacheFile && NS_SUCCEEDED(cacheFile->Exists(&exists)) && exists ) {
     // get the size of the file
     int64_t fileSize;
     int64_t max32(LL_INIT(0, 0xFFFFFFFF));
     cacheFile->GetFileSize(&fileSize);
     if (fileSize > max32)
       return NS_ERROR_OUT_OF_MEMORY;
-    uint32_t size;
-    LL_L2UI(size, fileSize);
 
+    uint32_t size = uint32_t(fileSize);
     // create new memory for the large clipboard data
     nsAutoArrayPtr<char> data(new char[size]);
     if ( !data )
       return NS_ERROR_OUT_OF_MEMORY;
       
     // now read it all in
     nsCOMPtr<nsIInputStream> inStr;
     NS_NewLocalFileInputStream( getter_AddRefs(inStr),