[Libreoffice-commits] .: sal/inc sal/osl sal/qa sal/rtl sal/systools sal/textenc sal/workben

Michael Meeks mmeeks at kemper.freedesktop.org
Mon Oct 18 11:48:43 PDT 2010


 sal/inc/systools/win32/uwinapi.h                |    4 ----
 sal/osl/os2/tempfile.c                          |    3 ++-
 sal/osl/unx/file_volume.cxx                     |    3 ++-
 sal/osl/unx/tempfile.c                          |    3 ++-
 sal/osl/unx/thread.c                            |    5 ++---
 sal/osl/w32/file_dirvol.cxx                     |    2 --
 sal/osl/w32/file_error.c                        |    3 ++-
 sal/osl/w32/profile.cxx                         |    3 ++-
 sal/osl/w32/security.c                          |    3 ++-
 sal/osl/w32/signal.cxx                          |    3 ++-
 sal/qa/osl/process/osl_process.cxx              |    3 ++-
 sal/qa/rtl/math/test_rtl_math.cxx               |    5 +++--
 sal/qa/rtl/oustring/rtl_OUString2.cxx           |    2 +-
 sal/qa/rtl/strings/test_oustring_convert.cxx    |    3 ++-
 sal/qa/rtl/strings/test_oustring_endswith.cxx   |    3 ++-
 sal/rtl/source/alloc_global.c                   |    3 ++-
 sal/rtl/source/hash.cxx                         |    5 +++--
 sal/systools/win32/kill/kill.cxx                |   11 ++++-------
 sal/systools/win32/onlineupdate/onlinecheck.cxx |    4 +---
 sal/systools/win32/uwinapi/MoveFileExA.cpp      |    5 +++--
 sal/textenc/textenc.cxx                         |    3 ++-
 sal/workben/t_cipher.c                          |    3 ++-
 22 files changed, 43 insertions(+), 39 deletions(-)

New commits:
commit 5ecab7a09f86843667520dafb158d569715ea214
Author: Kenneth Venken <kenneth.venken at gmail.com>
Date:   Mon Oct 18 19:47:47 2010 +0100

    cleanup to use SAL_N_ELEMENTS

diff --git a/sal/inc/systools/win32/uwinapi.h b/sal/inc/systools/win32/uwinapi.h
index 6c19788..7fda61e 100644
--- a/sal/inc/systools/win32/uwinapi.h
+++ b/sal/inc/systools/win32/uwinapi.h
@@ -102,10 +102,6 @@ EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainW( LPWSTR lpBuffer, DWORD nBuffser
 
 EXTERN_C WINBASEAPI DWORD WINAPI GetProcessId( HANDLE hProcess );
 
-/* macro that calculates the count of elements of a static array */
-
-#define elementsof(buf)	(sizeof(buf) / sizeof((buf)[0]))
-
 #ifdef __cplusplus
 
 inline bool IsValidHandle(HANDLE handle)
diff --git a/sal/osl/os2/tempfile.c b/sal/osl/os2/tempfile.c
index 9651318..7c84429 100644
--- a/sal/osl/os2/tempfile.c
+++ b/sal/osl/os2/tempfile.c
@@ -39,6 +39,7 @@
 #include <osl/thread.h>
 #include <rtl/ustrbuf.h>
 #include <osl/diagnose.h>
+#include <sal/macros.h>
 
 #ifndef _FILE_URL_H_
 #include "file_url.h"
@@ -87,7 +88,7 @@ oslFileError SAL_CALL osl_getTempDirURL( rtl_uString** pustrTempDir )
  ******************************************************************/
 
 static const char LETTERS[]        = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
-static const int  COUNT_OF_LETTERS = sizeof(LETTERS)/sizeof(LETTERS[0]) - 1;
+static const int  COUNT_OF_LETTERS = SAL_N_ELEMENTS(LETTERS) - 1;
 
 #define RAND_NAME_LENGTH 6
 
diff --git a/sal/osl/unx/file_volume.cxx b/sal/osl/unx/file_volume.cxx
index 9a732b8..761ba6b 100644
--- a/sal/osl/unx/file_volume.cxx
+++ b/sal/osl/unx/file_volume.cxx
@@ -42,6 +42,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/wait.h>
+#include <sal/macros.h>
 
 #ifdef HAVE_STATFS_H
 #undef HAVE_STATFS_H
@@ -596,7 +597,7 @@ osl_isAFloppyDevice (const char* pDeviceName)
     };
 
     int i;
