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 /sal | |
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 'sal')
-rw-r--r-- | sal/osl/unx/profile.cxx | 2 | ||||
-rw-r--r-- | sal/osl/unx/security.cxx | 2 | ||||
-rw-r--r-- | sal/osl/w32/profile.cxx | 2 | ||||
-rw-r--r-- | sal/rtl/alloc_cache.cxx | 3 | ||||
-rw-r--r-- | sal/rtl/alloc_global.cxx | 2 | ||||
-rw-r--r-- | sal/rtl/cipher.cxx | 3 | ||||
-rw-r--r-- | sal/rtl/math.cxx | 2 | ||||
-rw-r--r-- | sal/rtl/ustring.cxx | 2 |
8 files changed, 10 insertions, 8 deletions
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx index fa44ea934e5f..9eee8ce54e0e 100644 --- a/sal/osl/unx/profile.cxx +++ b/sal/osl/unx/profile.cxx @@ -1252,7 +1252,7 @@ static sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Line, sa } } - LineNo = LineNo > pProfile->m_NoLines ? pProfile->m_NoLines : LineNo; + LineNo = std::min(LineNo, pProfile->m_NoLines); if (LineNo < pProfile->m_NoLines) { diff --git a/sal/osl/unx/security.cxx b/sal/osl/unx/security.cxx index e0d0ad210ed1..bdd9db6b7b94 100644 --- a/sal/osl/unx/security.cxx +++ b/sal/osl/unx/security.cxx @@ -263,7 +263,7 @@ static bool osl_psz_getHomeDir(oslSecurity Security, sal_Char* pszDirectory, sal OUSTRING_TO_OSTRING_CVTFLAGS); if (pStrValue && pStrValue->length > 0) { - sal_Int32 nCopy = (sal_Int32)(nMax-1) < pStrValue->length ? (sal_Int32)(nMax-1) : pStrValue->length ; + sal_Int32 nCopy = (sal_Int32)std::min(nMax-1, pStrValue->length) ; strncpy (pszDirectory, pStrValue->buffer, nCopy); pszDirectory[nCopy] = '\0'; bRet = (std::size_t)pStrValue->length < nMax; diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx index 96dc7fcdbcec..d4e0ed6e5dbb 100644 --- a/sal/osl/w32/profile.cxx +++ b/sal/osl/w32/profile.cxx @@ -1374,7 +1374,7 @@ static const sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Li } } - LineNo = LineNo > pProfile->m_NoLines ? pProfile->m_NoLines : LineNo; + LineNo = std::min(LineNo, pProfile->m_NoLines); if (LineNo < pProfile->m_NoLines) { diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx index 6a3eea86d6a0..d9aeb7edcc77 100644 --- a/sal/rtl/alloc_cache.cxx +++ b/sal/rtl/alloc_cache.cxx @@ -31,6 +31,7 @@ #if defined(SAL_UNX) #include <sys/time.h> #endif +#include <algorithm> /** * @internal @@ -1283,7 +1284,7 @@ static void rtl_cache_depot_wsupdate( depot->m_prev_min = depot->m_curr_min; depot->m_curr_min = depot->m_mag_count; - npurge = depot->m_curr_min < depot->m_prev_min ? depot->m_curr_min : depot->m_prev_min; + npurge = std::min(depot->m_curr_min, depot->m_prev_min); for (; npurge > 0; npurge--) { rtl_cache_magazine_type * mag = rtl_cache_depot_dequeue (depot); diff --git a/sal/rtl/alloc_global.cxx b/sal/rtl/alloc_global.cxx index 25e2c1ea78b6..efbd2748dbf8 100644 --- a/sal/rtl/alloc_global.cxx +++ b/sal/rtl/alloc_global.cxx @@ -137,7 +137,7 @@ void * rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXTERN_C() p = rtl_allocateMemory (n); if (p) { - memcpy (p, p_old, (n < n_old) ? n : n_old); + memcpy (p, p_old, std::min(n, n_old)); rtl_freeMemory (p_old); } } diff --git a/sal/rtl/cipher.cxx b/sal/rtl/cipher.cxx index 9a64ac4364b0..62f3104be3ed 100644 --- a/sal/rtl/cipher.cxx +++ b/sal/rtl/cipher.cxx @@ -22,6 +22,7 @@ #include <sal/types.h> #include <rtl/alloc.h> #include <rtl/cipher.h> +#include <algorithm> #define RTL_CIPHER_NTOHL(c, l) \ ((l) = (static_cast<sal_uInt32>(*((c)++))) << 24, \ @@ -660,7 +661,7 @@ static rtlCipherError BF_init( if (pArgData && nArgLen) { - nArgLen = ((nArgLen < 8) ? nArgLen : 8); + nArgLen = std::min<sal_Size>(nArgLen, 8); if (eMode == rtl_Cipher_ModeStream) { memcpy(ctx->m_iv.m_byte, pArgData, nArgLen); diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx index f8a0f9dcec47..4b149b9f99dd 100644 --- a/sal/rtl/math.cxx +++ b/sal/rtl/math.cxx @@ -443,7 +443,7 @@ inline void doubleToString(typename T::String ** pResult, // Round the number if(nDigits >= 0) { - if ((fValue += nRoundVal[nDigits > 15 ? 15 : nDigits] ) >= 10) + if ((fValue += nRoundVal[std::min<sal_Int32>(nDigits, 15)] ) >= 10) { fValue = 1.0; nExp++; diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx index d562c7c736a1..64fb1c3edd39 100644 --- a/sal/rtl/ustring.cxx +++ b/sal/rtl/ustring.cxx @@ -436,7 +436,7 @@ sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths( { assert(firstLen >= 0 && secondLen >= 0); sal_Int32 i; - sal_Int32 len = firstLen < secondLen ? firstLen : secondLen; + sal_Int32 len = std::min(firstLen, secondLen); for (i = 0; i < len; ++i) { /* Check ASCII range */ SAL_WARN_IF( (static_cast<unsigned char>(*second)) > 127, "rtl.string", |