[Libreoffice-commits] core.git: animations/source binaryurp/qa comphelper/source configmgr/qa connectivity/source cppuhelper/source desktop/inc desktop/source filter/source hwpfilter/source i18npool/source i18nutil/source jvmfwk/plugins libreofficekit/qa

Noel Grandin noel.grandin at collabora.co.uk
Thu Jun 15 06:24:57 UTC 2017


 animations/source/animcore/animcore.cxx                               |    2 -
 binaryurp/qa/test-cache.cxx                                           |    2 -
 comphelper/source/misc/syntaxhighlight.cxx                            |    4 +-
 configmgr/qa/unit/test.cxx                                            |    4 +-
 connectivity/source/drivers/postgresql/pq_statics.cxx                 |   16 ++++----
 cppuhelper/source/bootstrap.cxx                                       |    6 +--
 desktop/inc/dp_misc.h                                                 |    2 -
 desktop/source/deployment/misc/dp_misc.cxx                            |    2 -
 desktop/source/deployment/registry/package/dp_package.cxx             |    6 +--
 filter/source/graphicfilter/ieps/ieps.cxx                             |    6 +--
 filter/source/svg/svgfilter.cxx                                       |    4 +-
 filter/source/svg/tokenmap.cxx                                        |    2 -
 hwpfilter/source/fontmap.cxx                                          |    7 +--
 hwpfilter/source/hbox.cxx                                             |    4 +-
 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |    2 -
 i18npool/source/nativenumber/nativenumbersupplier.cxx                 |   18 +++-------
 i18npool/source/textconversion/textconversion_ko.cxx                  |    8 +---
 i18npool/source/transliteration/numtotext_cjk.cxx                     |    2 -
 i18nutil/source/utility/widthfolding.cxx                              |    8 +---
 jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx                          |    4 +-
 jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx                        |    6 +--
 jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx                      |   12 +++---
 jvmfwk/plugins/sunmajor/pluginlib/util.cxx                            |    6 +--
 jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx                      |    2 -
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx                   |    4 +-
 25 files changed, 62 insertions(+), 77 deletions(-)

New commits:
commit ec8c98f59869bee0e327d32f39480a0e4b1330bc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jun 14 11:31:15 2017 +0200

    use more SAL_N_ELEMENTS part 3
    
    Change-Id: I82e366fefd2e31928b99840fe76649cc3521e623
    Reviewed-on: https://gerrit.libreoffice.org/38789
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/animations/source/animcore/animcore.cxx b/animations/source/animcore/animcore.cxx
index 2d75b522b2f3..05b7a4747970 100644
--- a/animations/source/animcore/animcore.cxx
+++ b/animations/source/animcore/animcore.cxx
@@ -423,7 +423,7 @@ AnimationNode::AnimationNode( sal_Int16 nNodeType )
     mnIterateType( css::presentation::ShapeAnimationSubType::AS_WHOLE ),
     mfIterateInterval(0.0)
 {
-    assert((sal_uInt32)nNodeType < sizeof(mpTypes)/sizeof(Sequence<Type>*));
+    assert(nNodeType < int(SAL_N_ELEMENTS(mpTypes)));
 }
 
 AnimationNode::AnimationNode( const AnimationNode& rNode )
