diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-11 08:47:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-15 07:26:17 +0100 |
commit | 7d8e94444d989d0ac4a4055b207726708e9ec0da (patch) | |
tree | ce3e4a09ed7932496c4d901360ff23787c8f6e24 /connectivity | |
parent | 80fb8d406ced47e6a2089f0c8ba5c103d2fec91f (diff) |
convert a<b?a:b to std::min(a,b)
with something like
git grep -nP '(.*)\s*<\s*(.*)\s*\?\s*\g1\s*:\s*\g2' -- *.?xx
Change-Id: Id5078b35961847feb78a66204fdb7598ee63fd23
Note: we also convert a>b?b:a
Reviewed-on: https://gerrit.libreoffice.org/47736
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/Blob.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/PreparedStatement.cxx | 6 | ||||
-rw-r--r-- | connectivity/source/drivers/postgresql/pq_resultset.cxx | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/connectivity/source/drivers/firebird/Blob.cxx b/connectivity/source/drivers/firebird/Blob.cxx index 3bf9252c7fdb..71828e5563c0 100644 --- a/connectivity/source/drivers/firebird/Blob.cxx +++ b/connectivity/source/drivers/firebird/Blob.cxx @@ -278,7 +278,7 @@ sal_Int32 SAL_CALL Blob::readBytes(uno::Sequence< sal_Int8 >& rDataOut, // Ensure we have enough space for the amount of data we can actually read. const sal_Int64 nBytesAvailable = m_nBlobLength - m_nBlobPosition; - const sal_Int32 nBytesToRead = nBytes < nBytesAvailable ? nBytes : nBytesAvailable; + const sal_Int32 nBytesToRead = std::min<sal_Int64>(nBytes, nBytesAvailable); if (rDataOut.getLength() < nBytesToRead) rDataOut.realloc(nBytesToRead); @@ -289,7 +289,7 @@ sal_Int32 SAL_CALL Blob::readBytes(uno::Sequence< sal_Int8 >& rDataOut, { sal_uInt16 nBytesRead = 0; sal_uInt64 nDataRemaining = nBytesToRead - nTotalBytesRead; - sal_uInt16 nReadSize = (nDataRemaining > SAL_MAX_UINT16) ? SAL_MAX_UINT16 : nDataRemaining; + sal_uInt16 nReadSize = std::min<sal_uInt64>(nDataRemaining, SAL_MAX_UINT16); aErr = isc_get_segment(m_statusVector, &m_blobHandle, &nBytesRead, diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 8b00beb20626..9d9a6853e1fa 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -552,7 +552,7 @@ void SAL_CALL OPreparedStatement::setClob(sal_Int32 nParameterIndex, const Refer { sal_Int64 nCharRemain = nLen - nCharWritten; constexpr sal_uInt16 MAX_SIZE = SAL_MAX_UINT16 / 4; - sal_uInt16 nWriteSize = (nCharRemain > MAX_SIZE) ? MAX_SIZE : nCharRemain; + sal_uInt16 nWriteSize = std::min<sal_Int64>(nCharRemain, MAX_SIZE); OString sData = OUStringToOString( xClob->getSubString(nCharWritten, nWriteSize), RTL_TEXTENCODING_UTF8); @@ -642,7 +642,7 @@ void SAL_CALL OPreparedStatement::setBlob(sal_Int32 nParameterIndex, while (xBlob->length() - nDataWritten > 0) { sal_uInt64 nDataRemaining = xBlob->length() - nDataWritten; - sal_uInt16 nWriteSize = (nDataRemaining > SAL_MAX_UINT16) ? SAL_MAX_UINT16 : nDataRemaining; + sal_uInt16 nWriteSize = std::min<sal_uInt64>(nDataRemaining, SAL_MAX_UINT16); aErr = isc_put_segment(m_statusVector, &aBlobHandle, nWriteSize, @@ -802,7 +802,7 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex, while (xBytes.getLength() - nDataWritten > 0) { sal_uInt64 nDataRemaining = xBytes.getLength() - nDataWritten; - sal_uInt16 nWriteSize = (nDataRemaining > SAL_MAX_UINT16) ? SAL_MAX_UINT16 : nDataRemaining; + sal_uInt16 nWriteSize = std::min<sal_uInt64>(nDataRemaining, SAL_MAX_UINT16); aErr = isc_put_segment(m_statusVector, &aBlobHandle, nWriteSize, diff --git a/connectivity/source/drivers/postgresql/pq_resultset.cxx b/connectivity/source/drivers/postgresql/pq_resultset.cxx index 3839e72e3a73..85be755818d6 100644 --- a/connectivity/source/drivers/postgresql/pq_resultset.cxx +++ b/connectivity/source/drivers/postgresql/pq_resultset.cxx @@ -257,7 +257,7 @@ sal_Int32 ResultSet::guessDataType( sal_Int32 column ) // we don't look into more than 100 rows ... sal_Int32 ret = css::sdbc::DataType::INTEGER; - int maxRows = ( m_rowCount > 100 ? 100 : m_rowCount ); + int maxRows = std::min<sal_Int32>( m_rowCount, 100 ); for( int i = 0 ; i < maxRows ; i ++ ) { if( ! PQgetisnull( m_result, i , column-1 ) ) |