Bug 1474878 - fix compile errors found by clang-cl in Windows-only code. r=aceman
authorJorg K <jorgk@jorgk.com>
Thu, 12 Jul 2018 00:38:57 +0200
changeset 32572 e7988ebfa0a8d940376638406cc9c390b51a29ae
parent 32571 49a49e3bd9e5578c6744dacf372eb902746df6e6
child 32573 8fc3d2e640f55942926e39a7a27e678d258084f5
push id386
push userclokep@gmail.com
push dateTue, 23 Oct 2018 00:48:12 +0000
reviewersaceman
bugs1474878
Bug 1474878 - fix compile errors found by clang-cl in Windows-only code. r=aceman
mailnews/addrbook/src/nsAbOutlookDirectory.cpp
mailnews/base/src/nsMessengerWinIntegration.cpp
mailnews/import/outlook/src/rtfDecoder.cpp
mailnews/import/winlivemail/nsWMSettings.cpp
--- a/mailnews/addrbook/src/nsAbOutlookDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbOutlookDirectory.cpp
@@ -55,17 +55,17 @@ NS_IMETHODIMP nsAbOutlookDirectory::Init
   nsresult rv = nsAbDirProperty::Init(aUri);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString entry;
   nsAutoCString stub;
 
   mAbWinType = getAbWinType(kOutlookDirectoryScheme, mURINoQuery.get(), stub, entry);
   if (mAbWinType == nsAbWinType_Unknown) {
-    PRINTF(("Huge problem URI=%s.\n", mURINoQuery));
+    PRINTF(("Huge problem URI=%s.\n", mURINoQuery.get()));
     return NS_ERROR_INVALID_ARG;
   }
   nsAbWinHelperGuard mapiAddBook (mAbWinType);
   nsString prefix;
   nsAutoString unichars;
   ULONG objectType = 0;
 
   if (!mapiAddBook->IsOK())
--- a/mailnews/base/src/nsMessengerWinIntegration.cpp
+++ b/mailnews/base/src/nsMessengerWinIntegration.cpp
@@ -281,17 +281,17 @@ nsMessengerWinIntegration::ResetCurrent(
 
   mCurrentUnreadCount = -1;
   mLastUnreadCountWrittenToRegistry = -1;
 
   mDefaultAccountMightHaveAnInbox = true;
   return NS_OK;
 }
 
-NOTIFYICONDATAW sBiffIconData = { NOTIFYICONDATAW_V2_SIZE,
+NOTIFYICONDATAW sBiffIconData = { (DWORD)NOTIFYICONDATAW_V2_SIZE,
                                   0,
                                   2,
                                   NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_INFO,
                                   WM_USER,
                                   0,
                                   L"",
                                   0,
                                   0,
--- a/mailnews/import/outlook/src/rtfDecoder.cpp
+++ b/mailnews/import/outlook/src/rtfDecoder.cpp
@@ -141,31 +141,31 @@ struct Keyword {
   int val;
 };
 
 class Lexem {
 public:
   enum Type {ltGroupBegin, ltGroupEnd, ltKeyword, ltPCDATA_A, ltPCDATA_W,
              ltBDATA, ltEOF, ltError};
   Lexem(Type t=ltError) : m_type(t) {}
-  Lexem(Lexem& from) // Move pointers when copying
+  Lexem(Lexem& from)
   {
     switch (m_type = from.m_type) {
     case ltKeyword:
       m_keyword = from.m_keyword;
       break;
     case ltPCDATA_A:
       m_pcdata_a = from.m_pcdata_a;
       break;
     case ltPCDATA_W:
       m_pcdata_w = from.m_pcdata_w;
       break;
     case ltBDATA:
-      m_bdata = from.m_bdata;
-      from.m_type = ltError;
+      m_bdata = from.m_bdata;  // Move pointers when copying.
+      from.m_type = ltError;   // Invalidate the original. Not nice.
       break;
     }
   }
   ~Lexem() { Clear(); }
   Lexem& operator = (Lexem& from)
   {
     if (&from != this) {
       Clear();
@@ -175,18 +175,18 @@ public:
         break;
       case ltPCDATA_A:
         m_pcdata_a = from.m_pcdata_a;
         break;
       case ltPCDATA_W:
         m_pcdata_w = from.m_pcdata_w;
         break;
       case ltBDATA:
-        m_bdata = from.m_bdata;
-        from.m_type = ltError;
+        m_bdata = from.m_bdata;  // Move pointers when copying.
+        from.m_type = ltError;   // Invalidate the original. Not nice.
         break;
       }
     }
     return *this;
   }
   Type type() const { return m_type; }
   void SetPCDATA_A(char chdata)
   {
@@ -309,19 +309,18 @@ Keyword GetKeyword(std::istream& stream)
       stream.unget();
   }
   else { // Control symbol
     keyword.name[0] = ch, keyword.name[1] = 0;
   }
   return keyword;
 }
 
-Lexem GetLexem(std::istream& stream)
+void GetLexem(std::istream& stream, Lexem& result)
 {
-  Lexem result;
   // We always stay at the beginning of the next lexem or a crlf
   // If it's a brace then it's group begin/end
   // If it's a backslash -> Preprocess
   // - if it's a \u or \' -> make UTF16 character
   // - else it's a keyword -> Process (e.g., remember the codepage)
   // - (if the keyword is \bin then the following is #BDATA)
   // If it's some other character -> Preprocess
   // - if it's 0x09 -> it's the keyword \tab
@@ -342,17 +341,16 @@ Lexem GetLexem(std::istream& stream)
     case '\t': // tab
       result.SetKeyword("tab");
       break;
     default: // PSDATA?
       result.SetPCDATA_A(ch);
       break;
     }
   }