diff --git a/binaryurp/qa/test-cache.cxx b/binaryurp/qa/test-cache.cxx
index f14b3837629e..989b103e2e90 100644
--- a/binaryurp/qa/test-cache.cxx
+++ b/binaryurp/qa/test-cache.cxx
@@ -39,7 +39,7 @@ private:
 // cf. jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java:
 void Test::testNothingLostFromLruList() {
     int a[8];
-    for (int i = 0; i != sizeof a / sizeof a[0]; ++i) {
+    for (int i = 0; i != int(SAL_N_ELEMENTS(a)); ++i) {
         for (int j = 0; j != i; ++j) {
             a[j] = 0;
         }
diff --git a/comphelper/source/misc/syntaxhighlight.cxx b/comphelper/source/misc/syntaxhighlight.cxx
index f27a993a1c3f..3eafb4bd9391 100644
--- a/comphelper/source/misc/syntaxhighlight.cxx
+++ b/comphelper/source/misc/syntaxhighlight.cxx
@@ -694,11 +694,11 @@ SyntaxHighlighter::SyntaxHighlighter(HighlighterLanguage language):
     {
         case HighlighterLanguage::Basic:
             m_tokenizer->setKeyWords( strListBasicKeyWords,
-                                            sizeof( strListBasicKeyWords ) / sizeof( char* ));
+                                      SAL_N_ELEMENTS( strListBasicKeyWords ));
             break;
         case HighlighterLanguage::SQL:
             m_tokenizer->setKeyWords( strListSqlKeyWords,
-                                            sizeof( strListSqlKeyWords ) / sizeof( char* ));
+                                      SAL_N_ELEMENTS( strListSqlKeyWords ));
             break;
         default:
             assert(false); // this cannot happen
diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx
index bc3b31775b6d..2c8138abe19e 100644
--- a/configmgr/qa/unit/test.cxx
+++ b/configmgr/qa/unit/test.cxx
@@ -591,7 +591,7 @@ bool WriterThread::iteration() {
         OUString("bloaters") };
 
     test_.setKey(path_, name_, css::uno::Any(options[index_]));
-    index_ = (index_ + 1) % (sizeof options / sizeof (OUString));
+    index_ = (index_ + 1) % SAL_N_ELEMENTS(options);
     return true;
 }
 
@@ -614,7 +614,7 @@ void Test::testThreads()
         { OUString("/org.openoffice.System"),
           OUString("L10N/Locale") }
     };
-    std::size_t const numReaders = sizeof list / sizeof (Entry);
+    std::size_t const numReaders = SAL_N_ELEMENTS(list);
     std::size_t const numWriters = numReaders - 2;
     ReaderThread * readers[numReaders];
     WriterThread * writers[numWriters];
diff --git a/connectivity/source/drivers/postgresql/pq_statics.cxx b/connectivity/source/drivers/postgresql/pq_statics.cxx
index 596122d16c6e..61688bd61e4f 100644
--- a/connectivity/source/drivers/postgresql/pq_statics.cxx
+++ b/connectivity/source/drivers/postgresql/pq_statics.cxx
@@ -201,7 +201,7 @@ Statics & getStatics()
                     PropertyDef( statics.TYPE , tString )
                 };
             ist.pProps = createPropertyArrayHelper(
-                tableDef, sizeof(tableDef)/sizeof(PropertyDef), READONLY );
+                tableDef, SAL_N_ELEMENTS(tableDef), READONLY );
 
             statics.refl.tableDescriptor.implName =
                 "org.openoffice.comp.pq.sdbcx.TableDescriptor";
@@ -240,7 +240,7 @@ Statics & getStatics()
                     PropertyDefEx( statics.TYPE_NAME , tString ,READONLY)
                 };
             statics.refl.column.pProps = createPropertyArrayHelper(
-                columnDef, sizeof(columnDef)/sizeof(PropertyDefEx) );
+                columnDef, SAL_N_ELEMENTS(columnDef) );
 
             statics.refl.columnDescriptor.implName =
                 "org.openoffice.comp.pq.sdbcx.ColumnDescriptor";
@@ -282,7 +282,7 @@ Statics & getStatics()
                     PropertyDef( statics.UPDATE_RULE, tInt )
                 };
             statics.refl.key.pProps = createPropertyArrayHelper(
-                keyDef, sizeof(keyDef)/sizeof(PropertyDef), READONLY );
+                keyDef, SAL_N_ELEMENTS(keyDef), READONLY );
 
 
             // Key properties
@@ -324,7 +324,7 @@ Statics & getStatics()
                     PropertyDef( statics.TYPE_NAME , tString )
                 };
             statics.refl.keycolumn.pProps = createPropertyArrayHelper(
-                keycolumnDef, sizeof(keycolumnDef)/sizeof(PropertyDef), READONLY );
+                keycolumnDef, SAL_N_ELEMENTS(keycolumnDef), READONLY );
 
             // KeyColumn props set
             statics.refl.keycolumnDescriptor.implName =
@@ -353,7 +353,7 @@ Statics & getStatics()
                     PropertyDef( statics.SCHEMA_NAME , tString )
                 };
             statics.refl.view.pProps = createPropertyArrayHelper(
-                viewDef, sizeof(viewDef)/sizeof(PropertyDef), READONLY );
+                viewDef, SAL_N_ELEMENTS(viewDef), READONLY );
 
             // view props set
             statics.refl.viewDescriptor.implName = "org.openoffice.comp.pq.sdbcx.ViewDescriptor";
