Fix warning C4312 when building with MSVC without -Wv:18

Discovered by https://gerrit.libreoffice.org/c/core/+/163717

Like these:

 C:/lo/core/sw/source/ui/dbui/addresslistdialog.cxx(426): warning C4312: 'reinterpret_cast': conversion from 'int' to 'void *' of greater size

Change-Id: Idbfbe8add89c8e219bdabcf28b741e2e31a5e345
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163781
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2024-02-22 22:12:53 +06:00
parent d7831d30e4
commit d37df8fd1a
12 changed files with 29 additions and 27 deletions

View file

@ -611,7 +611,7 @@ ErrCode getProcData(HMODULE handle, OUString const & name, ProcData * proc)
{
assert(proc != nullptr);
if (name.getLength() != 0 && name[0] == '@') { //TODO: "@" vs. "#"???
sal_Int32 n = o3tl::toInt32(name.subView(1)); //TODO: handle bad input
sal_IntPtr n = o3tl::toInt32(name.subView(1)); //TODO: handle bad input
if (n <= 0 || n > 0xFFFF) {
return ERRCODE_BASIC_BAD_ARGUMENT; //TODO: more specific errcode?
}

View file

@ -98,7 +98,7 @@ SQLRETURN OConnection::OpenConnection(const OUString& aConnectStr, sal_Int32 nTi
memcpy(szConnStrIn, aConStr.getStr(), std::min<sal_Int32>(sal_Int32(2048),aConStr.getLength()));
#ifndef MACOSX
N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,reinterpret_cast<SQLPOINTER>(nTimeOut),SQL_IS_UINTEGER);
N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,reinterpret_cast<SQLPOINTER>(static_cast<sal_IntPtr>(nTimeOut)),SQL_IS_UINTEGER);
#else
(void)nTimeOut; /* WaE */
#endif
@ -312,10 +312,10 @@ void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit )
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
const sal_IntPtr nAutocommit = autoCommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF;
OTools::ThrowException(this,N3SQLSetConnectAttr(m_aConnectionHandle,
SQL_ATTR_AUTOCOMMIT,
reinterpret_cast<SQLPOINTER>((autoCommit) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF) ,SQL_IS_INTEGER),
reinterpret_cast<SQLPOINTER>(nAutocommit) ,SQL_IS_INTEGER),
m_aConnectionHandle,SQL_HANDLE_DBC,*this);
}
@ -423,7 +423,7 @@ void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level )
OTools::ThrowException(this,N3SQLSetConnectAttr(m_aConnectionHandle,
SQL_ATTR_TXN_ISOLATION,
reinterpret_cast<SQLPOINTER>(level),SQL_IS_INTEGER),
reinterpret_cast<SQLPOINTER>(static_cast<sal_IntPtr>(level)),SQL_IS_INTEGER),
m_aConnectionHandle,SQL_HANDLE_DBC,*this);
}

View file

@ -228,7 +228,7 @@ const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex)
for (; k != m_pCache->getEnd(); ++k)
{
ORowSetValueVector* pTemp = k->get();
OSL_ENSURE( pTemp != reinterpret_cast<void*>(0xfeeefeee),"HALT!" );
OSL_ENSURE( pTemp != reinterpret_cast<void*>(sal_uIntPtr(0xfeeefeee)),"HALT!" );
}
OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow < m_pCache->getEnd() && aCacheIter != m_pCache->m_aCacheIterators.end(),"Invalid iterator set for currentrow!");
#endif

View file

@ -253,9 +253,10 @@ void Twain::ShimListenerThread::execute()
ThrowLastError("DuplicateHandle");
// we will not need our copy as soon as shim has its own inherited one
ScopedHANDLE hScopedDup(hDup);
DWORD nDup = static_cast<DWORD>(reinterpret_cast<sal_uIntPtr>(hDup));
if (reinterpret_cast<HANDLE>(nDup) != hDup)
throw std::exception("HANDLE does not fit to 32 bit - cannot pass to shim!");
sal_uIntPtr nDup = reinterpret_cast<sal_uIntPtr>(hDup);
if constexpr (sizeof(sal_uIntPtr) > 4)
if (nDup > 0xFFFFFFFF)
throw std::exception("HANDLE does not fit to 32 bit - cannot pass to shim!");
// Send this thread handle as the first parameter
sCmdLine = "\"" + sCmdLine + "\" " + OUString::number(nDup);

View file

@ -3042,7 +3042,8 @@ void SfxMedium::GetMedium_Impl()
pImpl->bDownloadDone = true;
pImpl->aDoneLink.ClearPendingCall();
ErrCodeMsg nError = GetErrorIgnoreWarning();
pImpl->aDoneLink.Call( reinterpret_cast<void*>(sal_uInt32(nError.GetCode())) );
sal_uIntPtr nErrorCode = sal_uInt32(nError.GetCode());
pImpl->aDoneLink.Call( reinterpret_cast<void*>(nErrorCode) );
}
bool SfxMedium::IsRemote() const

View file

@ -88,7 +88,7 @@ void GalleryTheme::ImplBroadcast(sal_uInt32 nUpdatePos)
if( GetObjectCount() && ( nUpdatePos >= GetObjectCount() ) )
nUpdatePos = GetObjectCount() - 1;
Broadcast( GalleryHint( GalleryHintType::THEME_UPDATEVIEW, GetName(), reinterpret_cast<void*>(nUpdatePos) ) );
Broadcast( GalleryHint( GalleryHintType::THEME_UPDATEVIEW, GetName(), reinterpret_cast<void*>(static_cast<sal_uIntPtr>(nUpdatePos)) ) );
}
}

View file

@ -55,7 +55,7 @@ SwNumberTreeNode::~SwNumberTreeNode()
OSL_ENSURE( IsPhantom() || mpParent == nullptr, ": I'm not supposed to have a parent.");
mpParent = reinterpret_cast<SwNumberTreeNode *>(0xdeadbeef);
mpParent = reinterpret_cast<SwNumberTreeNode *>(sal_uIntPtr(0xdeadbeef));
OSL_ENSURE(mChildren.empty(), "children left!");
}

View file

@ -421,7 +421,7 @@ IMPL_LINK_NOARG(SwAddressListDialog, EditHdl_Impl, weld::Button&, void)
IMPL_LINK_NOARG(SwAddressListDialog, ListBoxSelectHdl_Impl, weld::TreeView&, void)
{
int nSelect = m_xListLB->get_selected_index();
sal_IntPtr nSelect = m_xListLB->get_selected_index();
Application::PostUserEvent( LINK( this, SwAddressListDialog,
StaticListBoxSelectHdl_Impl ), reinterpret_cast<void*>(nSelect) );
}

View file

@ -895,7 +895,7 @@ sal_Int32 ComboBox::InsertEntry(const OUString& rStr, sal_Int32 const nPos)
nRealPos = m_pImpl->m_pImplLB->InsertEntry( nRealPos, rStr );
nRealPos -= m_pImpl->m_pImplLB->GetEntryList().GetMRUCount();
CallEventListeners( VclEventId::ComboboxItemAdded, reinterpret_cast<void*>(nRealPos) );
CallEventListeners( VclEventId::ComboboxItemAdded, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nRealPos)) );
return nRealPos;
}
@ -916,7 +916,7 @@ sal_Int32 ComboBox::InsertEntryWithImage(
nRealPos = m_pImpl->m_pImplLB->InsertEntry( nRealPos, rStr, rImage );
nRealPos -= m_pImpl->m_pImplLB->GetEntryList().GetMRUCount();
CallEventListeners( VclEventId::ComboboxItemAdded, reinterpret_cast<void*>(nRealPos) );
CallEventListeners( VclEventId::ComboboxItemAdded, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nRealPos)) );
return nRealPos;
}
@ -925,7 +925,7 @@ void ComboBox::RemoveEntryAt(sal_Int32 const nPos)
const sal_Int32 nMRUCount = m_pImpl->m_pImplLB->GetEntryList().GetMRUCount();
assert(nPos >= 0 && nPos <= COMBOBOX_MAX_ENTRIES - nMRUCount);
m_pImpl->m_pImplLB->RemoveEntry( nPos + nMRUCount );
CallEventListeners( VclEventId::ComboboxItemRemoved, reinterpret_cast<void*>(nPos) );
CallEventListeners( VclEventId::ComboboxItemRemoved, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nPos)) );
}
void ComboBox::Clear()
@ -933,7 +933,7 @@ void ComboBox::Clear()
if (!m_pImpl->m_pImplLB)
return;
m_pImpl->m_pImplLB->Clear();
CallEventListeners( VclEventId::ComboboxItemRemoved, reinterpret_cast<void*>(-1) );
CallEventListeners( VclEventId::ComboboxItemRemoved, reinterpret_cast<void*>(sal_IntPtr(-1)) );
}
Image ComboBox::GetEntryImage( sal_Int32 nPos ) const