-  return result;
 }
 
 void PreprocessLexem(/*inout*/Lexem& lexem, std::istream& stream, int uc)
 {
   if (lexem.type() == Lexem::ltKeyword) {
     if (lexem.KeywordName()[0] == 0) // Empty keyword - maybe eof?
       lexem = Lexem::error;
     else if (eq(lexem.KeywordName(), "u")) {
@@ -459,31 +457,32 @@ void UpdateState(const Lexem& lexem, /*i
     globalState.pcdata_a << lexem.pcdata_a();
     break;
   }
 }
 
 void DecodeRTF(std::istream& rtf, CRTFDecoder& decoder)
 {
   // Check if this is the rtf
-  Lexem lexem = GetLexem(rtf);
+  Lexem lexem;
+  GetLexem(rtf, lexem);
   if (lexem.type() != Lexem::ltGroupBegin)
     return;
   decoder.BeginGroup();
-  lexem = GetLexem(rtf);
+  GetLexem(rtf, lexem);
   if ((lexem.type() != Lexem::ltKeyword) || !eq(lexem.KeywordName(), "rtf") ||
       !lexem.KeywordVal() || (*lexem.KeywordVal() != 1))
     return;
   decoder.Keyword(lexem.KeywordName(), lexem.KeywordVal());
 
   GlobalState state(rtf);
   // Level is the count of elements in the stack
 
   while (!state.stream.eof() && (state.stack.size()>0)) { // Don't go past the global group
-    lexem = GetLexem(state.stream);
+    GetLexem(state.stream, lexem);
     PreprocessLexem(lexem, state.stream, state.stack.top().uc);
     UpdateState(lexem, state);
 
     if (state.pcdata_a_state == GlobalState::pcdsfinished) {
       std::string s = state.pcdata_a.str();
       int sz = ::MultiByteToWideChar(state.pcdata_a_codepage, 0, s.c_str(), s.size(), 0, 0);
       if (sz) {
         wchar_t* data = new wchar_t[sz];
--- a/mailnews/import/winlivemail/nsWMSettings.cpp
+++ b/mailnews/import/winlivemail/nsWMSettings.cpp
@@ -689,17 +689,17 @@ void WMSettings::SetSmtpServer(nsIDocume
     rv = smtpService->FindServer(userName.get(),
                                  NS_ConvertUTF16toUTF8(smtpName).get(),
                                  getter_AddRefs(extgServer));
     if (NS_SUCCEEDED(rv) && extgServer) {
       // set our account keyed to this smptserver key
       extgServer->GetKey(getter_Copies(smtpServerKey));
       id->SetSmtpServerKey(smtpServerKey);
 
-      IMPORT_LOG1("SMTP server already exists: %S\n", smtpName);
+      IMPORT_LOG1("SMTP server already exists: %s\n", NS_ConvertUTF16toUTF8(smtpName).get());
     }
     else {
       nsCOMPtr<nsISmtpServer> smtpServer;
       rv = smtpService->CreateServer(getter_AddRefs(smtpServer));
       if (NS_SUCCEEDED(rv) && smtpServer) {
         if (NS_SUCCEEDED(nsWMUtils::GetValueForTag(xmlDoc,
                                                    "SMTP_Port",
                                                    value))) {
@@ -729,13 +729,13 @@ void WMSettings::SetSmtpServer(nsIDocume
             smtpServer->SetAuthMethod(nsMsgAuthMethod::none);
         }
 
         smtpServer->SetHostname(NS_ConvertUTF16toUTF8(smtpName));
 
         smtpServer->GetKey(getter_Copies(smtpServerKey));
         id->SetSmtpServerKey(smtpServerKey);
 
-        IMPORT_LOG1("Created new SMTP server: %S\n", smtpName);
+        IMPORT_LOG1("Created new SMTP server: %s\n", NS_ConvertUTF16toUTF8(smtpName).get());
       }
     }
   }
 }