diff options
-rw-r--r-- | sal/osl/os2/file.cxx | 5 | ||||
-rw-r--r-- | sal/osl/os2/profile.c | 16 | ||||
-rw-r--r-- | sal/osl/unx/signal.c | 11 | ||||
-rw-r--r-- | sal/qa/rtl/textenc/rtl_textcvt.cxx | 13 | ||||
-rw-r--r-- | sal/rtl/source/uri.cxx | 5 | ||||
-rw-r--r-- | stoc/test/uriproc/test_uriproc.cxx | 15 | ||||
-rw-r--r-- | store/source/storcach.cxx | 3 | ||||
-rw-r--r-- | ure/source/uretest/cppmain.cc | 5 |
8 files changed, 38 insertions, 35 deletions
diff --git a/sal/osl/os2/file.cxx b/sal/osl/os2/file.cxx index 78243e766..349d9f592 100644 --- a/sal/osl/os2/file.cxx +++ b/sal/osl/os2/file.cxx @@ -54,6 +54,7 @@ #include <osl/diagnose.h> #include "file_error_transl.h" #include <osl/time.h> +#include <sal/macros.h> #include "file_url.h" @@ -130,12 +131,10 @@ extern "C" oslFileHandle osl_createFileHandleFromFD( int fd ); //{ ERROR_NOT_ENOUGH_QUOTA, osl_File_E_NOMEM } /* 1816 */ }; - #define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0]))) - //##################################################### oslFileError MapError(APIRET dwError) { - for (int i = 0; i < ELEMENTS_OF_ARRAY(errtable); ++i ) + for (int i = 0; i < SAL_N_ELEMENTS(errtable); ++i ) { if (dwError == errtable[i].oscode) return static_cast<oslFileError>(errtable[i].errnocode); diff --git a/sal/osl/os2/profile.c b/sal/osl/os2/profile.c index ca2e70c2c..85c46d680 100644 --- a/sal/osl/os2/profile.c +++ b/sal/osl/os2/profile.c @@ -26,8 +26,7 @@ ************************************************************************/ #include "system.h" - -// YD #define min(a,b) (((a) < (b)) ? (a) : (b)) +#include <sal/macros.h> #include <osl/security.h> #include <osl/diagnose.h> @@ -1347,7 +1346,7 @@ static sal_Bool getLine(osl_TFile* pFile, const sal_Char *pszLine, int MaxLen) (pChr < (pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf) - 1)); pChr++); - Max = min(pChr - pFile->m_pReadPtr, MaxLen); + Max = SAL_MIN(pChr - pFile->m_pReadPtr, MaxLen); memcpy(pLine, pFile->m_pReadPtr, Max); MaxLen -= Max; pLine += Max; @@ -1986,7 +1985,6 @@ static sal_Bool releaseProfile(osl_TProfileImpl* pProfile) } #if 0 // YD - static sal_Bool lookupProfile(const sal_Char *pszPath, const sal_Char *pszFile, sal_Char *pPath) { sal_Char *pChr, *pStr; @@ -2023,7 +2021,7 @@ static sal_Bool lookupProfile(const sal_Char *pszPath, const sal_Char *pszFile, oslProfile hProfile; /* open sversion.ini in the system directory, and try to locate the entry - with the highest version for StarOffice */ + with the highest version for StarOffice */ if ((osl_getProfileName(SVERSION_FALLBACK, SVERSION_NAME, Profile, sizeof(Profile))) && (hProfile = osl_openProfile(Profile, osl_Profile_READLOCK))) { @@ -2048,7 +2046,7 @@ static sal_Bool lookupProfile(const sal_Char *pszPath, const sal_Char *pszFile, } /* open sversion.ini in the users directory, and try to locate the entry - with the highest version for StarOffice */ + with the highest version for StarOffice */ if ((strcmp(SVERSION_LOCATION, SVERSION_FALLBACK) != 0) && (osl_getProfileName(SVERSION_LOCATION, SVERSION_NAME, Profile, sizeof(Profile))) && (hProfile = osl_openProfile(Profile, osl_Profile_READLOCK))) @@ -2075,7 +2073,7 @@ static sal_Bool lookupProfile(const sal_Char *pszPath, const sal_Char *pszFile, /* remove any trailing build number */ if ((pChr = strrchr(Product, '/')) != NULL) - *pChr = '\0'; + *pChr = '\0'; } } @@ -2169,7 +2167,7 @@ static sal_Bool lookupProfile(const sal_Char *pszPath, const sal_Char *pszFile, int i = 0; - for (i = 0; i < (sizeof(SubDirs) / sizeof(SubDirs[0])); i++) + for (i = 0; i < SAL_N_ELEMENTS(SubDirs); i++) if (strnicmp(pStr + 1, SubDirs[i], strlen(SubDirs[i])) == 0) { if ( strlen(pszPath) <= 0) @@ -2203,7 +2201,7 @@ static sal_Bool lookupProfile(const sal_Char *pszPath, const sal_Char *pszFile, *pChr = '\0'; /* open sversion.ini in the system directory, and try to locate the entry - with the highest version for StarOffice */ + with the highest version for StarOffice */ if ((osl_getProfileName(SVERSION_LOCATION, SVERSION_NAME, Profile, sizeof(Profile))) && (hProfile = osl_openProfile(Profile, osl_Profile_READLOCK))) { diff --git a/sal/osl/unx/signal.c b/sal/osl/unx/signal.c index 3f81f2d6c..0d5ee2b1b 100644 --- a/sal/osl/unx/signal.c +++ b/sal/osl/unx/signal.c @@ -68,6 +68,7 @@ #include <osl/signal.h> #include <osl/process.h> #include <osl/thread.h> +#include <sal/macros.h> #include <rtl/bootstrap.h> #include <rtl/digest.h> @@ -572,7 +573,7 @@ static int ReportCrash( int Signal ) void *stackframes[MAX_STACK_FRAMES]; int iFrame; - int nFrames = backtrace( stackframes, sizeof(stackframes)/sizeof(stackframes[0])); + int nFrames = backtrace( stackframes, SAL_N_ELEMENTS(stackframes); FILE *xmlout = NULL, *stackout = NULL, *checksumout = NULL; int fdxml, fdstk, fdchksum; @@ -755,7 +756,7 @@ static int ReportCrash( int Signal ) rtl_uString_release(crashrep_url); rtl_uString_release(crashrep_path); #if defined INCLUDE_BACKTRACE && (defined LINUX || defined MACOSX) - snprintf( szShellCmd, sizeof(szShellCmd)/sizeof(szShellCmd[0]), + snprintf( szShellCmd, SAL_N_ELEMENTS(szShellCmd), "%s -p %d -s %d -xml %s -chksum %s -stack %s -noui%s", rtl_string_getStr(crashrep_path_system), getpid(), @@ -765,7 +766,7 @@ static int ReportCrash( int Signal ) pStackTempName, bAutoCrashReport ? " -send" : "" ); #elif defined INCLUDE_BACKTRACE && defined SOLARIS - snprintf( szShellCmd, sizeof(szShellCmd)/sizeof(szShellCmd[0]), + snprintf( szShellCmd, SAL_N_ELEMENTS(szShellCmd), "%s -p %d -s %d -xml %s -chksum %s -noui%s", rtl_string_getStr(crashrep_path_system), getpid(), @@ -774,7 +775,7 @@ static int ReportCrash( int Signal ) pChecksumTempName, bAutoCrashReport ? " -send" : "" ); #else - snprintf( szShellCmd, sizeof(szShellCmd)/sizeof(szShellCmd[0]), + snprintf( szShellCmd, SAL_N_ELEMENTS(szShellCmd), "%s -p %d -s %d -noui%s", rtl_string_getStr(crashrep_path_system), getpid(), Signal, bAutoCrashReport ? " -send" : "" ); @@ -820,7 +821,7 @@ static void PrintStack( int sig ) { #if ! defined(MACOSX) || defined(INCLUDE_BACKTRACE) void *buffer[MAX_STACK_FRAMES]; - int size = backtrace( buffer, sizeof(buffer) / sizeof(buffer[0]) ); + int size = backtrace( buffer, SAL_N_ELEMENTS(buffer) ); #endif fprintf( stderr, "\n\nFatal exception: Signal %d\n", sig ); diff --git a/sal/qa/rtl/textenc/rtl_textcvt.cxx b/sal/qa/rtl/textenc/rtl_textcvt.cxx index 2d35b6ebf..5adafc5ee 100644 --- a/sal/qa/rtl/textenc/rtl_textcvt.cxx +++ b/sal/qa/rtl/textenc/rtl_textcvt.cxx @@ -40,6 +40,7 @@ #include "rtl/textcvt.h" #include "rtl/textenc.h" #include "sal/types.h" +#include <sal/macros.h> namespace { @@ -1278,7 +1279,7 @@ void Test::testSingleByte() { 0x0438,0x0439,0x043A,0x043B,0x043C,0x043D,0x043E,0x043F, 0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447, 0x0448,0x0449,0x044A,0x044B,0x044C,0x044D,0x044E,0x044F } } }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { testSingleByteCharSet(data[i]); } } @@ -2506,7 +2507,7 @@ void Test::testComplex() { false, RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR } }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { doComplexCharSetTest(data[i]); } } @@ -2594,7 +2595,7 @@ void Test::testComplexCut() { false, false, RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR } */ }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { doComplexCharSetCutTest(data[i]); } } @@ -2721,7 +2722,7 @@ void Test::testMime() { { "CP154", RTL_TEXTENCODING_PT154, false }, { "Cyrillic-Asian", RTL_TEXTENCODING_PT154, false } }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { if (data[i].mime == 0) { OSL_ASSERT(data[i].reverse); CPPUNIT_ASSERT_EQUAL( @@ -2821,7 +2822,7 @@ void Test::testWindows() { { 0, RTL_TEXTENCODING_UCS2, true }, { 0, RTL_TEXTENCODING_ISCII_DEVANAGARI, true } }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { OSL_ASSERT(data[i].codePage != 0 || data[i].reverse); if (data[i].codePage != 0) { CPPUNIT_ASSERT_EQUAL( @@ -2887,7 +2888,7 @@ void Test::testInfo() { { RTL_TEXTENCODING_PT154, RTL_TEXTENCODING_INFO_ASCII, true }, { RTL_TEXTENCODING_PT154, RTL_TEXTENCODING_INFO_MIME, true } }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { rtl_TextEncodingInfo info; info.StructSize = sizeof info; CPPUNIT_ASSERT(rtl_getTextEncodingInfo(data[i].encoding, &info)); diff --git a/sal/rtl/source/uri.cxx b/sal/rtl/source/uri.cxx index 8ada853c9..f06a7e5a5 100644 --- a/sal/rtl/source/uri.cxx +++ b/sal/rtl/source/uri.cxx @@ -43,6 +43,7 @@ #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" +#include "sal/macros.h" #include <cstddef> @@ -198,7 +199,7 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd, sal_Size nConverted; sal_Size nDstSize = rtl_convertTextToUnicode( aConverter, 0, aBuf.getStr(), aBuf.getLength(), aDst, - sizeof aDst / sizeof aDst[0], + SAL_N_ELEMENTS( aDst ), (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR), @@ -592,7 +593,7 @@ sal_Bool const * SAL_CALL rtl_getUriCharClass(rtl_UriCharClass eCharClass) OSL_ENSURE( (eCharClass >= 0 && (sal::static_int_cast< std::size_t >(eCharClass) - < sizeof aCharClass / sizeof aCharClass[0])), + < SAL_N_ELEMENTS(aCharClass))), "bad eCharClass"); return aCharClass[eCharClass]; } diff --git a/stoc/test/uriproc/test_uriproc.cxx b/stoc/test/uriproc/test_uriproc.cxx index ee7d02aca..fb6fb1b09 100644 --- a/stoc/test/uriproc/test_uriproc.cxx +++ b/stoc/test/uriproc/test_uriproc.cxx @@ -55,6 +55,7 @@ #include "rtl/ustrbuf.hxx" #include "rtl/ustring.hxx" #include "sal/types.h" +#include <sal/macros.h> #include <cstdlib> @@ -205,7 +206,7 @@ void Test::testParse() { "/", false, 1, "", "", "", "", "", 0, 0 }, { "////", 0, "////", true, "", "//", false, 2, "", "", "", "", "", 0, 0 } }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { css::uno::Reference< css::uri::XUriReference > uriRef( m_uriFactory->parse( rtl::OUString::createFromAscii(data[i].uriReference))); @@ -595,7 +596,7 @@ void Test::testMakeAbsolute() { css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s" }, { "scheme://a#s1", "#s2", true, css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s2" } }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { css::uno::Reference< css::uri::XUriReference > baseUriRef( m_uriFactory->parse( rtl::OUString::createFromAscii(data[i].baseUriReference))); @@ -700,7 +701,7 @@ void Test::testMakeRelative() { 0 }, { "scheme://auth/a/b", "scheme://auth/c/d", true, false, false, "../c/d", 0 } }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { css::uno::Reference< css::uri::XUriReference > baseUriRef( m_uriFactory->parse( rtl::OUString::createFromAscii(data[i].baseUriReference))); @@ -753,7 +754,7 @@ void Test::testVndSunStarExpand() { RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.util.theMacroExpander"))), css::uno::UNO_QUERY_THROW); - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { css::uno::Reference< css::uri::XUriReference > uriRef( m_uriFactory->parse( rtl::OUString::createFromAscii(data[i].uriReference))); @@ -793,7 +794,7 @@ void Test::testVndSunStarScript() { { "vnd.sun.star.script:name?a=&", 0, true, {} }, { "vnd.sun.star.script:name?key1=&%26=%3D&key1=hello", "name", true, { { "key1", "" }, { "key2", 0 }, { "&", "=" } } } }; - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { css::uno::Reference< css::uri::XUriReference > uriRef( m_uriFactory->parse( rtl::OUString::createFromAscii(data[i].uriReference))); @@ -950,7 +951,7 @@ void Test::testTranslator() { { "file:///abc/%25ef", "file:///abc/%25ef", true } }; css::uno::Reference< css::uri::XExternalUriReferenceTranslator > translator(css::uri::ExternalUriReferenceTranslator::create(m_context)); - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { if (data[i].toInternal) { TEST_ASSERT_EQUAL( "testTranslator, translateToInternal", i, @@ -981,7 +982,7 @@ void Test::testPkgUrlFactory() { "vnd.sun.star.pkg://file:%2F%2F%2Fa%2525b%252fc%2Fd~e&f@g%3Fh" } }; css::uno::Reference< css::uri::XVndSunStarPkgUrlReferenceFactory > factory( css::uri::VndSunStarPkgUrlReferenceFactory::create(m_context)); - for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) { css::uno::Reference< css::uri::XUriReference > url( factory->createVndSunStarPkgUrlReference( m_uriFactory->parse( diff --git a/store/source/storcach.cxx b/store/source/storcach.cxx index 201f99753..81863fc13 100644 --- a/store/source/storcach.cxx +++ b/store/source/storcach.cxx @@ -32,6 +32,7 @@ #include "storcach.hxx" #include "sal/types.h" +#include "sal/macros.h" #include "rtl/alloc.h" #include "osl/diagnose.h" @@ -342,7 +343,7 @@ PageCache_Impl::PageCache_Impl (sal_uInt16 nPageSize) m_nHit (0), m_nMissed (0) { - static size_t const theSize = sizeof(m_hash_table_0) / sizeof(m_hash_table_0[0]); + static size_t const theSize = SAL_N_ELEMENTS(m_hash_table_0); STORE_STATIC_ASSERT(theSize == theTableSize); memset(m_hash_table_0, 0, sizeof(m_hash_table_0)); } diff --git a/ure/source/uretest/cppmain.cc b/ure/source/uretest/cppmain.cc index 0be81b637..eeb0be153 100644 --- a/ure/source/uretest/cppmain.cc +++ b/ure/source/uretest/cppmain.cc @@ -26,6 +26,7 @@ ************************************************************************/ #include "sal/config.h" +#include "sal/macros.h" #include <cstddef> #include <functional> @@ -179,7 +180,7 @@ private: ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("no service manager")), static_cast< ::cppu::OWeakObject * >(this)); } - for (::std::size_t i = 0; i < sizeof services / sizeof services[0]; ++i) { + for (::std::size_t i = 0; i < SAL_N_ELEMENTS(services); ++i) { ::css::uno::Reference< ::css::uno::XInterface > instance; try { instance = manager->createInstanceWithContext( @@ -200,7 +201,7 @@ private: } static char const * const singletons[] = { "com.sun.star.util.theMacroExpander" }; - for (::std::size_t i = 0; i < sizeof singletons / sizeof singletons[0]; ++i) + for (::std::size_t i = 0; i < SAL_N_ELEMENTS(singletons); ++i) { ::rtl::OUStringBuffer b; b.appendAscii(RTL_CONSTASCII_STRINGPARAM("/singletons/")); |