Bug 1394013 Fix forbidden string constant assignment r?froydnj draft
authorTom Ritter <tom@mozilla.com>
Tue, 22 Aug 2017 16:58:06 -0500
changeset 653362 2a3e6c3f6a086410c64238057a398d183117c695
parent 653361 bf499ca757a9398e5837d5555216efc0eabd10ba
child 728322 77cabc03097ede1cfe4197cfbea70d06033e41da
push id76309
push userbmo:tom@mozilla.com
push dateFri, 25 Aug 2017 21:40:58 +0000
reviewersfroydnj
bugs1394013
milestone57.0a1
Bug 1394013 Fix forbidden string constant assignment r?froydnj 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))