@@ -370,7 +370,7 @@ Statics & getStatics()
                     PropertyDef( statics.NAME , tString )
                 };
             statics.refl.user.pProps = createPropertyArrayHelper(
-                userDefRO, sizeof(userDefRO)/sizeof(PropertyDef), READONLY );
+                userDefRO, SAL_N_ELEMENTS(userDefRO), READONLY );
 
             // user props set
             statics.refl.userDescriptor.implName =
@@ -400,7 +400,7 @@ Statics & getStatics()
                     PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence )
                 };
             statics.refl.index.pProps = createPropertyArrayHelper(
-                indexDef, sizeof(indexDef)/sizeof(PropertyDef), READONLY );
+                indexDef, SAL_N_ELEMENTS(indexDef), READONLY );
 
             // index props set
             statics.refl.indexDescriptor.implName =
@@ -432,7 +432,7 @@ Statics & getStatics()
                     PropertyDef( statics.TYPE_NAME , tString )
                 };
             statics.refl.indexColumn.pProps = createPropertyArrayHelper(
-                indexColumnDef, sizeof(indexColumnDef)/sizeof(PropertyDef), READONLY );
+                indexColumnDef, SAL_N_ELEMENTS(indexColumnDef), READONLY );
 
             // indexColumn props set
             statics.refl.indexColumnDescriptor.implName =
diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx
index 0d64c56e9e62..55a0d244b724 100644
--- a/cppuhelper/source/bootstrap.cxx
+++ b/cppuhelper/source/bootstrap.cxx
@@ -42,8 +42,6 @@
 
 #include "macro_expander.hxx"
 
-#define ARLEN(x) sizeof (x) / sizeof *(x)
-
 using namespace ::osl;
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -138,7 +136,7 @@ Reference< XComponentContext > SAL_CALL bootstrap()
         if ( hPool == nullptr )
             throw BootstrapException( "cannot create random pool!" );
         sal_uInt8 bytes[ 16 ];
