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>
This commit is contained in:
Stephan Bergmann 2021-10-29 09:26:28 +02:00
parent 2f39a7b8f9
commit a5cea74034
17 changed files with 20 additions and 20 deletions

View file

@ -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() )

View file

@ -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;

View file

@ -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)
{

View file

@ -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)

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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);

View file

@ -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"

View file

@ -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),

View file

@ -376,7 +376,7 @@ bool AccObjectManagerAgent::IsTopWinAcc(XAccessible* pXAcc)
{
return pWinManager->IsTopWinAcc( pXAcc );
}
return NULL;
return false;
}
bool AccObjectManagerAgent::IsStateManageDescendant(XAccessible* pXAcc)