diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-10-29 09:26:28 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-10-29 13:26:12 +0200 |
commit | a5cea74034a8e029bfdf0f2b82ea8800bf5bd206 (patch) | |
tree | 9d87c2d78e9c5e16b83c445ce23ed2e0fc8df175 | |
parent | 2f39a7b8f90a65d0be9894a0edcf01c161289459 (diff) |
Fix misuses of NULL across Windows-only code
...which defines NULL as a plain 0 integer literal instead of the GNU __null
extension, so clang-cl's -Wnull-conversion cannot kick in. These findings are
from an experimental build done with clang-cl and a modified
> --- a/clang/lib/Headers/stddef.h
> +++ b/clang/lib/Headers/stddef.h
> @@ -83,6 +83,10 @@ typedef __WCHAR_TYPE__ wchar_t;
> # if !defined(__MINGW32__) && !defined(_MSC_VER)
> # define NULL __null
> # else
> -# define NULL 0
> +# if __cplusplus >= 201103L
> +# define NULL nullptr
> +# else
> +# define NULL 0
> +# endif
> # endif
> #else
> # define NULL ((void*)0)
However, that build also ran into lots of places where 3rd-party code in
external/ and Windows system headers caused issues when NULL is nullptr (which
I worked around with various hacky patches for that build), so this is
unfortunately not something that can easily be enabled generally.
Change-Id: I10674464498a9bc63578d9e6cc32ddde23ab4f30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124419
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | embedserv/source/embed/ed_idataobj.cxx | 2 | ||||
-rw-r--r-- | embedserv/source/embed/ed_ipersiststr.cxx | 2 | ||||
-rw-r--r-- | setup_native/source/win32/customactions/sellang/sellang.cxx | 4 | ||||
-rw-r--r-- | svl/source/crypto/cryptosign.cxx | 6 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccAction.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccComponent.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccEditableText.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccHypertext.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccImage.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccTable.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccTableCell.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccText.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccValue.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/MAccessible.cxx | 2 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/MAccessible.h | 2 | ||||
-rw-r--r-- | winaccessibility/source/service/AccObject.cxx | 2 | ||||
-rw-r--r-- | winaccessibility/source/service/AccObjectManagerAgent.cxx | 2 |
17 files changed, 20 insertions, 20 deletions
diff --git a/embedserv/source/embed/ed_idataobj.cxx b/embedserv/source/embed/ed_idataobj.cxx index ca482a421939..84886e63cb4a 100644 --- a/embedserv/source/embed/ed_idataobj.cxx +++ b/embedserv/source/embed/ed_idataobj.cxx @@ -34,7 +34,7 @@ using namespace ::com::sun::star; sal_uInt64 EmbedDocument_Impl::getMetaFileHandle_Impl( bool isEnhMeta ) { - sal_uInt64 pResult = NULL; + sal_uInt64 pResult = 0; uno::Reference< datatransfer::XTransferable > xTransferable( m_pDocHolder->GetDocument(), uno::UNO_QUERY ); if ( xTransferable.is() ) diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx index df5f412593a4..c23141636de0 100644 --- a/embedserv/source/embed/ed_ipersiststr.cxx +++ b/embedserv/source/embed/ed_ipersiststr.cxx @@ -585,7 +585,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, if ( !fSameAsLoad && pStgSave != m_pMasterStorage ) { OSL_ENSURE( m_pMasterStorage, "How could the document be initialized without storage!??" ); - HRESULT hr = m_pMasterStorage->CopyTo( NULL, nullptr, nullptr, pStgSave ); + HRESULT hr = m_pMasterStorage->CopyTo( 0, nullptr, nullptr, pStgSave ); if ( FAILED( hr ) ) return E_FAIL; STATSTG aStat; diff --git a/setup_native/source/win32/customactions/sellang/sellang.cxx b/setup_native/source/win32/customactions/sellang/sellang.cxx index 35022ac7dd50..594bd70bc77c 100644 --- a/setup_native/source/win32/customactions/sellang/sellang.cxx +++ b/setup_native/source/win32/customactions/sellang/sellang.cxx @@ -251,7 +251,7 @@ extern "C" __declspec(dllexport) UINT __stdcall SelectLanguage( MSIHANDLE handle return ERROR_SUCCESS; } - if (MsiViewExecute(view, NULL) != ERROR_SUCCESS) { + if (MsiViewExecute(view, 0) != ERROR_SUCCESS) { MsiCloseHandle(view); MsiCloseHandle(database); return ERROR_SUCCESS; @@ -287,7 +287,7 @@ extern "C" __declspec(dllexport) UINT __stdcall SelectLanguage( MSIHANDLE handle &view) == ERROR_SUCCESS) { - if (MsiViewExecute(view, NULL) == ERROR_SUCCESS) { + if (MsiViewExecute(view, 0) == ERROR_SUCCESS) { while (ndicts < MAX_LANGUAGES && MsiViewFetch(view, &record) == ERROR_SUCCESS) { diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx index e7c5964f6d9e..25ac21b695c4 100644 --- a/svl/source/crypto/cryptosign.cxx +++ b/svl/source/crypto/cryptosign.cxx @@ -1426,7 +1426,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) HCRYPTMSG hDecodedMsg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_SIGNED, - NULL, + 0, nullptr, nullptr); if (!hDecodedMsg) @@ -2092,7 +2092,7 @@ bool Signing::Verify(const std::vector<unsigned char>& aData, HCRYPTMSG hMsg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, CMSG_DETACHED_FLAG, 0, - NULL, + 0, nullptr, nullptr); if (!hMsg) @@ -2162,7 +2162,7 @@ bool Signing::Verify(const std::vector<unsigned char>& aData, // initializes it with the certificates from the message. HCERTSTORE hStoreHandle = CertOpenStore(CERT_STORE_PROV_MSG, PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, - NULL, + 0, 0, hMsg); if (!hStoreHandle) diff --git a/winaccessibility/source/UAccCOM/AccAction.h b/winaccessibility/source/UAccCOM/AccAction.h index 8579e90cb242..7fcff0810523 100644 --- a/winaccessibility/source/UAccCOM/AccAction.h +++ b/winaccessibility/source/UAccCOM/AccAction.h @@ -42,7 +42,7 @@ public: BEGIN_COM_MAP(CAccAction) COM_INTERFACE_ENTRY(IAccessibleAction) COM_INTERFACE_ENTRY(IUNOXWrapper) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/UAccCOM/AccComponent.h b/winaccessibility/source/UAccCOM/AccComponent.h index bfd0cf42582c..9a620a5231b8 100644 --- a/winaccessibility/source/UAccCOM/AccComponent.h +++ b/winaccessibility/source/UAccCOM/AccComponent.h @@ -45,7 +45,7 @@ public: BEGIN_COM_MAP(CAccComponent) COM_INTERFACE_ENTRY(IAccessibleComponent) COM_INTERFACE_ENTRY(IUNOXWrapper) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/UAccCOM/AccEditableText.h b/winaccessibility/source/UAccCOM/AccEditableText.h index 30c6d2a08e91..244dc626bb5a 100644 --- a/winaccessibility/source/UAccCOM/AccEditableText.h +++ b/winaccessibility/source/UAccCOM/AccEditableText.h @@ -50,7 +50,7 @@ public: BEGIN_COM_MAP(CAccEditableText) COM_INTERFACE_ENTRY(IAccessibleEditableText) COM_INTERFACE_ENTRY(IUNOXWrapper) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/UAccCOM/AccHypertext.h b/winaccessibility/source/UAccCOM/AccHypertext.h index 41be1d886c93..3a6dccfb12a1 100644 --- a/winaccessibility/source/UAccCOM/AccHypertext.h +++ b/winaccessibility/source/UAccCOM/AccHypertext.h @@ -43,7 +43,7 @@ public: COM_INTERFACE_ENTRY(IAccessibleText) COM_INTERFACE_ENTRY(IAccessibleHypertext) COM_INTERFACE_ENTRY(IUNOXWrapper) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/UAccCOM/AccImage.h b/winaccessibility/source/UAccCOM/AccImage.h index f747ddfe57f7..4e0708a18066 100644 --- a/winaccessibility/source/UAccCOM/AccImage.h +++ b/winaccessibility/source/UAccCOM/AccImage.h @@ -44,7 +44,7 @@ public: BEGIN_COM_MAP(CAccImage) COM_INTERFACE_ENTRY(IAccessibleImage) COM_INTERFACE_ENTRY(IUNOXWrapper) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/UAccCOM/AccTable.h b/winaccessibility/source/UAccCOM/AccTable.h index d4062986147c..d5805c3c0b46 100644 --- a/winaccessibility/source/UAccCOM/AccTable.h +++ b/winaccessibility/source/UAccCOM/AccTable.h @@ -48,7 +48,7 @@ public: COM_INTERFACE_ENTRY(IAccessibleTable) COM_INTERFACE_ENTRY(IAccessibleTable2) COM_INTERFACE_ENTRY(IUNOXWrapper) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/UAccCOM/AccTableCell.h b/winaccessibility/source/UAccCOM/AccTableCell.h index 9b9315d5ca47..2c7d1a79aeb6 100644 --- a/winaccessibility/source/UAccCOM/AccTableCell.h +++ b/winaccessibility/source/UAccCOM/AccTableCell.h @@ -41,7 +41,7 @@ public: BEGIN_COM_MAP(CAccTableCell) COM_INTERFACE_ENTRY(IAccessibleTableCell) COM_INTERFACE_ENTRY(IUNOXWrapper) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL, SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0, SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/UAccCOM/AccText.h b/winaccessibility/source/UAccCOM/AccText.h index dd624fd4e306..eba821aae84d 100644 --- a/winaccessibility/source/UAccCOM/AccText.h +++ b/winaccessibility/source/UAccCOM/AccText.h @@ -40,7 +40,7 @@ public: BEGIN_COM_MAP(CAccText) COM_INTERFACE_ENTRY(IAccessibleText) COM_INTERFACE_ENTRY(IUNOXWrapper) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/UAccCOM/AccValue.h b/winaccessibility/source/UAccCOM/AccValue.h index 0bfb1dda0e25..056eeb26195e 100644 --- a/winaccessibility/source/UAccCOM/AccValue.h +++ b/winaccessibility/source/UAccCOM/AccValue.h @@ -45,7 +45,7 @@ public: BEGIN_COM_MAP(CAccValue) COM_INTERFACE_ENTRY(IAccessibleValue) COM_INTERFACE_ENTRY(IUNOXWrapper) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 7cb2ca2410ae..7437f8a586c9 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -2337,7 +2337,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::accSelect(long flagsSelect, VARI pSelectAcc->GetUNOInterface(&nHyper); if( pTempUNO == nullptr ) - return NULL; + return 0; Reference<XAccessibleContext> pRContext = pTempUNO->getAccessibleContext(); Reference< XAccessibleComponent > pRComponent(pRContext,UNO_QUERY); diff --git a/winaccessibility/source/UAccCOM/MAccessible.h b/winaccessibility/source/UAccCOM/MAccessible.h index 224e59179d61..3c662c1f12fb 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.h +++ b/winaccessibility/source/UAccCOM/MAccessible.h @@ -66,7 +66,7 @@ public: COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(IAccessibleApplication) COM_INTERFACE_ENTRY(IServiceProvider) - COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) + COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_) #if defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx index f03b853c9e84..9b6609666ee6 100644 --- a/winaccessibility/source/service/AccObject.cxx +++ b/winaccessibility/source/service/AccObject.cxx @@ -159,7 +159,7 @@ const short ROLE_TABLE[][2] = */ AccObject::AccObject(XAccessible* pAcc, AccObjectManagerAgent* pAgent, AccEventListener* pListener) : - m_resID (NULL), + m_resID (0), m_pParantID (nullptr), m_pIMAcc (nullptr), m_pParentObj(nullptr), diff --git a/winaccessibility/source/service/AccObjectManagerAgent.cxx b/winaccessibility/source/service/AccObjectManagerAgent.cxx index ab909d495398..62d58f384f17 100644 --- a/winaccessibility/source/service/AccObjectManagerAgent.cxx +++ b/winaccessibility/source/service/AccObjectManagerAgent.cxx @@ -376,7 +376,7 @@ bool AccObjectManagerAgent::IsTopWinAcc(XAccessible* pXAcc) { return pWinManager->IsTopWinAcc( pXAcc ); } - return NULL; + return false; } bool AccObjectManagerAgent::IsStateManageDescendant(XAccessible* pXAcc) |