-        if ( rtl_random_getBytes( hPool, bytes, ARLEN( bytes ) )
+        if ( rtl_random_getBytes( hPool, bytes, SAL_N_ELEMENTS( bytes ) )
             != rtl_Random_E_None )
             throw BootstrapException( "random pool error!" );
         rtl_random_destroyPool( hPool );
@@ -167,7 +165,7 @@ Reference< XComponentContext > SAL_CALL bootstrap()
         // start office process
         oslProcess hProcess = nullptr;
         oslProcessError rc = osl_executeProcess(
-            OUString(path + "soffice").pData, ar_args, ARLEN( ar_args ),
+            OUString(path + "soffice").pData, ar_args, SAL_N_ELEMENTS( ar_args ),
             osl_Process_DETACHED,
             sec.getHandle(),
             nullptr, // => current working dir
diff --git a/desktop/inc/dp_misc.h b/desktop/inc/dp_misc.h
index 365bff77338a..154a4de59543 100644
--- a/desktop/inc/dp_misc.h
+++ b/desktop/inc/dp_misc.h
@@ -32,8 +32,6 @@
 #include <com/sun/star/awt/XWindow.hpp>
 #include "dp_misc_api.hxx"
 
-#define ARLEN(x) (sizeof (x) / sizeof *(x))
-
 namespace dp_misc {
 
 const sal_Char CR = 0x0d;
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index 2083075a608e..3655a4c05c13 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -428,7 +428,7 @@ OUString generateRandomPipeId()
         throw RuntimeException( "cannot create random pool!?", nullptr );
     sal_uInt8 bytes[ 32 ];
     if (rtl_random_getBytes(
-            s_hPool, bytes, ARLEN(bytes) ) != rtl_Random_E_None) {
+            s_hPool, bytes, SAL_N_ELEMENTS(bytes) ) != rtl_Random_E_None) {
         throw RuntimeException( "random pool error!?", nullptr );
     }
     OUStringBuffer buf;
diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx
index 2c40f9e54798..cc060c4f0b31 100644
--- a/desktop/source/deployment/registry/package/dp_package.cxx
+++ b/desktop/source/deployment/registry/package/dp_package.cxx
@@ -1511,10 +1511,8 @@ void BackendImpl::PackageImpl::scanLegacyBundle(
     if (title.endsWithIgnoreAsciiCase("skip_registration") )
         skip_registration = true;
 
-    OUString ar [] = { OUString("Title"), OUString("IsFolder") };
-    Reference<sdbc::XResultSet> xResultSet(
-        ucbContent.createCursor(
-            Sequence<OUString>( ar, ARLEN(ar) ) ) );
+    Sequence<OUString> ar { OUString("Title"), OUString("IsFolder") };
+    Reference<sdbc::XResultSet> xResultSet( ucbContent.createCursor( ar ) );
     while (xResultSet->next())
     {
         checkAborted( abortChannel );
diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx
index 954668bdea92..133b0e666411 100644
--- a/filter/source/graphicfilter/ieps/ieps.cxx
+++ b/filter/source/graphicfilter/ieps/ieps.cxx
@@ -232,7 +232,7 @@ static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r
     oslFileHandle pErr = nullptr;
         oslProcessError eErr = runProcessWithPathSearch(
             "pstoedit" EXESUFFIX,
-            args, sizeof(args)/sizeof(rtl_uString *),
+            args, SAL_N_ELEMENTS(args),
             &aProcess, &pIn, &pOut, &pErr);
 
     if (eErr!=osl_Process_E_None)
@@ -360,7 +360,7 @@ static bool RenderAsBMPThroughConvert(const sal_uInt8* pBuf, sal_uInt32 nBytesRe
     return RenderAsBMPThroughHelper(pBuf, nBytesRead, rGraphic,
         ("convert" EXESUFFIX),
         args,
-        sizeof(args)/sizeof(rtl_uString *));
+        SAL_N_ELEMENTS(args));
 }
 
 static bool RenderAsBMPThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
@@ -390,7 +390,7 @@ static bool RenderAsBMPThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
         "gs" EXESUFFIX,
 #endif
         args,
-        sizeof(args)/sizeof(rtl_uString *));
+        SAL_N_ELEMENTS(args));
 }
 
 static bool RenderAsBMP(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &rGraphic)
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index 6a3530a3cbb0..02ef2098ee3d 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -328,13 +328,13 @@ bool SVGFilter::isStreamSvg(const uno::Reference<io::XInputStream>& xInput)
     const sal_Int8* pBuffer = aBuffer.getConstArray();
 
     sal_Int8 aMagic1[] = {'<', 's', 'v', 'g'};
-    sal_Int32 aMagic1Size = sizeof(aMagic1) / sizeof(*aMagic1);
+    sal_Int32 aMagic1Size = SAL_N_ELEMENTS(aMagic1);
 
     if (std::search(pBuffer, pBuffer + nBytes, aMagic1, aMagic1 + aMagic1Size) != pBuffer + nBytes )
         return true;
 
     sal_Int8 aMagic2[] = {'D', 'O', 'C', 'T', 'Y', 'P', 'E', ' ', 's', 'v', 'g'};
-    sal_Int32 aMagic2Size = sizeof(aMagic2) / sizeof(*aMagic2);
+    sal_Int32 aMagic2Size = SAL_N_ELEMENTS(aMagic2);
 
     return std::search(pBuffer, pBuffer + nBytes, aMagic2, aMagic2 + aMagic2Size) != pBuffer + nBytes;
 }
diff --git a/filter/source/svg/tokenmap.cxx b/filter/source/svg/tokenmap.cxx
index 00b7bca5df4e..082c0354c669 100644
--- a/filter/source/svg/tokenmap.cxx
+++ b/filter/source/svg/tokenmap.cxx
@@ -58,7 +58,7 @@ const char* getTokenName( sal_Int32 nTokenId )
         return nullptr;
 
     const xmltoken* pCurr=wordlist;
-    const xmltoken* pEnd=wordlist+sizeof(wordlist)/sizeof(*wordlist);
+    const xmltoken* pEnd=wordlist+SAL_N_ELEMENTS(wordlist);
     while( pCurr != pEnd )
     {
         if(pCurr->nToken == nTokenId)
diff --git a/hwpfilter/source/fontmap.cxx b/hwpfilter/source/fontmap.cxx
index a59d131f8c78..003001308412 100644
--- a/hwpfilter/source/fontmap.cxx
+++ b/hwpfilter/source/fontmap.cxx
@@ -24,6 +24,7 @@
 #include <string.h>
 #endif
 
+#include <sal/types.h>
 #include <fontmap.hxx>
 
 struct FontEntry
@@ -145,16 +146,14 @@ const char* const RepFontTab[] =
 
 int getRepFamilyName(const char* orig, char *buf, double &ratio)
 {
-    int i;
-    int size = sizeof(FontMapTab)/sizeof(FontEntry);
-    for( i = 0 ; i < size ; i++)
+    for( int i = 0 ; i < int(SAL_N_ELEMENTS(FontMapTab)); i++)
     {
         if( !strcmp(orig, FontMapTab[i].familyname) ){
                 ratio = FontMapTab[i].ratio;
             return strlen( strcpy(buf,RepFontTab[FontMapTab[i].key]) );
           }
     }
-     ratio = FontMapTab[0].ratio;
+    ratio = FontMapTab[0].ratio;
     return strlen( strcpy(buf, RepFontTab[0] ) );
 }
 
diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index ef6348817f48..9ad331945798 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -480,7 +480,7 @@ static hchar olHanglJaso(int num, int type)
 
     if (type == OL_HANGL_JASO)
     {
-        num = num % (14 + (sizeof(jung) / sizeof(char)));
+        num = num % (14 + SAL_N_ELEMENTS(jung));
 
         if (num < 14)
             hh = (han_init[num] << 8) | 'A';
@@ -493,7 +493,7 @@ static hchar olHanglJaso(int num, int type)
             hh = (han_init[num] << 8) | 'a';
         else
         {
-            int j = (num / 14) % (sizeof(jung2) / sizeof(char));
+            int j = (num / 14) % SAL_N_ELEMENTS(jung2);
 
             num = num % 14;
             hh = (han_init[num] << 8) | (jung2[j] << 5) | 1;
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 102b54b8df77..cab75e6f32ac 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -947,7 +947,7 @@ static const Supported_NumberingType aSupportedTypes[] =
         {style::NumberingType::CHARS_GREEK_UPPER_LETTER,   C_GR_A ", " C_GR_B ", ... (gr)", LANG_ALL},
         {style::NumberingType::CHARS_GREEK_LOWER_LETTER,   S_GR_A ", " S_GR_B ", ... (gr)", LANG_ALL},
 };
-static const sal_Int32 nSupported_NumberingTypes = sizeof(aSupportedTypes) / sizeof(Supported_NumberingType);
+static const sal_Int32 nSupported_NumberingTypes = SAL_N_ELEMENTS(aSupportedTypes);
 
 OUString DefaultNumberingProvider::makeNumberingIdentifier(sal_Int16 index)
 {
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 43c81b5123a6..4418fc287c45 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -841,13 +841,11 @@ struct HebrewNumberChar {
     { 0x05d0, 1 }
 };
 
-static sal_Int16 nbOfHebrewNumberChar = sizeof(HebrewNumberCharArray)/sizeof(HebrewNumberChar);
-
-static sal_Unicode thousand[] = {0x05d0, 0x05dc, 0x05e3, 0x0};
-static sal_Unicode thousands[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x0};
-static sal_Unicode thousands_last[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x05dd, 0x0};
-static sal_Unicode geresh = 0x05f3;
-static sal_Unicode gershayim = 0x05f4;
+static const sal_Unicode thousand[] = {0x05d0, 0x05dc, 0x05e3, 0x0};
+static const sal_Unicode thousands[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x0};
+static const sal_Unicode thousands_last[] = {0x05d0, 0x05dc, 0x05e4, 0x05d9, 0x05dd, 0x0};
+static const sal_Unicode geresh = 0x05f3;
+static const sal_Unicode gershayim = 0x05f4;
 
 void makeHebrewNumber(sal_Int64 value, OUStringBuffer& output, bool isLast, bool useGeresh)
 {
@@ -861,7 +859,7 @@ void makeHebrewNumber(sal_Int64 value, OUStringBuffer& output, bool isLast, bool
         output.append(value == 1000 ? thousand : isLast ? thousands_last : thousands);
     } else {
         sal_Int16 nbOfChar = 0;
-        for (sal_Int32 j = 0; num > 0 && j < nbOfHebrewNumberChar; j++) {
+        for (sal_Int32 j = 0; num > 0 && j < sal_Int32(SAL_N_ELEMENTS(HebrewNumberCharArray)); j++) {
             if (num - HebrewNumberCharArray[j].value >= 0) {
                 nbOfChar++;
                 if (num == 15 || num == 16) // substitution for 15 and 16
@@ -952,8 +950,6 @@ struct CyrillicNumberChar {
     { 0x0430, 1 }
 };
 
-static sal_Int16 nbOfCyrillicNumberChar = sizeof(CyrillicNumberCharArray)/sizeof(CyrillicNumberChar);
-
 void makeCyrillicNumber(sal_Int64 value, OUStringBuffer& output, bool addTitlo)
 {
     sal_Int16 num = sal::static_int_cast<sal_Int16>(value % 1000);
@@ -967,7 +963,7 @@ void makeCyrillicNumber(sal_Int64 value, OUStringBuffer& output, bool addTitlo)
             addTitlo = false;
     }
 
-    for (sal_Int32 j = 0; num > 0 && j < nbOfCyrillicNumberChar; j++) {
+    for (sal_Int32 j = 0; num > 0 && j < sal_Int32(SAL_N_ELEMENTS(CyrillicNumberCharArray)); j++) {
         if (num < 20 && num > 10) {
             num -= 10;
             makeCyrillicNumber(num, output, false);
diff --git a/i18npool/source/textconversion/textconversion_ko.cxx b/i18npool/source/textconversion/textconversion_ko.cxx
index 07a4151bc873..e9a788f5a461 100644
--- a/i18npool/source/textconversion/textconversion_ko.cxx
+++ b/i18npool/source/textconversion/textconversion_ko.cxx
@@ -87,7 +87,7 @@ sal_Int16 SAL_CALL checkScriptType(sal_Unicode c)
         sal_Int16 script;
     } UBlock2Script;
 
-    static UBlock2Script scriptList[] = {
+    static const UBlock2Script scriptList[] = {
         {UBLOCK_HANGUL_JAMO, UBLOCK_HANGUL_JAMO, SCRIPT_HANGUL},
         {UBLOCK_CJK_RADICALS_SUPPLEMENT, UBLOCK_BOPOMOFO, SCRIPT_HANJA},
         {UBLOCK_HANGUL_COMPATIBILITY_JAMO, UBLOCK_HANGUL_COMPATIBILITY_JAMO, SCRIPT_HANGUL},
@@ -98,14 +98,12 @@ sal_Int16 SAL_CALL checkScriptType(sal_Unicode c)
         {UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS, UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS, SCRIPT_HANJA},
     };
 
-#define scriptListCount sizeof (scriptList) / sizeof (UBlock2Script)
-
     UBlockCode block=ublock_getCode((sal_uInt32) c);
     sal_uInt16 i;
-    for ( i = 0; i < scriptListCount; i++) {
+    for ( i = 0; i < SAL_N_ELEMENTS(scriptList); i++) {
         if (block <= scriptList[i].to) break;
     }
-    return (i < scriptListCount && block >= scriptList[i].from) ? scriptList[i].script : SCRIPT_OTHERS;
+    return (i < SAL_N_ELEMENTS(scriptList) && block >= scriptList[i].from) ? scriptList[i].script : SCRIPT_OTHERS;
 }
 
 #ifdef DISABLE_DYNLOADING
diff --git a/i18npool/source/transliteration/numtotext_cjk.cxx b/i18npool/source/transliteration/numtotext_cjk.cxx
index f1d15d268afd..af633d0c1997 100644
--- a/i18npool/source/transliteration/numtotext_cjk.cxx
+++ b/i18npool/source/transliteration/numtotext_cjk.cxx
@@ -60,7 +60,7 @@ TRANSLITERATION_NUMTOTEXT( KanjiShortModern_ja_JP, NATNUM7)
 NumToText##name::NumToText##name() \
 { \
         table = _table;\
-        tableSize = sizeof(_table) / sizeof(sal_Unicode); \
+        tableSize = SAL_N_ELEMENTS(_table); \
         recycleSymbol = recycle; \
         transliterationName = "NumToText"#name; \
         implementationName = "com.sun.star.i18n.Transliteration.NumToText"#name; \
diff --git a/i18nutil/source/utility/widthfolding.cxx b/i18nutil/source/utility/widthfolding.cxx
index acc413598613..3b948025e318 100644
--- a/i18nutil/source/utility/widthfolding.cxx
+++ b/i18nutil/source/utility/widthfolding.cxx
@@ -220,9 +220,7 @@ oneToOneMapping& widthfolding::getfull2halfTableForASC()
     //
     //  See the following page for detail:
     // http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions
-    int i, j;
-    int n = sizeof(full2halfASCException) / sizeof(UnicodePairWithFlag);
-    for( i = 0; i < n; i++ )
+    for( int i = 0; i < int(SAL_N_ELEMENTS(full2halfASCException)); i++ )
     {
         const int high = (full2halfASCException[i].first >> 8) & 0xFF;
         const int low  = (full2halfASCException[i].first)      & 0xFF;
@@ -231,7 +229,7 @@ oneToOneMapping& widthfolding::getfull2halfTableForASC()
         {
             table.mpIndex[high] = new UnicodePairWithFlag*[256];
 
-            for( j = 0; j < 256; j++ )
+            for( int j = 0; j < 256; j++ )
                 table.mpIndex[high][j] = nullptr;
         }
         table.mpIndex[high][low] = &full2halfASCException[i];
@@ -255,7 +253,7 @@ oneToOneMapping& widthfolding::gethalf2fullTableForJIS()
     //  See the following page for detail:
     // http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions
     int i, j;
-    int n = sizeof(half2fullJISException) / sizeof(UnicodePairWithFlag);
+    int n = SAL_N_ELEMENTS(half2fullJISException);
     for( i = 0; i < n; i++ )
     {
         const int high = (half2fullJISException[i].first >> 8) & 0xFF;
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx b/jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx
index 1750696ab018..d7bf982e4fc1 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx
@@ -47,7 +47,7 @@ char const* const* GnuInfo::getJavaExePaths(int * size)
         "gij-4.1",
         "bin/gij-4.1"
     };
-    *size = sizeof (ar) / sizeof (char*);
+    *size = SAL_N_ELEMENTS (ar);
     return ar;
 }
 
@@ -82,7 +82,7 @@ char const* const* GnuInfo::getRuntimePaths(int * size)
         "/libgcj.so.7",
         "/libgcj.so.6"
     };
-    *size = sizeof(ar) / sizeof (char*);
+    *size = SAL_N_ELEMENTS(ar);
     return ar;
 }
 
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx b/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx
index 1de6afd210b6..8407e3be53e7 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx
@@ -44,7 +44,7 @@ char const* const* OtherInfo::getJavaExePaths(int * size)
         "jre/bin/java"
 #endif
     };
-        *size = sizeof (ar) / sizeof (char*);
+        *size = SAL_N_ELEMENTS (ar);
     return ar;
 }
 
@@ -72,7 +72,7 @@ char const* const* OtherInfo::getRuntimePaths(int * size)
 #endif
 
     };
-    *size = sizeof(ar) / sizeof (char*);
+    *size = SAL_N_ELEMENTS(ar);
     return ar;
 }
 
@@ -94,7 +94,7 @@ char const* const* OtherInfo::getLibraryPaths(int* size)
         "/lib/" JFW_PLUGIN_ARCH
     };
 
-    *size = sizeof(ar) / sizeof (char*);
+    *size = SAL_N_ELEMENTS(ar);
     return ar;
 #else
     *size = 0;
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx
index 85f31a383fc6..9646ba3a6f87 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx
@@ -322,24 +322,24 @@ SelfTest::SelfTest()
 {
     bool bRet = true;
 
-    char const * versions[] = {"1.4.0", "1.4.1", "1.0.0", "10.0.0", "10.10.0",
+    static char const * versions[] = {"1.4.0", "1.4.1", "1.0.0", "10.0.0", "10.10.0",
                          "10.2.2", "10.10.0", "10.10.10", "111.0.999",
                          "1.4.1_01", "9.90.99_09", "1.4.1_99",
                          "1.4.1_00a",
                          "1.4.1-ea", "1.4.1-beta", "1.4.1-rc1",
                          "1.5.0_01-ea", "1.5.0_01-rc2"};
-    char const * badVersions[] = {".4.0", "..1", "", "10.0", "10.10.0.", "10.10.0-", "10.10.0.",
+    static char const * badVersions[] = {".4.0", "..1", "", "10.0", "10.10.0.", "10.10.0-", "10.10.0.",
                             "10.2-2", "10_10.0", "10..10","10.10", "a.0.999",
                             "1.4b.1_01", "9.90.-99_09", "1.4.1_99-",
                             "1.4.1_00a2", "1.4.0_z01z", "1.4.1__99A",
                             "1.4.1-1ea", "1.5.0_010", "1.5.0._01-", "1.5.0_01-eac"};
-    char const * orderedVer[] = { "1.3.1-ea", "1.3.1-beta", "1.3.1-rc1",
+    static char const * orderedVer[] = { "1.3.1-ea", "1.3.1-beta", "1.3.1-rc1",
                             "1.3.1", "1.3.1_00a", "1.3.1_01", "1.3.1_01a",
                             "1.3.2", "1.4.0", "1.5.0_01-ea", "2.0.0"};
 
-    int num = sizeof (versions) / sizeof(char*);
-    int numBad = sizeof (badVersions) / sizeof(char*);
-    int numOrdered = sizeof (orderedVer) / sizeof(char*);
+    int num = SAL_N_ELEMENTS (versions);
+    int numBad = SAL_N_ELEMENTS (badVersions);
+    int numOrdered = SAL_N_ELEMENTS (orderedVer);
     //parsing test (positive)
     for (int i = 0; i < num; i++)
     {
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 281af044c6e1..5e3c8f58494a 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -1217,21 +1217,21 @@ void addJavaInfosDirScan(
 #else // MACOSX
     OUString excMessage = "[Java framework] sunjavaplugin: "
                           "Error in function addJavaInfosDirScan in util.cxx.";
-    int cJavaNames= sizeof(g_arJavaNames) / sizeof(char*);
+    int cJavaNames= SAL_N_ELEMENTS(g_arJavaNames);
     std::unique_ptr<OUString[]> sarJavaNames(new OUString[cJavaNames]);
     OUString *arNames = sarJavaNames.get();
     for(int i= 0; i < cJavaNames; i++)
         arNames[i] = OUString(g_arJavaNames[i], strlen(g_arJavaNames[i]),
                               RTL_TEXTENCODING_UTF8);
 
-    int cSearchPaths= sizeof(g_arSearchPaths) / sizeof(char*);
+    int cSearchPaths= SAL_N_ELEMENTS(g_arSearchPaths);
     std::unique_ptr<OUString[]> sarPathNames(new OUString[cSearchPaths]);
     OUString *arPaths = sarPathNames.get();
     for(int c = 0; c < cSearchPaths; c++)
         arPaths[c] = OUString(g_arSearchPaths[c], strlen(g_arSearchPaths[c]),
                                RTL_TEXTENCODING_UTF8);
 
-    int cCollectDirs = sizeof(g_arCollectDirs) / sizeof(char*);
+    int cCollectDirs = SAL_N_ELEMENTS(g_arCollectDirs);
     std::unique_ptr<OUString[]> sarCollectDirs(new OUString[cCollectDirs]);
     OUString *arCollectDirs = sarCollectDirs.get();
     for(int d = 0; d < cCollectDirs; d++)
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx
index a08b237b62cd..104b69508209 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx
@@ -54,7 +54,7 @@ END_VENDOR_MAP()
 
 bool isVendorSupported(const OUString& sVendor)
 {
-    const size_t count = sizeof(gVendorMap) / sizeof (VendorSupportMapEntry) - 1;
+    const size_t count = SAL_N_ELEMENTS(gVendorMap) - 1;
     for ( size_t pos = 0; pos < count; ++pos )
     {
         if (sVendor.equalsAscii(gVendorMap[pos].sVendorName))
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index cf6bc02e96f8..88b5ec5d8016 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -991,7 +991,7 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
 
     if ( strcmp(sName, "zoom-in-symbolic") == 0)
     {
-        for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ )
+        for ( unsigned int i = 0; i < SAL_N_ELEMENTS( fZooms ); i++ )
         {
             if ( fCurrentZoom < fZooms[i] )
             {
@@ -1006,7 +1006,7 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
     }
     else if ( strcmp(sName, "zoom-out-symbolic") == 0)
     {
-        for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ )
+        for ( unsigned int i = 0; i < SAL_N_ELEMENTS( fZooms ); i++ )
         {
             if ( fCurrentZoom > fZooms[i] )
             {


More information about the Libreoffice-commits mailing list