View file

@ -1552,7 +1552,7 @@ namespace
// vcl::StringEntryIdentifier does not allow for 0 values, but our position is 0-based
// => normalize
return reinterpret_cast< vcl::StringEntryIdentifier >( _nPos + 1 );
return reinterpret_cast< vcl::StringEntryIdentifier >( _nPos + sal_IntPtr(1) );
}
sal_Int32 lcl_getEntryPos( vcl::StringEntryIdentifier _entry )

View file

@ -191,7 +191,7 @@ IMPL_LINK_NOARG(ListBox, ImplSelectHdl, LinkParamNone*, void)
IMPL_LINK( ListBox, ImplFocusHdl, sal_Int32, nPos, void )
{
CallEventListeners( VclEventId::ListboxFocus, reinterpret_cast<void*>(nPos) );
CallEventListeners( VclEventId::ListboxFocus, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nPos)) );
}
IMPL_LINK_NOARG( ListBox, ImplListItemSelectHdl, LinkParamNone*, void )
@ -945,7 +945,7 @@ sal_Int32 ListBox::InsertEntry( const OUString& rStr, sal_Int32 nPos )
{
sal_Int32 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList().GetMRUCount(), rStr );
nRealPos = sal::static_int_cast<sal_Int32>(nRealPos - mpImplLB->GetEntryList().GetMRUCount());
CallEventListeners( VclEventId::ListboxItemAdded, reinterpret_cast<void*>(nRealPos) );
CallEventListeners( VclEventId::ListboxItemAdded, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nRealPos)) );
return nRealPos;
}
@ -953,14 +953,14 @@ sal_Int32 ListBox::InsertEntry( const OUString& rStr, const Image& rImage, sal_I
{
sal_Int32 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList().GetMRUCount(), rStr, rImage );
nRealPos = sal::static_int_cast<sal_Int32>(nRealPos - mpImplLB->GetEntryList().GetMRUCount());
CallEventListeners( VclEventId::ListboxItemAdded, reinterpret_cast<void*>(nRealPos) );
CallEventListeners( VclEventId::ListboxItemAdded, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nRealPos)) );
return nRealPos;
}
void ListBox::RemoveEntry( sal_Int32 nPos )
{
mpImplLB->RemoveEntry( nPos + mpImplLB->GetEntryList().GetMRUCount() );
CallEventListeners( VclEventId::ListboxItemRemoved, reinterpret_cast<void*>(nPos) );
CallEventListeners( VclEventId::ListboxItemRemoved, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nPos)) );
}
Image ListBox::GetEntryImage( sal_Int32 nPos ) const
@ -1043,9 +1043,9 @@ void ListBox::SelectEntryPos( sal_Int32 nPos, bool bSelect )
//Only when bSelect == true, send both Selection & Focus events
if (nCurrentPos != nPos && bSelect)
{
CallEventListeners( VclEventId::ListboxSelect, reinterpret_cast<void*>(nPos));
CallEventListeners( VclEventId::ListboxSelect, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nPos)));
if (HasFocus())
CallEventListeners( VclEventId::ListboxFocus, reinterpret_cast<void*>(nPos));
CallEventListeners( VclEventId::ListboxFocus, reinterpret_cast<void*>(static_cast<sal_IntPtr>(nPos)));
}
}
}

View file

@ -4202,7 +4202,7 @@ void VclBuilder::mungeModel(ComboBox &rTarget, const ListStore &rStore, sal_uInt
{
if (m_bLegacy)
{
sal_Int32 nValue = rRow[1].toInt32();
sal_IntPtr nValue = rRow[1].toInt32();
rTarget.SetEntryData(nEntry, reinterpret_cast<void*>(nValue));
}
else
@ -4229,7 +4229,7 @@ void VclBuilder::mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt1
{
if (m_bLegacy)
{
sal_Int32 nValue = rRow[1].toInt32();
sal_IntPtr nValue = rRow[1].toInt32();
rTarget.SetEntryData(nEntry, reinterpret_cast<void*>(nValue));
}
else
@ -4256,7 +4256,7 @@ void VclBuilder::mungeModel(SvTabListBox& rTarget, const ListStore &rStore, sal_
{
if (m_bLegacy)
{
sal_Int32 nValue = rRow[1].toInt32();
sal_IntPtr nValue = rRow[1].toInt32();
pEntry->SetUserData(reinterpret_cast<void*>(nValue));
}
else