Fix forbidden string constant assignment draft
authorTom Ritter <tom@mozilla.com>
Tue, 22 Aug 2017 16:58:06 -0500
changeset 653103 8b360bc49fc88eb4f296879f845e551f8e3ae1ca
parent 653102 be8bba0e9d5737b96464cc3667568061bb8af264
child 653104 75dbdf4e89aca11f5dc90d577e223a89cbb270db
push id76238
push userbmo:tom@mozilla.com
push dateFri, 25 Aug 2017 15:17:03 +0000
milestone57.0a1
Fix forbidden string constant assignment ISO C++ forbids converting a string constant to 'wchar_t*' [-Werror=write-strings] Either change it to a nullptr (which has same intent) or pass through a static MozReview-Commit-ID: CSunOCyO9PN
uriloader/exthandler/win/nsMIMEInfoWin.cpp
xpcom/base/nsVersionComparator.cpp
xpcom/io/nsLocalFileWin.cpp
old mode 100644
new mode 100755
--- a/uriloader/exthandler/win/nsMIMEInfoWin.cpp
+++ b/uriloader/exthandler/win/nsMIMEInfoWin.cpp
@@ -414,17 +414,17 @@ bool nsMIMEInfoWin::GetDllLaunchInfo(nsI
     return false;
 
   nsAutoString appFilesystemCommand;
   if (NS_SUCCEEDED(appKey->ReadStringValue(EmptyString(),
                                            appFilesystemCommand))) {
     // Replace embedded environment variables.
     uint32_t bufLength = 
       ::ExpandEnvironmentStringsW(appFilesystemCommand.get(),
-                                  L"", 0);
+                                  nullptr, 0);
     if (bufLength == 0) // Error
       return false;
 
     auto destination = mozilla::MakeUniqueFallible<wchar_t[]>(bufLength);
     if (!destination)
       return false;
     if (!::ExpandEnvironmentStringsW(appFilesystemCommand.get(),
                                      destination.get(),
old mode 100644
new mode 100755
--- a/xpcom/base/nsVersionComparator.cpp
+++ b/xpcom/base/nsVersionComparator.cpp
@@ -133,18 +133,20 @@ ParseVP(wchar_t* aPart, VersionPartW& aR
   }
 
   dot = wcschr(aPart, '.');
   if (dot) {
     *dot = '\0';
   }
 
   if (aPart[0] == '*' && aPart[1] == '\0') {
+    static wchar_t kEmpty[] = L"";
+
     aResult.numA = INT32_MAX;
-    aResult.strB = L"";
+    aResult.strB = kEmpty;
   } else {
     aResult.numA = wcstol(aPart, const_cast<wchar_t**>(&aResult.strB), 10);
   }
 
   if (!*aResult.strB) {
     aResult.strB = nullptr;
     aResult.strBlen = 0;
   } else {
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -1265,17 +1265,17 @@ nsLocalFile::CleanupCmdHandlerPath(nsASt
   // rundll32.exe "%ProgramFiles%\Win...ery\PhotoViewer.dll", var var
   // rundll32.exe "%ProgramFiles%\Windows Photo Gallery\PhotoViewer.dll"
   // C:\Windows\System32\rundll32.exe "path to dll", var var
   // %SystemRoot%\System32\rundll32.exe "%ProgramFiles%\Win...ery\Photo
   //    Viewer.dll", var var
 
   // Expand environment variables so we have full path strings.
   uint32_t bufLength = ::ExpandEnvironmentStringsW(handlerCommand.get(),
-                                                   L"", 0);
+                                                   nullptr, 0);
   if (bufLength == 0) // Error
     return false;
 
   auto destination = mozilla::MakeUniqueFallible<wchar_t[]>(bufLength);
   if (!destination)
     return false;
   if (!::ExpandEnvironmentStringsW(handlerCommand.get(), destination.get(),
                                    bufLength))