-    for (i = 0; i < (sizeof(pFloppyDevice)/sizeof(pFloppyDevice[0])); i++)
+    for (i = 0; i < SAL_N_ELEMENTS(pFloppyDevice); i++)
     {
         if (strncmp(pDeviceName, pFloppyDevice[i], strlen(pFloppyDevice[i])) == 0)
             return sal_True;
diff --git a/sal/osl/unx/tempfile.c b/sal/osl/unx/tempfile.c
index 1c3ec8f..25130cd 100644
--- a/sal/osl/unx/tempfile.c
+++ b/sal/osl/unx/tempfile.c
@@ -42,6 +42,7 @@
 #include <osl/thread.h>
 #include <rtl/ustrbuf.h>
 #include <osl/diagnose.h>
+#include <sal/macros.h>
 
 #ifndef _FILE_URL_H_
 #include "file_url.h"
@@ -106,7 +107,7 @@ oslFileError SAL_CALL osl_getTempDirURL( rtl_uString** pustrTempDir )
  ******************************************************************/
 
 static const char LETTERS[]        = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
-static const int  COUNT_OF_LETTERS = sizeof(LETTERS)/sizeof(LETTERS[0]) - 1;
+static const int  COUNT_OF_LETTERS = SAL_N_ELEMENTS(LETTERS) - 1;
 
 #define RAND_NAME_LENGTH 6
 
diff --git a/sal/osl/unx/thread.c b/sal/osl/unx/thread.c
index 3f96f70..5b5406e 100644
--- a/sal/osl/unx/thread.c
+++ b/sal/osl/unx/thread.c
@@ -30,9 +30,8 @@
 #include <osl/diagnose.h>
 #include <osl/thread.h>
 #include <osl/nlsupport.h>
-#ifndef _RTL_TEXTENC_H_
 #include <rtl/textenc.h>
-#endif
+#include <sal/macros.h>
 
 /****************************************************************************
  * @@@ TODO @@@
@@ -580,7 +579,7 @@ typedef struct _HashEntry
 } HashEntry;
 
 static HashEntry* HashTable[31];
-static int HashSize = sizeof(HashTable) / sizeof(HashTable[0]);
+static int HashSize = SAL_N_ELEMENTS(HashTable);
 
 static pthread_mutex_t HashLock = PTHREAD_MUTEX_INITIALIZER;
 
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index dd10f01..282ce24 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -50,8 +50,6 @@
 #endif 
 
 //#####################################################
-#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
-
 static const wchar_t UNC_PREFIX[] = L"\\\\";
 static const wchar_t BACKSLASH = '\\';
 static const wchar_t SLASH = '/';
diff --git a/sal/osl/w32/file_error.c b/sal/osl/w32/file_error.c
index 3298ed5..5829aea 100644
--- a/sal/osl/w32/file_error.c
+++ b/sal/osl/w32/file_error.c
@@ -34,6 +34,7 @@
 
 #include "osl/diagnose.h"
 #include "osl/thread.h"
+#include <sal/macros.h>
 
 /* OS error to oslFileError values mapping table */
 struct osl_file_error_entry
@@ -108,7 +109,7 @@ static const struct osl_file_error_entry errtable[] = {
 
 oslFileError oslTranslateFileError (/*DWORD*/ unsigned long dwError)
 {
-    static const int n = sizeof(errtable)/sizeof(errtable[0]);
+    static const int n = SAL_N_ELEMENTS(errtable);
 
     int i;
     for (i = 0; i < n; ++i )
diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx
index 17640fe..6887424 100644
--- a/sal/osl/w32/profile.cxx
+++ b/sal/osl/w32/profile.cxx
@@ -37,6 +37,7 @@
 #include <osl/file.h>
 #include <osl/util.h>
 #include <rtl/alloc.h>
+#include <sal/macros.h>
 #include <algorithm>
 using std::min;
 static inline void copy_ustr_n( void *dest, const void *source, size_t length ) { rtl_copyMemory(dest, source, length*sizeof(sal_Unicode)); }
@@ -2556,7 +2557,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
                 int i = 0;
                 pStr = aTmpPath + nPos;
 
-                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 ( *strPath == 0)
diff --git a/sal/osl/w32/security.c b/sal/osl/w32/security.c
index 4d9ee32..0fc22f1 100644
--- a/sal/osl/w32/security.c
+++ b/sal/osl/w32/security.c
@@ -33,6 +33,7 @@
 #include <osl/thread.h>
 #include <osl/file.h>
 #include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
 #include "secimpl.h"
 
 /*****************************************************************************/
@@ -756,7 +757,7 @@ static sal_Bool GetSpecialFolder(rtl_uString **strPath, int nFolder)
                                    &hRegKey) == ERROR_SUCCESS)
                     {
                         LONG lRet;
-                        DWORD lSize = elementsof(PathA);
+                        DWORD lSize = SAL_N_ELEMENTS(PathA);
                         DWORD Type = REG_SZ;
 
                         switch (nFolder)
diff --git a/sal/osl/w32/signal.cxx b/sal/osl/w32/signal.cxx
index 835fdc1..5f97f72 100644
--- a/sal/osl/w32/signal.cxx
+++ b/sal/osl/w32/signal.cxx
@@ -41,6 +41,7 @@
 #endif
 #include <ErrorRep.h>
 #include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
 
 typedef struct _oslSignalHandlerImpl
 {
@@ -187,7 +188,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
         StartupInfo.cb = sizeof(StartupInfo.cb);
 
 
-        sntprintf( szBuffer, elementsof(szBuffer), 
+        sntprintf( szBuffer, SAL_N_ELEMENTS(szBuffer),
             _T("%s -p %u -excp 0x%p -t %u%s"), 
             static_cast<sal_Char*>( aPath ), 
             GetCurrentProcessId(), 
diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx
index 35b96bd..6567230 100644
--- a/sal/qa/osl/process/osl_process.cxx
+++ b/sal/qa/osl/process/osl_process.cxx
@@ -40,6 +40,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <osl/module.hxx>
+#include <sal/macros.h>
 
 #if ( defined WNT )                     // Windows
 #include <tools/prewin.h>
@@ -569,7 +570,7 @@ public:
             NULL,
             suCWD.pData,
             child_env,
-            sizeof(child_env)/sizeof(child_env[0]),
+            SAL_N_ELEMENTS(child_env),
             &process);
 
         CPPUNIT_ASSERT_MESSAGE
diff --git a/sal/qa/rtl/math/test_rtl_math.cxx b/sal/qa/rtl/math/test_rtl_math.cxx
index 9868381..2dc2ffd 100644
--- a/sal/qa/rtl/math/test_rtl_math.cxx
+++ b/sal/qa/rtl/math/test_rtl_math.cxx
@@ -38,6 +38,7 @@
 #include <testshl/tresstatewrapper.hxx>
 #include "rtl/ustring.hxx"
 #include "sal/types.h"
+#include <sal/macros.h>
 
 #include <stdlib.h>
 
@@ -533,7 +534,7 @@ extern "C" sal_Bool SAL_CALL test_rtl_math(hTestResult pTestResult)
                 { 1.0000000000000002220446049250313080847263336181640625,
                   rtl_math_StringFormat_F, 53, '.', false,
                   "1.00000000000000000000000000000000000000000000000000000" } };
-        size_t const nCount = sizeof aTest / sizeof aTest[0];
+        size_t const nCount = SAL_N_ELEMENTS(aTest);
 
 //LLA: the float tests are wrong here, due to the fact that
 //     we calculate with too less digits after the point
@@ -645,7 +646,7 @@ extern "C" sal_Bool SAL_CALL test_rtl_math(hTestResult pTestResult)
                 { "3.14E2000", rtl_math_StringFormat_E, 4, '.', false,
                   "1.#INF" },
             };
-        size_t const nCount = sizeof aTest / sizeof aTest[0];
+        size_t const nCount = SAL_N_ELEMENTS(aTest);
         bReturn &= testStringToNumberToString< StringTraits >(
             pTestResult, aTest, nCount);
         bReturn &= testStringToNumberToString< UStringTraits >(
diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx
index 05516c7..e3877a1 100644
--- a/sal/qa/rtl/oustring/rtl_OUString2.cxx
+++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx
@@ -986,7 +986,7 @@ void convertToString::test() {
     static sal_Unicode const utf16[] = { 0x0041, 0x00E4, 0x0061 };
     rtl::OString s;
     CPPUNIT_ASSERT(
-        rtl::OUString(utf16, sizeof utf16 / sizeof utf16[0]).convertToString(
+        rtl::OUString(utf16, SAL_N_ELEMENTS(utf16)).convertToString(
             &s, RTL_TEXTENCODING_UTF7,
             (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
              RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)));
diff --git a/sal/qa/rtl/strings/test_oustring_convert.cxx b/sal/qa/rtl/strings/test_oustring_convert.cxx
index f0e0434..c0705e2 100644
--- a/sal/qa/rtl/strings/test_oustring_convert.cxx
+++ b/sal/qa/rtl/strings/test_oustring_convert.cxx
@@ -33,6 +33,7 @@
 #include "rtl/strbuf.hxx"
 #include "rtl/string.hxx"
 #include "rtl/ustring.hxx"
+#include <sal/macros.h>
 
 namespace test { namespace oustring {
 
@@ -180,7 +181,7 @@ void test::oustring::Convert::convertToString()
               OUSTRING_TO_OSTRING_CVTFLAGS,
               "A?B",
               "A?B" } };
-    for (unsigned int i = 0; i < sizeof aTests / sizeof aTests[0]; ++i)
+    for (unsigned int i = 0; i < SAL_N_ELEMENTS(aTests); ++i)
         testConvertToString(aTests[i]);
 }
 
diff --git a/sal/qa/rtl/strings/test_oustring_endswith.cxx b/sal/qa/rtl/strings/test_oustring_endswith.cxx
index b4dc26a..4f2ae1f 100644
--- a/sal/qa/rtl/strings/test_oustring_endswith.cxx
+++ b/sal/qa/rtl/strings/test_oustring_endswith.cxx
@@ -36,6 +36,7 @@
 #include "rtl/textenc.h"
 #include "rtl/ustring.hxx"
 #include "sal/types.h"
+#include <sal/macros.h>
 
 namespace test { namespace oustring {
 
@@ -103,7 +104,7 @@ void test::oustring::EndsWith::endsWith()
           RTL_CONSTASCII_STRINGPARAM("b\0c"), true },
         { RTL_CONSTASCII_STRINGPARAM("a\0b\0c"),
           RTL_CONSTASCII_STRINGPARAM("b"), false } };
-    for (int i = 0; i < sizeof data / sizeof data[0]; ++i) {
+    for (int i = 0; i < SAL_N_ELEMENTS(data); ++i) {
         rtl::OStringBuffer msg;
         appendString(msg, rtl::OString(data[i].str1, data[i].str1Len));
         msg.append(
diff --git a/sal/rtl/source/alloc_global.c b/sal/rtl/source/alloc_global.c
index b7612bc..9171b49 100644
--- a/sal/rtl/source/alloc_global.c
+++ b/sal/rtl/source/alloc_global.c
@@ -26,6 +26,7 @@
  ************************************************************************/
 
 #include "rtl/alloc.h"
+#include <sal/macros.h>
 
 #ifndef INCLUDED_STRING_H
 #include <string.h>
@@ -72,7 +73,7 @@ static const sal_Size g_alloc_sizes[] =
 };
 
 #define RTL_MEMORY_CACHED_LIMIT 4 * 4096
-#define RTL_MEMORY_CACHED_SIZES (sizeof(g_alloc_sizes) / sizeof(g_alloc_sizes[0]))
+#define RTL_MEMORY_CACHED_SIZES (SAL_N_ELEMENTS(g_alloc_sizes))
 
 static rtl_cache_type * g_alloc_caches[RTL_MEMORY_CACHED_SIZES] =
 {
diff --git a/sal/rtl/source/hash.cxx b/sal/rtl/source/hash.cxx
index 8e4d94c..5ae56a6 100644
--- a/sal/rtl/source/hash.cxx
+++ b/sal/rtl/source/hash.cxx
@@ -32,6 +32,7 @@
 #include "hash.h"
 #include "strimp.h"
 #include <osl/diagnose.h>
+#include <sal/macros.h>
 
 struct StringHashTableImpl {
     sal_uInt32    nEntries;
@@ -68,8 +69,8 @@ getNextSize (sal_uInt32 nSize)
                                           65521, 131071,262139, 524287, 1048573,
                                           2097143, 4194301, 8388593, 16777213,
                                           33554393, 67108859, 134217689 };
-    #define NUM_PRIMES (sizeof (nPrimes)/ sizeof (nPrimes[0]))
-    for (sal_uInt32 i = 0; i < NUM_PRIMES; i++)
+
+    for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(nPrimes); i++)
     {
         if (nPrimes[i] > nSize)
             return nPrimes[i];
diff --git a/sal/systools/win32/kill/kill.cxx b/sal/systools/win32/kill/kill.cxx
index 1103950..55966d6 100644
--- a/sal/systools/win32/kill/kill.cxx
+++ b/sal/systools/win32/kill/kill.cxx
@@ -68,9 +68,6 @@ static inline bool IsValidHandle( HANDLE handle )
     return INVALID_HANDLE_VALUE != handle && NULL != handle;
 }
 
-
-#define elementsof( a ) (sizeof(a) / sizeof( (a)[0] ))
-
 /////////////////////////////////////////////////////////////////////////////
 // Retrieves function adress in another process
 /////////////////////////////////////////////////////////////////////////////
@@ -91,7 +88,7 @@ FARPROC WINAPI GetProcAddressEx( HANDLE hProcess, HMODULE hModule, LPCSTR lpProc
             FARPROC	lpfnRemoteProcAddress = NULL;
             TCHAR	szBaseName[MAX_PATH];
 
-            if ( GetModuleBaseName( GetCurrentProcess(), hModule, szBaseName, elementsof(szBaseName) ) )
+            if ( GetModuleBaseName( GetCurrentProcess(), hModule, szBaseName, SAL_N_ELEMENTS(szBaseName) ) )
             {
                 HMODULE	ahModules[MAX_MODULES];
                 DWORD	cbNeeded = 0;
@@ -105,7 +102,7 @@ FARPROC WINAPI GetProcAddressEx( HANDLE hProcess, HMODULE hModule, LPCSTR lpProc
                         TCHAR	szRemoteBaseName[MAX_PATH];
 
                         if ( GetModuleBaseName(
-                            hProcess, ahModules[n], szRemoteBaseName, elementsof(szRemoteBaseName) ) &&
+                            hProcess, ahModules[n], szRemoteBaseName, SAL_N_ELEMENTS(szRemoteBaseName) ) &&
                             0 == lstrcmpi( szRemoteBaseName, szBaseName )
                             )
                         {
@@ -257,7 +254,7 @@ static void ParseCommandArgs( LPDWORD lpProcesses, LPDWORD lpdwNumProcesses, int
         SIG_ENTRY( KILL )
     };
 
-    const int NumSupportedSignals = elementsof(SupportedSignals);
+    const int NumSupportedSignals = SAL_N_ELEMENTS(SupportedSignals);
 
     DWORD	dwMaxProcesses = *lpdwNumProcesses;
     int		argc = __argc;
@@ -402,7 +399,7 @@ void OutputSystemMessage( DWORD dwErrorCode )
 int _tmain()
 {
     DWORD	dwProcessIds[1024];
-    DWORD	nProcesses = elementsof(dwProcessIds);
+    DWORD	nProcesses = SAL_N_ELEMENTS(dwProcessIds);
     int		sig = SIGTERM;
 
 
diff --git a/sal/systools/win32/onlineupdate/onlinecheck.cxx b/sal/systools/win32/onlineupdate/onlinecheck.cxx
index dfcf2de..1ea7232 100644
--- a/sal/systools/win32/onlineupdate/onlinecheck.cxx
+++ b/sal/systools/win32/onlineupdate/onlinecheck.cxx
@@ -46,8 +46,6 @@
 #include <excpt.h>
 #endif
 
-#define elementsof(a) (sizeof(a)/sizeof((a)[0]))
-
 // #i71984
 extern "C" sal_Bool SAL_CALL hasInternetConnection()
 {
@@ -66,7 +64,7 @@ extern "C" sal_Bool SAL_CALL hasInternetConnection()
     BOOL fIsConnected = InternetGetConnectedStateEx(
         &dwFlags,
         szConnectionName,
-        elementsof(szConnectionName),
+        SAL_N_ELEMENTS(szConnectionName),
         0 );
 
     return fIsConnected ? sal_True : sal_False;
diff --git a/sal/systools/win32/uwinapi/MoveFileExA.cpp b/sal/systools/win32/uwinapi/MoveFileExA.cpp
index 4f7522f..6c47078 100644
--- a/sal/systools/win32/uwinapi/MoveFileExA.cpp
+++ b/sal/systools/win32/uwinapi/MoveFileExA.cpp
@@ -27,6 +27,7 @@
  ************************************************************************/
 
 #include "macros.h"
+#include <sal/macros.h>
 
 #define	WININIT_FILENAME	"wininit.ini"
 #define RENAME_SECTION		"rename"
@@ -50,7 +51,7 @@ IMPLEMENT_THUNK( kernel32, WINDOWS, BOOL, WINAPI, MoveFileExA, ( LPCSTR lpExisti
             )
         {
             CHAR	szBuffer[32767];	// The buffer size must not exceed 32K
-            DWORD	dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer, elementsof(szBuffer), WININIT_FILENAME );
+            DWORD	dwBufLen = GetPrivateProfileSectionA( RENAME_SECTION, szBuffer, SAL_N_ELEMENTS(szBuffer), WININIT_FILENAME );
 
             CHAR	szRename[MAX_PATH];	// This is enough for at most to times 67 chracters
             strcpy( szRename, szNewFileNameA );
@@ -58,7 +59,7 @@ IMPLEMENT_THUNK( kernel32, WINDOWS, BOOL, WINAPI, MoveFileExA, ( LPCSTR lpExisti
             strcat( szRename, szExistingFileNameA );
             size_t	lnRename = strlen(szRename);
 
-            if ( dwBufLen + lnRename + 2 <= elementsof(szBuffer) )
+            if ( dwBufLen + lnRename + 2 <= SAL_N_ELEMENTS(szBuffer) )
             {
                 CopyMemory( &szBuffer[dwBufLen], szRename, lnRename );
                 szBuffer[dwBufLen + lnRename ] = 0;
diff --git a/sal/textenc/textenc.cxx b/sal/textenc/textenc.cxx
index 3c5d484..fc3c388 100644
--- a/sal/textenc/textenc.cxx
+++ b/sal/textenc/textenc.cxx
@@ -35,6 +35,7 @@
 #include "gettextencodingdata.h"
 #include "tenchelp.h"
 #include "rtl/textenc.h"
+#include <sal/macros.h>
 
 #ifndef INCLUDED_STDDEF_H
 #include <stddef.h>
@@ -223,7 +224,7 @@ Impl_getTextEncodingData(rtl_TextEncoding nEncoding) SAL_THROW_EXTERN_C()
             &aImplPT154TextEncodingData, /* PT154 */
             &adobeDingbatsEncodingData }; /* ADOBE_DINGBATS */
     return
-        nEncoding < sizeof aData / sizeof aData[0] ? aData[nEncoding] : NULL;
+        nEncoding < SAL_N_ELEMENTS(aData) ? aData[nEncoding] : NULL;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/workben/t_cipher.c b/sal/workben/t_cipher.c
index 1dc8205..5f8b6e7 100644
--- a/sal/workben/t_cipher.c
+++ b/sal/workben/t_cipher.c
@@ -25,6 +25,7 @@
  *
  ************************************************************************/
 #include <sal/types.h>
+#include <sal/macros.h>
 #include <osl/diagnose.h>
 #include <rtl/cipher.h>
 
@@ -327,7 +328,7 @@ int SAL_CALL main (int argc, char *argv)
         sal_Size       length;
         int            i, n;
 
-        n = sizeof(arcfour_data_len) / sizeof(arcfour_data_len[0]);
+        n = SAL_N_ELEMENTS(arcfour_data_len);
         for (i = 0; i < n; i++)
         {
             length = arcfour_data_len[i];


More information about the Libreoffice-commits mailing list