Kaydet (Commit) 34604446 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Various clang-cl/loplugin warnings

Change-Id: Ib18e04e5024d15f8bbbf4921932b07465fb1f32f
üst b30173fd
...@@ -7,10 +7,17 @@ ...@@ -7,10 +7,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#ifndef _COMOPENDOCUMENTS_HPP_ #ifndef INCLUDED_SHELL_INC_SPSUPP_COMOPENDOCUMENTS_HPP
#define _COMOPENDOCUMENTS_HPP_ #define INCLUDED_SHELL_INC_SPSUPP_COMOPENDOCUMENTS_HPP
#if defined __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
#endif
#include "spsupp_h.h" #include "spsupp_h.h"
#if defined __clang__
#pragma clang diagnostic pop
#endif
#include "COMRefCounted.hpp" #include "COMRefCounted.hpp"
#include "Objsafe.h" #include "Objsafe.h"
#include "assert.h" #include "assert.h"
...@@ -28,7 +35,7 @@ public: ...@@ -28,7 +35,7 @@ public:
}; };
COMOpenDocuments(); COMOpenDocuments();
virtual ~COMOpenDocuments(); virtual ~COMOpenDocuments() override;
// IUnknown methods // IUnknown methods
...@@ -210,6 +217,6 @@ private: ...@@ -210,6 +217,6 @@ private:
COMObjectSafety m_aObjectSafety; COMObjectSafety m_aObjectSafety;
}; };
#endif // _COMOPENDOCUMENTS_HPP_ #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#ifndef _COMREFCOUNTED_HPP_ #ifndef INCLUDED_SHELL_INC_SPSUPP_COMREFCOUNTED_HPP
#define _COMREFCOUNTED_HPP_ #define INCLUDED_SHELL_INC_SPSUPP_COMREFCOUNTED_HPP
#include "objbase.h" #include "objbase.h"
...@@ -37,6 +37,6 @@ private: ...@@ -37,6 +37,6 @@ private:
long m_nRef = 1; // Created referenced long m_nRef = 1; // Created referenced
}; };
#endif // _COMREFCOUNTED_HPP_ #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#ifndef _REGISTRAR_H #ifndef INCLUDED_SHELL_INC_SPSUPP_REGISTRAR_H
#define _REGISTRAR_H #define INCLUDED_SHELL_INC_SPSUPP_REGISTRAR_H
#include "windows.h" #include "windows.h"
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#ifndef _SPSUPPCLASSFACTORY_H_ #ifndef INCLUDED_SHELL_INC_SPSUPP_SPSUPPCLASSFACTORY_HPP
#define _SPSUPPCLASSFACTORY_H_ #define INCLUDED_SHELL_INC_SPSUPP_SPSUPPCLASSFACTORY_HPP
#include "COMRefCounted.hpp" #include "COMRefCounted.hpp"
...@@ -16,7 +16,7 @@ class ClassFactory : public COMRefCounted<IClassFactory> ...@@ -16,7 +16,7 @@ class ClassFactory : public COMRefCounted<IClassFactory>
{ {
public: public:
ClassFactory(); ClassFactory();
virtual ~ClassFactory(); virtual ~ClassFactory() override;
// IUnknown methods // IUnknown methods
...@@ -44,6 +44,6 @@ private: ...@@ -44,6 +44,6 @@ private:
static long m_nLockCount; static long m_nLockCount;
}; };
#endif // _SPSUPPCLASSFACTORY_H_ #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#ifndef _SPSUPPSERV_HPP_ #ifndef INCLUDED_SHELL_INC_SPSUPP_SPSUPPSERV_HPP
#define _SPSUPPSERV_HPP_ #define INCLUDED_SHELL_INC_SPSUPP_SPSUPPSERV_HPP
#include <objbase.h> #include <objbase.h>
ITypeLib* GetTypeLib(); ITypeLib* GetTypeLib();
const wchar_t* GetLOPath(); const wchar_t* GetLOPath();
#endif // _SPSUPPSERV_HPP_ #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -88,7 +88,7 @@ ITag* CContentReader::chooseTagReader( const std::wstring& tag_name, const XmlTa ...@@ -88,7 +88,7 @@ ITag* CContentReader::chooseTagReader( const std::wstring& tag_name, const XmlTa
if ( XmlAttributes.find(CONTENT_STYLE_STYLE_NAME) != XmlAttributes.end()) if ( XmlAttributes.find(CONTENT_STYLE_STYLE_NAME) != XmlAttributes.end())
return new CAutoStyleTag(XmlAttributes); return new CAutoStyleTag(XmlAttributes);
else else
return new CDummyTag(); return new CDummyTag;
} }
else if ( ( tag_name == CONTENT_STYLE_PROPERTIES ) || ( tag_name == CONTENT_TEXT_STYLE_PROPERTIES ) ) else if ( ( tag_name == CONTENT_STYLE_PROPERTIES ) || ( tag_name == CONTENT_TEXT_STYLE_PROPERTIES ) )
{ {
...@@ -98,10 +98,10 @@ ITag* CContentReader::chooseTagReader( const std::wstring& tag_name, const XmlTa ...@@ -98,10 +98,10 @@ ITag* CContentReader::chooseTagReader( const std::wstring& tag_name, const XmlTa
ITag* pTagBuilder = m_TagBuilderStack.top(); ITag* pTagBuilder = m_TagBuilderStack.top();
pTagBuilder->addAttributes( XmlAttributes ); pTagBuilder->addAttributes( XmlAttributes );
return new CDummyTag(); return new CDummyTag;
} }
else else
return new CDummyTag(); return new CDummyTag;
} }
/** get style of the current content. /** get style of the current content.
......
...@@ -31,9 +31,9 @@ CBaseReader( DocumentName ) ...@@ -31,9 +31,9 @@ CBaseReader( DocumentName )
{ {
try try
{ {
m_pKeywords_Builder = new CKeywordsTag( ); m_pKeywords_Builder = new CKeywordsTag;
m_pSimple_Builder = new CSimpleTag( ); m_pSimple_Builder = new CSimpleTag( );
m_pDummy_Builder = new CDummyTag( ); m_pDummy_Builder = new CDummyTag;
//retrieve all information that is useful //retrieve all information that is useful
m_AllMetaInfo[META_INFO_AUTHOR] = EMPTY_XML_TAG; m_AllMetaInfo[META_INFO_AUTHOR] = EMPTY_XML_TAG;
...@@ -68,9 +68,9 @@ CBaseReader( stream ) ...@@ -68,9 +68,9 @@ CBaseReader( stream )
{ {
try try
{ {
m_pKeywords_Builder = new CKeywordsTag( ); m_pKeywords_Builder = new CKeywordsTag;
m_pSimple_Builder = new CSimpleTag( ); m_pSimple_Builder = new CSimpleTag( );
m_pDummy_Builder = new CDummyTag( ); m_pDummy_Builder = new CDummyTag;
//retrieve all information that is useful //retrieve all information that is useful
m_AllMetaInfo[META_INFO_AUTHOR] = EMPTY_XML_TAG; m_AllMetaInfo[META_INFO_AUTHOR] = EMPTY_XML_TAG;
......
...@@ -61,7 +61,7 @@ Reference<XSimpleMailClient> SAL_CALL CSmplMailSuppl::querySimpleMailClient() ...@@ -61,7 +61,7 @@ Reference<XSimpleMailClient> SAL_CALL CSmplMailSuppl::querySimpleMailClient()
if ((handle != INVALID_HANDLE_VALUE) && (handle != nullptr)) if ((handle != INVALID_HANDLE_VALUE) && (handle != nullptr))
{ {
FreeLibrary(handle); FreeLibrary(handle);
xSmplMailClient.set(new CSmplMailClient()); xSmplMailClient.set(new CSmplMailClient);
} }
return xSmplMailClient; return xSmplMailClient;
} }
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#include <sal/config.h>
#include <cstring>
#include "COMOpenDocuments.hpp" #include "COMOpenDocuments.hpp"
#include "spsuppServ.hpp" #include "spsuppServ.hpp"
#include "stdio.h" #include "stdio.h"
...@@ -27,7 +31,9 @@ bool SecurityWarning(const wchar_t* sProgram, const wchar_t* sDocument) ...@@ -27,7 +31,9 @@ bool SecurityWarning(const wchar_t* sProgram, const wchar_t* sDocument)
// Returns S_OK if successful // Returns S_OK if successful
HRESULT LOStart(wchar_t* sCommandLine) HRESULT LOStart(wchar_t* sCommandLine)
{ {
STARTUPINFOW si = { sizeof(si) }; STARTUPINFOW si;
std::memset(&si, 0, sizeof si);
si.cb = sizeof si;
si.dwFlags = STARTF_USESHOWWINDOW; si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW; si.wShowWindow = SW_SHOW;
PROCESS_INFORMATION pi = {}; PROCESS_INFORMATION pi = {};
...@@ -42,7 +48,7 @@ HRESULT LOStart(wchar_t* sCommandLine) ...@@ -42,7 +48,7 @@ HRESULT LOStart(wchar_t* sCommandLine)
nullptr, nullptr,
dwError, dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&sMsgBuf, reinterpret_cast<LPWSTR>(&sMsgBuf),
0, nullptr); 0, nullptr);
size_t nBufSize = wcslen(sMsgBuf) + 100; size_t nBufSize = wcslen(sMsgBuf) + 100;
...@@ -97,7 +103,7 @@ HRESULT STDMETHODCALLTYPE COMOpenDocuments::COMObjectSafety::GetInterfaceSafetyO ...@@ -97,7 +103,7 @@ HRESULT STDMETHODCALLTYPE COMOpenDocuments::COMObjectSafety::GetInterfaceSafetyO
} }
// We know about it; release reference and return required information // We know about it; release reference and return required information
reinterpret_cast<IUnknown*>(ppvo)->Release(); static_cast<IUnknown*>(ppvo)->Release();
*pdwSupportedOptions = iSupportedOptionsMask; *pdwSupportedOptions = iSupportedOptionsMask;
*pdwEnabledOptions = m_iEnabledOptions; *pdwEnabledOptions = m_iEnabledOptions;
return S_OK; return S_OK;
...@@ -173,7 +179,7 @@ STDMETHODIMP COMOpenDocuments::QueryInterface(REFIID riid, void **ppvObject) ...@@ -173,7 +179,7 @@ STDMETHODIMP COMOpenDocuments::QueryInterface(REFIID riid, void **ppvObject)
return E_NOINTERFACE; return E_NOINTERFACE;
} }
reinterpret_cast<IUnknown*>(*ppvObject)->AddRef(); static_cast<IUnknown*>(*ppvObject)->AddRef();
return S_OK; return S_OK;
} }
...@@ -306,7 +312,7 @@ STDMETHODIMP COMOpenDocuments::CreateNewDocument2( ...@@ -306,7 +312,7 @@ STDMETHODIMP COMOpenDocuments::CreateNewDocument2(
wchar_t sCommandLine[32768]; wchar_t sCommandLine[32768];
swprintf(sCommandLine, sizeof(sCommandLine) / sizeof(*sCommandLine), L"\"%s\" -n \"%s\"", sProgram, bstrTemplateLocation); swprintf(sCommandLine, sizeof(sCommandLine) / sizeof(*sCommandLine), L"\"%s\" -n \"%s\"", sProgram, bstrTemplateLocation);
HRESULT hr = LOStart(sCommandLine); HRESULT hr = LOStart(sCommandLine);
*pbResult = SUCCEEDED(hr); *pbResult = VARIANT_BOOL(SUCCEEDED(hr));
return hr; return hr;
} }
...@@ -356,7 +362,7 @@ STDMETHODIMP COMOpenDocuments::ViewDocument3( ...@@ -356,7 +362,7 @@ STDMETHODIMP COMOpenDocuments::ViewDocument3(
wchar_t sCommandLine[32768]; wchar_t sCommandLine[32768];
swprintf(sCommandLine, sizeof(sCommandLine) / sizeof(*sCommandLine), L"\"%s\" --view \"%s\"", sProgram, bstrDocumentLocation); swprintf(sCommandLine, sizeof(sCommandLine) / sizeof(*sCommandLine), L"\"%s\" --view \"%s\"", sProgram, bstrDocumentLocation);
HRESULT hr = LOStart(sCommandLine); HRESULT hr = LOStart(sCommandLine);
*pbResult = SUCCEEDED(hr); *pbResult = VARIANT_BOOL(SUCCEEDED(hr));
return hr; return hr;
} }
...@@ -430,7 +436,7 @@ STDMETHODIMP COMOpenDocuments::EditDocument3( ...@@ -430,7 +436,7 @@ STDMETHODIMP COMOpenDocuments::EditDocument3(
wchar_t sCommandLine[32768]; wchar_t sCommandLine[32768];
swprintf(sCommandLine, sizeof(sCommandLine) / sizeof(*sCommandLine), L"\"%s\" -o \"%s\"", sProgram, bstrDocumentLocation); swprintf(sCommandLine, sizeof(sCommandLine) / sizeof(*sCommandLine), L"\"%s\" -o \"%s\"", sProgram, bstrDocumentLocation);
HRESULT hr = LOStart(sCommandLine); HRESULT hr = LOStart(sCommandLine);
*pbResult = SUCCEEDED(hr); *pbResult = VARIANT_BOOL(SUCCEEDED(hr));
return hr; return hr;
} }
......
...@@ -25,8 +25,6 @@ ClassFactory::~ClassFactory() ...@@ -25,8 +25,6 @@ ClassFactory::~ClassFactory()
// IUnknown methods // IUnknown methods
const wchar_t* GUID2Str(REFGUID rGUID);
STDMETHODIMP ClassFactory::QueryInterface( STDMETHODIMP ClassFactory::QueryInterface(
REFIID riid, REFIID riid,
void **ppvObject) void **ppvObject)
......
...@@ -8,7 +8,15 @@ ...@@ -8,7 +8,15 @@
*/ */
// Include MIDL-generated file // Include MIDL-generated file
#if defined __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wextra-tokens"
// "#endif !_MIDL_USE_GUIDDEF_" in midl-generated code
#endif
#include "spsupp_i.c" #include "spsupp_i.c"
#if defined __clang__
#pragma clang diagnostic pop
#endif
#include <memory> #include <memory>
#include "olectl.h" #include "olectl.h"
...@@ -17,8 +25,12 @@ ...@@ -17,8 +25,12 @@
#include "COMOpenDocuments.hpp" #include "COMOpenDocuments.hpp"
#include "registrar.hpp" #include "registrar.hpp"
namespace {
HANDLE g_hModule; HANDLE g_hModule;
}
ITypeLib* GetTypeLib() ITypeLib* GetTypeLib()
{ {
typedef std::unique_ptr<ITypeLib, void(*)(IUnknown* p)> ITypeLibGuard; typedef std::unique_ptr<ITypeLib, void(*)(IUnknown* p)> ITypeLibGuard;
...@@ -26,7 +38,7 @@ ITypeLib* GetTypeLib() ...@@ -26,7 +38,7 @@ ITypeLib* GetTypeLib()
if (!aITypeLibGuard.get()) if (!aITypeLibGuard.get())
{ {
wchar_t szFile[MAX_PATH]; wchar_t szFile[MAX_PATH];
if (GetModuleFileNameW((HMODULE)g_hModule, szFile, MAX_PATH) == 0) if (GetModuleFileNameW(static_cast<HMODULE>(g_hModule), szFile, MAX_PATH) == 0)
return nullptr; return nullptr;
ITypeLib* pTypeLib; ITypeLib* pTypeLib;
HRESULT hr = LoadTypeLib(szFile, &pTypeLib); HRESULT hr = LoadTypeLib(szFile, &pTypeLib);
...@@ -43,7 +55,7 @@ const wchar_t* GetLOPath() ...@@ -43,7 +55,7 @@ const wchar_t* GetLOPath()
if (*sPath == 0) if (*sPath == 0)
{ {
// Initialization // Initialization
if (GetModuleFileNameW((HMODULE)g_hModule, sPath, MAX_PATH) == 0) if (GetModuleFileNameW(static_cast<HMODULE>(g_hModule), sPath, MAX_PATH) == 0)
return nullptr; return nullptr;
wchar_t* pSlashPos = wcsrchr(sPath, L'\\'); wchar_t* pSlashPos = wcsrchr(sPath, L'\\');
if (pSlashPos == nullptr) if (pSlashPos == nullptr)
...@@ -107,7 +119,7 @@ STDAPI DllRegisterServer(void) ...@@ -107,7 +119,7 @@ STDAPI DllRegisterServer(void)
return ResultFromScode(SELFREG_E_TYPELIB); return ResultFromScode(SELFREG_E_TYPELIB);
wchar_t szFile[MAX_PATH]; wchar_t szFile[MAX_PATH];
if (GetModuleFileNameW((HMODULE)g_hModule, szFile, MAX_PATH) == 0) if (GetModuleFileNameW(static_cast<HMODULE>(g_hModule), szFile, MAX_PATH) == 0)
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
HRESULT hr = RegisterTypeLib(pTypeLib, szFile, nullptr); HRESULT hr = RegisterTypeLib(pTypeLib, szFile, nullptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment