From 0bd502af47b53bc4340df7874bd726361e3bbad9 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sun, 29 Mar 2015 09:17:00 +0200 Subject: Clean up remaining C-style casts among void pointers Change-Id: I1b49c020d597b569e330482f4dbf20c15ccdae3f --- basic/source/classes/sbunoobj.cxx | 2 +- compilerplugins/clang/cstylecast.cxx | 3 --- forms/source/component/DatabaseForm.cxx | 4 ++-- idlc/source/astdump.cxx | 6 +++--- idlc/source/astenum.cxx | 2 +- idlc/source/astinterface.cxx | 2 +- idlc/source/aststruct.cxx | 2 +- include/vcl/cmdevt.hxx | 2 +- include/vcl/event.hxx | 4 ++-- pyuno/source/module/pyuno.cxx | 4 ++-- pyuno/source/module/pyuno_runtime.cxx | 4 ++-- sot/source/sdstor/stgstrms.cxx | 2 +- stoc/source/corereflection/base.hxx | 2 +- stoc/source/corereflection/criface.cxx | 8 ++++---- sw/source/core/txtnode/fntcache.cxx | 2 +- sw/source/core/txtnode/swfntcch.cxx | 2 +- xmloff/source/style/impastpl.cxx | 2 +- 17 files changed, 25 insertions(+), 28 deletions(-) diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 7a73a45a65a1..2e527d46edbd 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -4799,7 +4799,7 @@ bool StructRefInfo::setValue( const Any& rValue ) { return uno_type_assignData( getInst(), maType.getTypeLibType(), - (void*)rValue.getValue(), + const_cast(rValue.getValue()), rValue.getValueTypeRef(), reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface), reinterpret_cast< uno_AcquireFunc >(cpp_acquire), diff --git a/compilerplugins/clang/cstylecast.cxx b/compilerplugins/clang/cstylecast.cxx index fcc1fc828862..47e8d17b8977 100644 --- a/compilerplugins/clang/cstylecast.cxx +++ b/compilerplugins/clang/cstylecast.cxx @@ -95,9 +95,6 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) { if (t1->isPointerType() && t2->isPointerType()) { t1 = t1->getAs()->getPointeeType(); t2 = t2->getAs()->getPointeeType(); - if (t2->isVoidType()) { - return true; - } } else if (t1->isLValueReferenceType() && t2->isLValueReferenceType()) { t1 = t1->getAs()->getPointeeType(); t2 = t2->getAs()->getPointeeType(); diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 82a6d7822eaf..672e7c489ec3 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -569,11 +569,11 @@ Sequence ODatabaseForm::GetDataMultiPartEncoded(const Reference(static_cast(pData), nLen); + return Sequence(static_cast(pData), nLen); } diff --git a/idlc/source/astdump.cxx b/idlc/source/astdump.cxx index e0f786b68505..5b6938c80d80 100644 --- a/idlc/source/astdump.cxx +++ b/idlc/source/astdump.cxx @@ -87,7 +87,7 @@ bool AstModule::dump(RegistryKey& rKey) void const * pBlob = aBlob.getBlob(&aBlobSize); if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY, - (RegValue)pBlob, aBlobSize)) + const_cast(pBlob), aBlobSize)) { fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n", idlc()->getOptions()->getProgramName().getStr(), @@ -112,7 +112,7 @@ bool AstModule::dump(RegistryKey& rKey) if ( getNodeType() != NT_root ) { if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY, - (RegValue)pBlob, aBlobSize)) + const_cast(pBlob), aBlobSize)) { fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n", idlc()->getOptions()->getProgramName().getStr(), @@ -152,7 +152,7 @@ bool AstTypeDef::dump(RegistryKey& rKey) sal_uInt32 aBlobSize; void const * pBlob = aBlob.getBlob(&aBlobSize); - if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY, (RegValue)pBlob, aBlobSize)) + if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY, const_cast(pBlob), aBlobSize)) { fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n", idlc()->getOptions()->getProgramName().getStr(), diff --git a/idlc/source/astenum.cxx b/idlc/source/astenum.cxx index 32f813803c6e..51a48f06282e 100644 --- a/idlc/source/astenum.cxx +++ b/idlc/source/astenum.cxx @@ -92,7 +92,7 @@ bool AstEnum::dump(RegistryKey& rKey) void const * pBlob = aBlob.getBlob(&aBlobSize); if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY, - (RegValue)pBlob, aBlobSize)) + const_cast(pBlob), aBlobSize)) { fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n", idlc()->getOptions()->getProgramName().getStr(), diff --git a/idlc/source/astinterface.cxx b/idlc/source/astinterface.cxx index f6b9eef824f1..7a28e2198d5c 100644 --- a/idlc/source/astinterface.cxx +++ b/idlc/source/astinterface.cxx @@ -244,7 +244,7 @@ bool AstInterface::dump(RegistryKey& rKey) sal_uInt32 aBlobSize; void const * pBlob = aBlob.getBlob(&aBlobSize); - if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY, (RegValue)pBlob, aBlobSize)) + if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY, const_cast(pBlob), aBlobSize)) { fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n", idlc()->getOptions()->getProgramName().getStr(), diff --git a/idlc/source/aststruct.cxx b/idlc/source/aststruct.cxx index 0a85a12965fa..5df066c01e31 100644 --- a/idlc/source/aststruct.cxx +++ b/idlc/source/aststruct.cxx @@ -162,7 +162,7 @@ bool AstStruct::dump(RegistryKey& rKey) void const * pBlob = aBlob.getBlob(&aBlobSize); if (localKey.setValue(emptyStr, RG_VALUETYPE_BINARY, - (RegValue)pBlob, aBlobSize)) + const_cast(pBlob), aBlobSize)) { fprintf(stderr, "%s: warning, could not set value of key \"%s\" in %s\n", idlc()->getOptions()->getProgramName().getStr(), diff --git a/include/vcl/cmdevt.hxx b/include/vcl/cmdevt.hxx index ad6a9dc72d25..942d45bb443a 100644 --- a/include/vcl/cmdevt.hxx +++ b/include/vcl/cmdevt.hxx @@ -439,7 +439,7 @@ inline CommandEvent::CommandEvent( const Point& rMousePos, sal_uInt16 nCmd, bool bMEvt, const void* pCmdData ) : maPos( rMousePos ) { - mpData = (void*)pCmdData; + mpData = const_cast(pCmdData); mnCommand = nCmd; mbMouseEvent = bMEvt; } diff --git a/include/vcl/event.hxx b/include/vcl/event.hxx index 8ad67fb0efdc..05a54dc7dfc5 100644 --- a/include/vcl/event.hxx +++ b/include/vcl/event.hxx @@ -447,7 +447,7 @@ inline NotifyEvent::NotifyEvent( MouseNotifyEvent nEventType, vcl::Window* pWind const void* pEvent, long nRet ) { mpWindow = pWindow; - mpData = (void*)pEvent; + mpData = const_cast(pEvent); mnEventType = nEventType; mnRetValue = nRet; } @@ -521,7 +521,7 @@ inline DataChangedEvent::DataChangedEvent( DataChangedEventType nType, const void* pData, AllSettingsFlags nChangeFlags ) { - mpData = (void*)pData; + mpData = const_cast(pData); mnFlags = nChangeFlags; mnType = nType; } diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx index 1d990d035eeb..3ec1316b123c 100644 --- a/pyuno/source/module/pyuno.cxx +++ b/pyuno/source/module/pyuno.cxx @@ -408,7 +408,7 @@ PyObject *PyUNO_str( PyObject * self ) { PyThreadDetach antiguard; Any a = rHolder->getMaterial(); - OUString s = val2str( (void*) a.getValue(), a.getValueType().getTypeLibType() ); + OUString s = val2str( a.getValue(), a.getValueType().getTypeLibType() ); buf.append( OUStringToOString(s,RTL_TEXTENCODING_ASCII_US) ); } } @@ -418,7 +418,7 @@ PyObject *PyUNO_str( PyObject * self ) PyThreadDetach antiguard; buf.append( "pyuno object " ); - OUString s = val2str( (void*)me->members->wrappedObject.getValue(), + OUString s = val2str( me->members->wrappedObject.getValue(), me->members->wrappedObject.getValueType().getTypeLibType() ); buf.append( OUStringToOString(s,RTL_TEXTENCODING_ASCII_US) ); } diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx index c58682cd006b..a7793da7e7ff 100644 --- a/pyuno/source/module/pyuno_runtime.cxx +++ b/pyuno/source/module/pyuno_runtime.cxx @@ -499,8 +499,8 @@ PyRef Runtime::any2PyObject (const Any &a ) const PyRef args( PyTuple_New( 1 ), SAL_NO_ACQUIRE, NOT_NULL ); // assuming that the Message is always the first member, wuuuu - void *pData = (void*)a.getValue(); - OUString message = *static_cast(pData); + void const *pData = a.getValue(); + OUString message = *static_cast(pData); PyRef pymsg = ustring2PyString( message ); PyTuple_SetItem( args.get(), 0 , pymsg.getAcquired() ); // the exception base functions want to have an "args" tuple, diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index ca7f087f25c4..e90e823ccae3 100644 --- a/sot/source/sdstor/stgstrms.cxx +++ b/sot/source/sdstor/stgstrms.cxx @@ -984,7 +984,7 @@ sal_Int32 StgDataStrm::Write( const void* pBuf, sal_Int32 n ) } else // do a direct (unbuffered) write - nRes = (short) rIo.Write( nPage, (void*) p, 1 ) * nPageSize; + nRes = (short) rIo.Write( nPage, const_cast(p), 1 ) * nPageSize; } else { diff --git a/stoc/source/corereflection/base.hxx b/stoc/source/corereflection/base.hxx index 7c83960acd4f..d81cf768acf6 100644 --- a/stoc/source/corereflection/base.hxx +++ b/stoc/source/corereflection/base.hxx @@ -425,7 +425,7 @@ inline bool coerce_assign( { return uno_type_assignData( pDest, pTD->pWeakRef, - (void *)rSource.getValue(), rSource.getValueTypeRef(), + const_cast(rSource.getValue()), rSource.getValueTypeRef(), reinterpret_cast< uno_QueryInterfaceFunc >(css::uno::cpp_queryInterface), reinterpret_cast< uno_AcquireFunc >(css::uno::cpp_acquire), reinterpret_cast< uno_ReleaseFunc >(css::uno::cpp_release) ); diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx index a3b72bc47ebf..560d6329e219 100644 --- a/stoc/source/corereflection/criface.cxx +++ b/stoc/source/corereflection/criface.cxx @@ -258,7 +258,7 @@ void IdlAttributeFieldImpl::set( Any & rObj, const Any & rValue ) // construct temp uno val to do proper assignment: todo opt void * pTemp = alloca( pValueTD->nSize ); uno_copyAndConvertData( - pTemp, (void *)rValue.getValue(), pValueTD, getReflection()->getCpp2Uno().get() ); + pTemp, const_cast(rValue.getValue()), pValueTD, getReflection()->getCpp2Uno().get() ); uno_constructData( pArg, pTD ); // assignment does simple conversion @@ -636,14 +636,14 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > & pCppArgs[nPos].getValueTypeRef(), pTD->pWeakRef )) { uno_type_copyAndConvertData( - ppUnoArgs[nPos], (void *)pCppArgs[nPos].getValue(), + ppUnoArgs[nPos], const_cast(pCppArgs[nPos].getValue()), pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() ); bAssign = true; } else if (pTD->eTypeClass == typelib_TypeClass_ANY) { uno_type_any_constructAndConvert( - static_cast(ppUnoArgs[nPos]), (void *)pCppArgs[nPos].getValue(), + static_cast(ppUnoArgs[nPos]), const_cast(pCppArgs[nPos].getValue()), pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() ); bAssign = true; } @@ -666,7 +666,7 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > & // construct temp uno val to do proper assignment: todo opt void * pTemp = alloca( pValueTD->nSize ); uno_copyAndConvertData( - pTemp, (void *)pCppArgs[nPos].getValue(), pValueTD, + pTemp, const_cast(pCppArgs[nPos].getValue()), pValueTD, getReflection()->getCpp2Uno().get() ); uno_constructData( ppUnoArgs[nPos], pTD ); diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 225e637bcaf4..9c34419b7a7e 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -104,7 +104,7 @@ void SwFntCache::Flush( ) } SwFntObj::SwFntObj(const SwSubFont &rFont, const void *pOwn, SwViewShell const *pSh) - : SwCacheObj((void*)pOwn) + : SwCacheObj(pOwn) , aFont(rFont) , pScrFont(NULL) , pPrtFont(&aFont) diff --git a/sw/source/core/txtnode/swfntcch.cxx b/sw/source/core/txtnode/swfntcch.cxx index 058b071fd29c..109ce7af8872 100644 --- a/sw/source/core/txtnode/swfntcch.cxx +++ b/sw/source/core/txtnode/swfntcch.cxx @@ -30,7 +30,7 @@ extern const sal_uInt8 StackPos[]; SwFontCache *pSwFontCache = NULL; SwFontObj::SwFontObj( const void *pOwn, SwViewShell *pSh ) : - SwCacheObj( (void*)pOwn ), + SwCacheObj( pOwn ), aSwFont( &static_cast(pOwn)->GetAttrSet(), pSh ? pSh->getIDocumentSettingAccess() : 0 ) { aSwFont.GoMagic( pSh, aSwFont.GetActual() ); diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx index b6e1b2ae176a..a35f51b0b4cf 100644 --- a/xmloff/source/style/impastpl.cxx +++ b/xmloff/source/style/impastpl.cxx @@ -165,7 +165,7 @@ data2string(void *data, static OUString any2string(uno::Any any) { - return data2string((void*)any.getValue(), any.pType); + return data2string(const_cast(any.getValue()), any.pType); } // Class SvXMLAutoStylePoolProperties_Impl -- cgit