diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-14 10:46:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-14 15:14:27 +0200 |
commit | 546c35519125a769755330c961c7b8fc61e24d89 (patch) | |
tree | 0b73735081bd279b89b93dabc5c35dee6ec08b94 /sal | |
parent | 92b7acdf2a1159af8a31da22ce6227950f709040 (diff) |
use more SAL_N_ELEMENTS part 2
Change-Id: If00e371c3cd3ae616309a172c875faed016e391b
Reviewed-on: https://gerrit.libreoffice.org/38773
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/signal.cxx | 2 | ||||
-rw-r--r-- | sal/qa/rtl/digest/rtl_digest.cxx | 19 | ||||
-rw-r--r-- | sal/qa/rtl/oustring/rtl_OUString2.cxx | 4 | ||||
-rw-r--r-- | sal/qa/rtl/textenc/rtl_textcvt.cxx | 2 | ||||
-rw-r--r-- | sal/qa/rtl/uri/rtl_testuri.cxx | 3 | ||||
-rw-r--r-- | sal/textenc/convertadobe.tab | 2 | ||||
-rw-r--r-- | sal/textenc/convertsimple.cxx | 4 |
7 files changed, 14 insertions, 22 deletions
diff --git a/sal/osl/unx/signal.cxx b/sal/osl/unx/signal.cxx index f4c9a9ce5171..bc13b7947e8b 100644 --- a/sal/osl/unx/signal.cxx +++ b/sal/osl/unx/signal.cxx @@ -134,7 +134,7 @@ what looks like a bug in the new handler*/ { SIGXCPU, ACT_ABORT, SIG_DFL, false }, /* exceeded cpu limit */ { SIGXFSZ, ACT_ABORT, SIG_DFL, false } /* exceeded file size limit */ }; -const int NoSignals = sizeof(Signals) / sizeof(struct SignalAction); +const int NoSignals = SAL_N_ELEMENTS(Signals); bool bSetSEGVHandler = false; bool bSetWINCHHandler = false; diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx index b61ce9be3fcd..f5c088b6c3ad 100644 --- a/sal/qa/rtl/digest/rtl_digest.cxx +++ b/sal/qa/rtl/digest/rtl_digest.cxx @@ -109,9 +109,7 @@ class DigestTest : public CppUnit::TestFixture public: void testCreate() { - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); - - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { rtlDigest handle = rtl_digest_create( constDigestAlgorithms[i] ); CPPUNIT_ASSERT_MESSAGE("create digest", handle != nullptr); @@ -125,9 +123,7 @@ public: void testQuery() { - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); - - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { rtlDigest handle = rtl_digest_create(constDigestAlgorithms[i]); rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle); @@ -139,11 +135,10 @@ public: void testQueryLength() { - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); rtlDigest handle; sal_uInt32 nAlgoLength; - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { handle = rtl_digest_create(constDigestAlgorithms[i]); nAlgoLength = rtl_digest_queryLength(handle); @@ -171,9 +166,7 @@ public: CPPUNIT_ASSERT_EQUAL_MESSAGE("init(handle, 0, 0)", rtl_Digest_E_None, aError); rtl_digest_destroy( handle ); - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); - - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { handle = rtl_digest_create(constDigestAlgorithms[i]); @@ -223,9 +216,7 @@ public: void testCheckSum() { - int aAlgorithmSize = sizeof(constDigestAlgorithms) / sizeof(constDigestAlgorithms[0]); - - for (int i = 0; i < aAlgorithmSize; i++) + for (size_t i = 0; i < SAL_N_ELEMENTS(constDigestAlgorithms); i++) { OString aSum = getDigest(sSampleString, constDigestAlgorithms[i]); CPPUNIT_ASSERT_EQUAL_MESSAGE("Checksum of sample string is wrong.", constSampleStringSums[i], aSum); diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx index 15748fcf8d2f..c345bc31b8bb 100644 --- a/sal/qa/rtl/oustring/rtl_OUString2.cxx +++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx @@ -987,7 +987,7 @@ void createFromCodePoints::test() { sal_Int32(0), rtl::OUString(static_cast< sal_uInt32 const * >(nullptr), 0).getLength()); static sal_uInt32 const cp[] = { 0, 0xD800, 0xFFFF, 0x10000, 0x10FFFF }; - rtl::OUString s(cp, sizeof cp / sizeof (sal_uInt32)); + rtl::OUString s(cp, SAL_N_ELEMENTS(cp)); CPPUNIT_ASSERT_EQUAL(sal_Int32(7), s.getLength()); CPPUNIT_ASSERT_EQUAL(u'\0', s[0]); CPPUNIT_ASSERT_EQUAL(u'\xD800', s[1]); @@ -1010,7 +1010,7 @@ public: void iterateCodePoints::testNotWellFormed() { static sal_Unicode const utf16[] = { 0xD800, 0xDC00, 0x0041, 0xDBFF, 0xDFFF, 0xDDEF, 0xD9AB }; - rtl::OUString s(utf16, sizeof utf16 / sizeof (sal_Unicode)); + rtl::OUString s(utf16, SAL_N_ELEMENTS(utf16)); sal_Int32 i = 0; CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10000), s.iterateCodePoints(&i)); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), i); diff --git a/sal/qa/rtl/textenc/rtl_textcvt.cxx b/sal/qa/rtl/textenc/rtl_textcvt.cxx index c9d7e5f08117..34e5208ae890 100644 --- a/sal/qa/rtl/textenc/rtl_textcvt.cxx +++ b/sal/qa/rtl/textenc/rtl_textcvt.cxx @@ -2678,7 +2678,7 @@ void Test::testSRCBUFFERTOSMALL() { CPPUNIT_ASSERT_EQUAL( sal_Size(0), rtl_convertTextToUnicode( - cv, cx, &src, 1, dst, sizeof dst / sizeof (sal_Unicode), + cv, cx, &src, 1, dst, SAL_N_ELEMENTS(dst), (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR), diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx index e60797731d2f..ac0728413b1d 100644 --- a/sal/qa/rtl/uri/rtl_testuri.cxx +++ b/sal/qa/rtl/uri/rtl_testuri.cxx @@ -335,7 +335,8 @@ void Test::test_Uri() { { "http://a/b/c", "d", "http://a/b/d" }, { "http://a/b/c/", "d", "http://a/b/c/d" }, { "http://a/b/c//", "d", "http://a/b/c//d" } }; - for (std::size_t i = 0; i < sizeof aRelToAbsTest / sizeof (RelToAbsTest); ++i) + + for (std::size_t i = 0; i < SAL_N_ELEMENTS(aRelToAbsTest); ++i) { rtl::OUString aAbs; bool bMalformed = false; diff --git a/sal/textenc/convertadobe.tab b/sal/textenc/convertadobe.tab index 37cf080a4130..568ccd6be44b 100644 --- a/sal/textenc/convertadobe.tab +++ b/sal/textenc/convertadobe.tab @@ -281,7 +281,7 @@ adobeDingbatsEncodingConverterData = { 0x27A8, 0x27A9, 0x27AA, 0x27AB, 0x27AC, 0x27AD, 0x27AE, 0x27AF, 0xFFFF, 0x27B1, 0x27B2, 0x27B3, 0x27B4, 0x27B5, 0x27B6, 0x27B7, // 0xF0 0x27B8, 0x27B9, 0x27BA, 0x27BB, 0x27BC, 0x27BD, 0x27BE, 0xFFFF }, - (sizeof(unicodeToAdobeDingbatsEncoding) / sizeof(*unicodeToAdobeDingbatsEncoding)), + SAL_N_ELEMENTS(unicodeToAdobeDingbatsEncoding), unicodeToAdobeDingbatsEncoding }; ImplTextEncodingData const adobeStandardEncodingData diff --git a/sal/textenc/convertsimple.cxx b/sal/textenc/convertsimple.cxx index 99689f6d3d32..507e20907346 100644 --- a/sal/textenc/convertsimple.cxx +++ b/sal/textenc/convertsimple.cxx @@ -326,7 +326,7 @@ sal_uInt16 ImplGetReplaceChar( sal_Unicode c ) const ImplReplaceCharData* pCharData; nLow = 0; - nHigh = (sizeof( aImplRepCharTab )/sizeof( ImplReplaceCharData ))-1; + nHigh = SAL_N_ELEMENTS( aImplRepCharTab ) - 1; do { nMid = (nLow+nHigh)/2; @@ -418,7 +418,7 @@ const sal_uInt16* ImplGetReplaceString( sal_Unicode c ) const ImplReplaceCharStrData* pCharData; nLow = 0; - nHigh = (sizeof( aImplRepCharStrTab )/sizeof( ImplReplaceCharStrData ))-1; + nHigh = SAL_N_ELEMENTS( aImplRepCharStrTab ) - 1; do { nMid = (nLow+nHigh)/2; |