Bug 883729 - Fix -Wnull-conversion warnings in xpcom. r=bsmedberg
☠☠ backed out by 3dca4337889f ☠ ☠
authorChris Peterson <cpeterson@mozilla.com>
Thu, 13 Jun 2013 20:57:47 -0700
changeset 146814 1b201503737b0c97302cd8a04cd1022c8012945e
parent 146813 bc4c43776396b5c0ffba90e6e9102e07f2d02a16
child 146815 3dca4337889fc66f4d48af8092e4e1c61b425823
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs883729
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 883729 - Fix -Wnull-conversion warnings in xpcom. r=bsmedberg
xpcom/build/FileLocation.cpp
xpcom/components/nsComponentManager.cpp
xpcom/glue/nsInterfaceHashtable.h
--- a/xpcom/build/FileLocation.cpp
+++ b/xpcom/build/FileLocation.cpp
@@ -68,17 +68,17 @@ FileLocation::GetURIString(nsACString &r
 
 already_AddRefed<nsIFile>
 FileLocation::GetBaseFile()
 {
   if (IsZip() && mBaseZip) {
     nsRefPtr<nsZipHandle> handler = mBaseZip->GetFD();
     if (handler)
       return handler->mFile.GetBaseFile();
-    return NULL;
+    return nullptr;
   }
 
   nsCOMPtr<nsIFile> file = mBaseFile;
   return file.forget();
 }
 
 bool
 FileLocation::Equals(const FileLocation &file) const
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -242,35 +242,35 @@ static already_AddRefed<nsIFile>
 GetLocationFromDirectoryService(const char* prop)
 {
     nsCOMPtr<nsIProperties> directoryService;
     nsDirectoryService::Create(nullptr,
                                NS_GET_IID(nsIProperties),
                                getter_AddRefs(directoryService));
 
     if (!directoryService)
-        return NULL;
+        return nullptr;
 
     nsCOMPtr<nsIFile> file;
     nsresult rv = directoryService->Get(prop,
                                         NS_GET_IID(nsIFile),
                                         getter_AddRefs(file));
     if (NS_FAILED(rv))
-        return NULL;
+        return nullptr;
 
     return file.forget();
 }
 
 static already_AddRefed<nsIFile>
 CloneAndAppend(nsIFile* aBase, const nsACString& append)
 {
     nsCOMPtr<nsIFile> f;
     aBase->Clone(getter_AddRefs(f));
     if (!f)
-        return NULL;
+        return nullptr;
 
     f->AppendNative(append);
     return f.forget();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsComponentManagerImpl
 ////////////////////////////////////////////////////////////////////////////////
@@ -381,20 +381,20 @@ nsresult nsComponentManagerImpl::Init()
            ("nsComponentManager: Initialized."));
 
     nsresult rv = mNativeModuleLoader.Init();
     if (NS_FAILED(rv))
         return rv;
 
     nsCategoryManager::GetSingleton()->SuppressNotifications(true);
 
-    RegisterModule(&kXPCOMModule, NULL);
+    RegisterModule(&kXPCOMModule, nullptr);
 
     for (uint32_t i = 0; i < sStaticModules->Length(); ++i)
-        RegisterModule((*sStaticModules)[i], NULL);
+        RegisterModule((*sStaticModules)[i], nullptr);
 
     nsRefPtr<nsZipArchive> appOmnijar = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
     if (appOmnijar) {
         cl = sModuleLocations->InsertElementAt(1); // Insert after greDir
         cl->type = NS_COMPONENT_LOCATION;
         cl->location.Init(appOmnijar, "chrome.manifest");
     }
     nsRefPtr<nsZipArchive> greOmnijar = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE);
@@ -863,28 +863,28 @@ nsComponentManagerImpl::GetFactoryEntry(
     return mFactories.Get(aClass);
 }
 
 already_AddRefed<nsIFactory>
 nsComponentManagerImpl::FindFactory(const nsCID& aClass)
 {
     nsFactoryEntry* e = GetFactoryEntry(aClass);
     if (!e)
-        return NULL;
+        return nullptr;
 
     return e->GetFactory();
 }
 
 already_AddRefed<nsIFactory>
 nsComponentManagerImpl::FindFactory(const char *contractID,
                                     uint32_t aContractIDLen)
 {
     nsFactoryEntry *entry = GetFactoryEntry(contractID, aContractIDLen);
     if (!entry)
-        return NULL;
+        return nullptr;
 
     return entry->GetFactory();
 }
 
 /**
  * GetClassObject()
  *
  * Given a classID, this finds the singleton ClassObject that implements the CID.
@@ -1108,30 +1108,30 @@ nsComponentManagerImpl::CreateInstanceBy
     return rv;
 }
 
 static PLDHashOperator
 FreeFactoryEntries(const nsID& aCID,
                    nsFactoryEntry* aEntry,
                    void* arg)
 {
-    aEntry->mFactory = NULL;
-    aEntry->mServiceObject = NULL;
+    aEntry->mFactory = nullptr;
+    aEntry->mServiceObject = nullptr;
     return PL_DHASH_NEXT;
 }
 
 nsresult
 nsComponentManagerImpl::FreeServices()
 {
     NS_ASSERTION(gXPCOMShuttingDown, "Must be shutting down in order to free all services");
 
     if (!gXPCOMShuttingDown)
         return NS_ERROR_FAILURE;
 
-    mFactories.EnumerateRead(FreeFactoryEntries, NULL);
+    mFactories.EnumerateRead(FreeFactoryEntries, nullptr);
     return NS_OK;
 }
 
 // This should only ever be called within the monitor!
 nsComponentManagerImpl::PendingServiceInfo*
 nsComponentManagerImpl::AddPendingService(const nsCID& aServiceCID,
                                           PRThread* aThread)
 {
@@ -1479,17 +1479,17 @@ nsComponentManagerImpl::GetServiceByCont
 already_AddRefed<mozilla::ModuleLoader>
 nsComponentManagerImpl::LoaderForExtension(const nsACString& aExt)
 {
     nsCOMPtr<mozilla::ModuleLoader> loader = mLoaderMap.Get(aExt);
     if (!loader) {
         loader = do_GetServiceFromCategory("module-loader",
                                            PromiseFlatCString(aExt).get());
         if (!loader)
-            return NULL;
+            return nullptr;
 
         mLoaderMap.Put(aExt, loader);
     }
 
     return loader.forget();
 }
 
 NS_IMETHODIMP
@@ -1668,17 +1668,17 @@ nsComponentManagerImpl::ContractIDToCID(
         SafeMutexAutoLock lock(mLock);
         nsFactoryEntry* entry = mContractIDs.Get(nsDependentCString(aContractID));
         if (entry) {
             *_retval = (nsCID*) NS_Alloc(sizeof(nsCID));
             **_retval = *entry->mCIDEntry->cid;
             return NS_OK;
         }
     }
-    *_retval = NULL;
+    *_retval = nullptr;
     return NS_ERROR_FACTORY_NOT_REGISTERED;
 }
 
 static size_t
 SizeOfFactoriesEntryExcludingThis(nsIDHashKey::KeyType aKey,
                                   nsFactoryEntry* const &aData,
                                   nsMallocSizeOfFun aMallocSizeOf,
                                   void* aUserArg)
@@ -1735,26 +1735,26 @@ nsComponentManagerImpl::SizeOfIncludingT
 nsFactoryEntry::nsFactoryEntry(const mozilla::Module::CIDEntry* entry,
                                nsComponentManagerImpl::KnownModule* module)
     : mCIDEntry(entry)
     , mModule(module)
 {
 }
 
 nsFactoryEntry::nsFactoryEntry(const nsCID& aCID, nsIFactory* factory)
-    : mCIDEntry(NULL)
-    , mModule(NULL)
+    : mCIDEntry(nullptr)
+    , mModule(nullptr)
     , mFactory(factory)
 {
     mozilla::Module::CIDEntry* e = new mozilla::Module::CIDEntry();
     nsCID* cid = new nsCID;
     *cid = aCID;
     e->cid = cid;
     mCIDEntry = e;
-}        
+}
 
 nsFactoryEntry::~nsFactoryEntry()
 {
     // If this was a RegisterFactory entry, we own the CIDEntry/CID
     if (!mModule) {
         delete mCIDEntry->cid;
         delete mCIDEntry;
     }
@@ -1764,37 +1764,37 @@ already_AddRefed<nsIFactory>
 nsFactoryEntry::GetFactory()
 {
     nsComponentManagerImpl::gComponentManager->mLock.AssertNotCurrentThreadOwns();
 
     if (!mFactory) {
         // RegisterFactory then UnregisterFactory can leave an entry in mContractIDs
         // pointing to an unusable nsFactoryEntry.
         if (!mModule)
-            return NULL;
+            return nullptr;
 
         if (!mModule->Load())
-            return NULL;
+            return nullptr;
 
         // Don't set mFactory directly, it needs to be locked
         nsCOMPtr<nsIFactory> factory;
 
         if (mModule->Module()->getFactoryProc) {
             factory = mModule->Module()->getFactoryProc(*mModule->Module(),
                                                         *mCIDEntry);
         }
         else if (mCIDEntry->getFactoryProc) {
             factory = mCIDEntry->getFactoryProc(*mModule->Module(), *mCIDEntry);
         }
         else {
             NS_ASSERTION(mCIDEntry->constructorProc, "no getfactory or constructor");
             factory = new mozilla::GenericFactory(mCIDEntry->constructorProc);
         }
         if (!factory)
-            return NULL;
+            return nullptr;
 
         SafeMutexAutoLock lock(nsComponentManagerImpl::gComponentManager->mLock);
         // Threads can race to set mFactory
         if (!mFactory) {
             factory.swap(mFactory);
         }
     }
     nsCOMPtr<nsIFactory> factory = mFactory;
@@ -1854,17 +1854,17 @@ NS_GetComponentRegistrar(nsIComponentReg
 EXPORT_XPCOM_API(nsresult)
 XRE_AddStaticComponent(const mozilla::Module* aComponent)
 {
     nsComponentManagerImpl::InitializeStaticModules();
     nsComponentManagerImpl::sStaticModules->AppendElement(aComponent);
 
     if (nsComponentManagerImpl::gComponentManager &&
         nsComponentManagerImpl::NORMAL == nsComponentManagerImpl::gComponentManager->mStatus)
-        nsComponentManagerImpl::gComponentManager->RegisterModule(aComponent, NULL);
+        nsComponentManagerImpl::gComponentManager->RegisterModule(aComponent, nullptr);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsComponentManagerImpl::AddBootstrappedManifestLocation(nsIFile* aLocation)
 {
   nsString path;
--- a/xpcom/glue/nsInterfaceHashtable.h
+++ b/xpcom/glue/nsInterfaceHashtable.h
@@ -130,17 +130,17 @@ nsInterfaceHashtable<KeyClass,Interface>
 }
 
 template<class KeyClass, class Interface>
 already_AddRefed<Interface>
 nsInterfaceHashtable<KeyClass,Interface>::Get(KeyType aKey) const
 {
   typename base_type::EntryType* ent = this->GetEntry(aKey);
   if (!ent)
-    return NULL;
+    return nullptr;
 
   nsCOMPtr<Interface> copy = ent->mData;
   return copy.forget();
 }
 
 template<class KeyClass,class Interface>
 Interface*
 nsInterfaceHashtable<KeyClass,Interface>::GetWeak