Kaydet (Commit) b42094b2 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

remove use of SAL_MIN() macro

Change-Id: Ia91118388240c9a54d010b94aef34ad528ce5761
üst e50ab7bb
......@@ -258,7 +258,11 @@ inline sal_uInt32 writeUtf8(sal_uInt8* buffer, const sal_Char* v)
inline sal_uInt32 readUtf8(const sal_uInt8* buffer, sal_Char* v, sal_uInt32 maxSize)
{
sal_uInt32 size = SAL_MIN(strlen((const sal_Char*) buffer) + 1, maxSize);
sal_uInt32 size = strlen((const sal_Char*) buffer) + 1;
if(size > maxSize)
{
size = maxSize;
}
memcpy(v, buffer, size);
......
......@@ -116,10 +116,15 @@ sal_uInt32 writeString(sal_uInt8* buffer, const sal_Unicode* v)
sal_uInt32 readString(const sal_uInt8* buffer, sal_Unicode* v, sal_uInt32 maxSize)
{
sal_uInt32 len = SAL_MIN(UINT16StringLen(buffer) + 1, maxSize / 2);
sal_uInt32 len = UINT16StringLen(buffer) + 1;
sal_uInt32 i;
sal_uInt8* buff = (sal_uInt8*)buffer;
if(len > maxSize / 2)
{
len = maxSize / 2;
}
for (i = 0; i < (len - 1); i++)
{
sal_uInt16 aChar;
......@@ -615,8 +620,9 @@ void MethodEntry::reallocParams(sal_uInt16 size)
if (m_paramCount)
{
sal_uInt16 i;
sal_uInt16 mn = size < m_paramCount ? size : m_paramCount;
for (i = 0; i < SAL_MIN(size, m_paramCount); i++)
for (i = 0; i < mn; i++)
{
newParams[i].setData(m_params[i].m_typeName, m_params[i].m_name, m_params[i].m_mode);
}
......@@ -638,8 +644,9 @@ void MethodEntry::reallocExcs(sal_uInt16 size)
newExcNames = NULL;
sal_uInt16 i;
sal_uInt16 mn = size < m_excCount ? size : m_excCount;
for (i = 0; i < SAL_MIN(size, m_excCount); i++)
for (i = 0; i < mn; i++)
{
newExcNames[i] = m_excNames[i];
}
......
......@@ -32,10 +32,6 @@
#include <stddef.h>
#ifndef SAL_MIN
# define SAL_MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef SAL_N_ELEMENTS
# if defined(__cplusplus) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
/*
......
......@@ -179,7 +179,7 @@ cpyBootstrapSocketPath(sal_Char *name, size_t len)
OUSTRING_TO_OSTRING_CVTFLAGS);
if (pStrValue && pStrValue->length > 0)
{
size_t nCopy = SAL_MIN (len-1, (size_t)pStrValue->length);
size_t nCopy = (len-1 < (size_t)pStrValue->length) ? len-1 : (size_t)pStrValue->length;
strncpy (name, pStrValue->buffer, nCopy);
name[nCopy] = '\0';
bRet = (size_t)pStrValue->length < len;
......
......@@ -327,7 +327,7 @@ static sal_Bool SAL_CALL osl_psz_getHomeDir(oslSecurity Security, sal_Char* pszD
OUSTRING_TO_OSTRING_CVTFLAGS);
if (pStrValue && pStrValue->length > 0)
{
sal_Int32 nCopy = SAL_MIN ((sal_Int32)(nMax-1), pStrValue->length);
sal_Int32 nCopy = (sal_Int32)(nMax-1) < pStrValue->length ? (sal_Int32)(nMax-1) : pStrValue->length ;
strncpy (pszDirectory, pStrValue->buffer, nCopy);
pszDirectory[nCopy] = '\0';
bRet = (size_t)pStrValue->length < nMax;
......
......@@ -658,7 +658,10 @@ rtl_cache_depot_dequeue (
/* update depot stats */
depot->m_mag_count--;
depot->m_curr_min = SAL_MIN(depot->m_curr_min, depot->m_mag_count);
if(depot->m_curr_min > depot->m_mag_count)
{
depot->m_curr_min = depot->m_mag_count;
}
}
return (mag);
}
......@@ -1470,7 +1473,7 @@ rtl_cache_depot_wsupdate (
depot->m_prev_min = depot->m_curr_min;
depot->m_curr_min = depot->m_mag_count;
npurge = SAL_MIN(depot->m_curr_min, depot->m_prev_min);
npurge = depot->m_curr_min < depot->m_prev_min ? depot->m_curr_min : depot->m_prev_min;
for (; npurge > 0; npurge--)
{
rtl_cache_magazine_type * mag = rtl_cache_depot_dequeue (depot);
......
......@@ -170,7 +170,7 @@ void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXT
p = rtl_allocateMemory (n);
if (p != 0)
{
memcpy (p, p_old, SAL_MIN(n, n_old));
memcpy (p, p_old, (n < n_old) ? n : n_old);
rtl_freeMemory (p_old);
}
}
......
......@@ -732,11 +732,11 @@ public:
return rtl_crc32 (nPath, pszName, rtl_str_getLength(pszName));
}
sal_Size getName (sal_Char * pBuffer, sal_Size nBufsiz) const
sal_Size getName (sal_Char * pBuffer, sal_Size nBufsize) const
{
sal_Char const * pszName = PAGE().m_aNameBlock.m_pData;
sal_Size nLength = rtl_str_getLength(pszName);
memcpy (pBuffer, pszName, SAL_MIN(nLength, nBufsiz));
memcpy (pBuffer, pszName, nLength < nBufsize ? nLength : nBufsize);
return nLength;
}
......
......@@ -167,8 +167,10 @@ storeError OStoreLockBytes::readAt (
nOffset, m_xNode->capacity());
sal_uInt32 nLength = sal_uInt32(aDescr.m_nLength);
nLength = SAL_MIN(nLength, nBytes);
if(nLength > nBytes)
{
nLength = nBytes;
}
memcpy (
&pData[rnDone],
&m_xNode->m_pData[aDescr.m_nOffset],
......@@ -186,7 +188,10 @@ storeError OStoreLockBytes::readAt (
nOffset - m_xNode->capacity(), OStoreDataPageData::capacity(m_xNode->m_aDescr)); // @@@
sal_uInt32 nLength = sal_uInt32(aDescr.m_nLength);
nLength = SAL_MIN(nLength, nBytes);
if(nLength > nBytes)
{
nLength = nBytes;
}
storeError eErrCode = aPage.read (aDescr.m_nPage, aData, *m_xManager);
if (eErrCode != store_E_None)
......@@ -259,7 +264,10 @@ storeError OStoreLockBytes::writeAt (
nOffset, m_xNode->capacity());
sal_uInt32 nLength = sal_uInt32(aDescr.m_nLength);
nLength = SAL_MIN(nLength, nBytes);
if(nLength > nBytes)
{
nLength = nBytes;
}
memcpy (
&m_xNode->m_pData[aDescr.m_nOffset],
......@@ -312,7 +320,10 @@ storeError OStoreLockBytes::writeAt (
}
// Modify data page.
nLength = SAL_MIN(nLength, nBytes);
if(nLength > nBytes)
{
nLength = nBytes;
}
memcpy (
&xData->m_pData[aDescr.m_nOffset],
&pData[rnDone], nLength);
......
......@@ -1415,7 +1415,10 @@ ErrCode UcbLockBytes::ReadAt ( sal_uLong nPos, void *pBuffer, sal_uLong nCount,
Sequence<sal_Int8> aData;
sal_Int32 nSize;
nCount = SAL_MIN(nCount, 0x7FFFFFFF);
if(nCount > 0x7FFFFFFF)
{
nCount = 0x7FFFFFFF;
}
try
{
if ( !m_bTerminated && !IsSynchronMode() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment