[PATCH] more Sal n elements

Kenneth Venken kenneth.venken at gmail.com
Thu Dec 2 16:41:21 PST 2010


---
 automation/source/testtool/registry_win.cxx        |    5 +-
 cui/source/dialogs/cuifmsearch.cxx                 |    2 +-
 cui/source/options/opthtml.cxx                     |    3 +-
 cui/source/tabpages/border.cxx                     |    5 +-
 cui/source/tabpages/page.cxx                       |    9 +-
 cui/source/tabpages/swpossizetabpage.cxx           |  106 ++++++++++----------
 extensions/source/nsplugin/source/npshell.cxx      |    1 +
 extensions/source/nsplugin/source/so_main.cxx      |    4 +-
 extensions/source/propctrlr/formmetadata.cxx       |    4 +-
 extensions/source/update/check/updatecheck.cxx     |    5 +-
 .../source/update/check/updatecheckconfig.cxx      |    3 +-
 setup_native/source/ulfconv/ulfconv.cxx            |    3 +-
 .../mscrypt/securityenvironment_mscryptimpl.cxx    |    4 +-
 xmlsecurity/source/xmlsec/nss/secerror.cxx         |    3 +-
 .../xmlsec/nss/securityenvironment_nssimpl.cxx     |    3 +-
 15 files changed, 82 insertions(+), 78 deletions(-)

diff --git a/automation/source/testtool/registry_win.cxx b/automation/source/testtool/registry_win.cxx
index 0e77790..009f24c 100644
--- a/automation/source/testtool/registry_win.cxx
+++ b/automation/source/testtool/registry_win.cxx
@@ -46,6 +46,7 @@
 
 #include "registry_win.hxx"
 #include <osl/thread.h>
+#include <sal/macros.h>
 
 
 String ReadRegistry( String aKey, String aValueName )
@@ -70,8 +71,8 @@ String ReadRegistry( String aKey, String aValueName )
                 &hRegKey ) == ERROR_SUCCESS )
     {
         LONG lRet;
-        sal_Unicode	PathW[_MAX_PATH];
-        DWORD lSize = sizeof(PathW) / sizeof( sal_Unicode );
+        sal_Unicode	PathW[_MAX_PATH ];
+        DWORD lSize = SAL_N_ELEMENTS(PathW);
         DWORD Type = REG_SZ;
 
         lRet = RegQueryValueExW(hRegKey, reinterpret_cast<LPCWSTR>(aValueName.GetBuffer()), NULL, &Type, (LPBYTE)PathW, &lSize);
diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx
index b38e4bb..b4f3290 100644
--- a/cui/source/dialogs/cuifmsearch.cxx
+++ b/cui/source/dialogs/cuifmsearch.cxx
@@ -492,7 +492,7 @@ IMPL_LINK(FmSearchDialog, OnCheckBoxToggled, CheckBox*, pBox)
     {
         // die beiden jeweils anderen Boxes disablen oder enablen
         CheckBox* pBoxes[] = { &m_cbWildCard, &m_cbRegular, &m_cbApprox };
-        for (sal_uInt32 i=0; i<sizeof(pBoxes)/sizeof(CheckBox*); ++i)
+        for (sal_uInt32 i=0; i< SAL_N_ELEMENTS(pBoxes); ++i)
         {
             if (pBoxes[i] != pBox)
             {
diff --git a/cui/source/options/opthtml.cxx b/cui/source/options/opthtml.cxx
index 5a992c8..8119726 100644
--- a/cui/source/options/opthtml.cxx
+++ b/cui/source/options/opthtml.cxx
@@ -38,6 +38,7 @@
 #include <cuires.hrc>
 #include "helpid.hrc"
 #include <dialmgr.hxx>
+#include <sal/macros.h>
 
 // Umwandlung der Modi zu den Positionen in der Listbox
 const USHORT aPosToExportArr[] =
@@ -186,7 +187,7 @@ void OfaHtmlTabPage::Reset( const SfxItemSet& )
     aUnknownTagCB.Check(pHtmlOpt->IsImportUnknown());
     aIgnoreFontNamesCB.Check(pHtmlOpt->IsIgnoreFontFamily());
     USHORT nExport = pHtmlOpt->GetExportMode();
-    if( nExport >= ( sizeof( aExportToPosArr ) / sizeof( USHORT ) ) )
+    if( nExport >= SAL_N_ELEMENTS( aExportToPosArr ) )
         nExport = 4;	// default for bad config entry is NS 4.0
     USHORT nPosArr = aExportToPosArr[ nExport ];
 //	if( nPosArr == DEPRECATED_ENTRY )
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 22c8468..481d0fa 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -56,6 +56,7 @@
 #include <sfx2/request.hxx>
 #include <svl/intitem.hxx>
 #include <sfx2/itemconnect.hxx>
+#include <sal/macros.h>
 #include "borderconn.hxx"
 
 // -----------------------------------------------------------------------
@@ -691,7 +692,7 @@ BOOL SvxBorderTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
                                 TBorderPair(svx::FRAMEBORDER_RIGHT,BOX_LINE_RIGHT),
                             };
 
-    for (sal_uInt32 i=0; i < sizeof(eTypes1)/sizeof(TBorderPair); ++i)
+    for (sal_uInt32 i=0; i < SAL_N_ELEMENTS(eTypes1); ++i)
         aBoxItem.SetLine( aFrameSel.GetFrameBorderStyle( eTypes1[i].first ), eTypes1[i].second );
 
     //--------------------------------
@@ -701,7 +702,7 @@ BOOL SvxBorderTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
                                 TBorderPair(svx::FRAMEBORDER_HOR,BOXINFO_LINE_HORI),
                                 TBorderPair(svx::FRAMEBORDER_VER,BOXINFO_LINE_VERT)
                             };
-    for (sal_uInt32 j=0; j < sizeof(eTypes2)/sizeof(TBorderPair); ++j)
+    for (sal_uInt32 j=0; j < SAL_N_ELEMENTS(eTypes2); ++j)
         aBoxInfoItem.SetLine( aFrameSel.GetFrameBorderStyle( eTypes2[j].first ), eTypes2[j].second );
 
     aBoxInfoItem.EnableHor( mbHorEnabled );
diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx
index 49d7221..6b8f9f5 100644
--- a/cui/source/tabpages/page.cxx
+++ b/cui/source/tabpages/page.cxx
@@ -40,6 +40,7 @@
 #include <vcl/msgbox.hxx>
 #include <unotools/configitem.hxx>
 #include "svx/htmlmode.hxx"
+#include <sal/macros.h>
 
 #define _SVX_PAGE_CXX
 
@@ -155,9 +156,7 @@ USHORT aArr[] =
 
 USHORT PageUsageToPos_Impl( USHORT nUsage )
 {
-    const USHORT nCount = sizeof(aArr) / sizeof(USHORT);
-
-    for ( USHORT i = 0; i < nCount; ++i )
+    for ( USHORT i = 0; i < SAL_N_ELEMENTS(aArr); ++i )
         if ( aArr[i] == ( nUsage & 0x000f ) )
             return i;
     return SVX_PAGE_ALL;
@@ -167,9 +166,7 @@ USHORT PageUsageToPos_Impl( USHORT nUsage )
 
 USHORT PosToPageUsage_Impl( USHORT nPos )
 {
-    const USHORT nCount = sizeof(aArr) / sizeof(USHORT);
-
-    if ( nPos >= nCount )
+    if ( nPos >= SAL_N_ELEMENTS(aArr) )
         return 0;
     return aArr[nPos];
 }
diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx
index 20f93fb..e4841ab 100644
--- a/cui/source/tabpages/swpossizetabpage.cxx
+++ b/cui/source/tabpages/swpossizetabpage.cxx
@@ -43,6 +43,7 @@
 #include <svx/svdview.hxx>
 #include <svx/svdpagv.hxx>
 #include <svx/rectenum.hxx>
+#include <sal/macros.h>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/VertOrientation.hpp>
@@ -368,55 +369,53 @@ static FrmMap __FAR_DATA aVAsCharHtmlMap[] =
 
 std::size_t lcl_GetFrmMapCount(const FrmMap* pMap)
 {
-    if ( pMap )
+    if( pMap )
     {
-        std::size_t aSizeOf = sizeof(FrmMap);
-        if( pMap == aVParaHtmlMap)
-            return sizeof(aVParaHtmlMap) / aSizeOf;
-        if( pMap == aVAsCharHtmlMap)
-            return sizeof(aVAsCharHtmlMap) / aSizeOf;
-        if( pMap == aHParaHtmlMap)
-            return sizeof(aHParaHtmlMap) / aSizeOf;
-        if( pMap == aHParaHtmlAbsMap)
-            return sizeof(aHParaHtmlAbsMap) / aSizeOf;
-        if ( pMap == aVPageMap )
-            return sizeof(aVPageMap) / aSizeOf;
-        if ( pMap == aVPageHtmlMap )
-            return sizeof(aVPageHtmlMap) / aSizeOf;
-        if ( pMap == aVAsCharMap )
-            return sizeof(aVAsCharMap) / aSizeOf;
-        if ( pMap == aVParaMap )
-            return sizeof(aVParaMap) / aSizeOf;
-        if ( pMap == aHParaMap )
-            return sizeof(aHParaMap) / aSizeOf;
-        if ( pMap == aHFrameMap )
-            return sizeof(aHFrameMap) / aSizeOf;
-        // OD 19.09.2003 #i18732# - own vertical alignment map for to frame anchored objects
-        if ( pMap == aVFrameMap )
-            return sizeof(aVFrameMap) / aSizeOf;
-        if ( pMap == aHCharMap )
-            return sizeof(aHCharMap) / aSizeOf;
-        if ( pMap == aHCharHtmlMap )
-            return sizeof(aHCharHtmlMap) / aSizeOf;
-        if ( pMap == aHCharHtmlAbsMap )
-            return sizeof(aHCharHtmlAbsMap) / aSizeOf;
-        if ( pMap == aVCharMap )
-            return sizeof(aVCharMap) / aSizeOf;
-        if ( pMap == aVCharHtmlMap )
-            return sizeof(aVCharHtmlMap) / aSizeOf;
-        if ( pMap == aVCharHtmlAbsMap )
-            return sizeof(aVCharHtmlAbsMap) / aSizeOf;
-        if ( pMap == aHPageHtmlMap )
-            return sizeof(aHPageHtmlMap) / aSizeOf;
-        if ( pMap == aHFlyHtmlMap )
-            return sizeof(aHFlyHtmlMap) / aSizeOf;
-        if ( pMap == aVFlyHtmlMap )
-            return sizeof(aVFlyHtmlMap) / aSizeOf;
-        if( pMap == aVMultiSelectionMap)
-            return sizeof(aVMultiSelectionMap) / aSizeOf;
-        if( pMap == aHMultiSelectionMap)
-            return sizeof(aHMultiSelectionMap) / aSizeOf;
-        return sizeof(aHPageMap) / aSizeOf;
+        if( pMap == aVParaHtmlMap )
+            return SAL_N_ELEMENTS(aVParaHtmlMap);
+        if( pMap == aVAsCharHtmlMap )
+            return SAL_N_ELEMENTS( aVAsCharHtmlMap );
+        if( pMap == aHParaHtmlMap )
+            return SAL_N_ELEMENTS( aHParaHtmlMap );
+        if( pMap == aHParaHtmlAbsMap )
+            return SAL_N_ELEMENTS( aHParaHtmlAbsMap );
+        if( pMap == aVPageMap )
+            return SAL_N_ELEMENTS( aVPageMap );
+        if( pMap == aVPageHtmlMap )
+            return SAL_N_ELEMENTS( aVPageHtmlMap );
+        if( pMap == aVAsCharMap )
+            return SAL_N_ELEMENTS( aVAsCharMap );
+        if( pMap == aVParaMap )
+            return SAL_N_ELEMENTS( aVParaMap );
+        if( pMap == aHParaMap )
+            return SAL_N_ELEMENTS( aHParaMap );
+        if( pMap == aHFrameMap )
+            return SAL_N_ELEMENTS( aHFrameMap );
+        if( pMap == aVFrameMap )
+            return SAL_N_ELEMENTS( aVFrameMap );
+        if( pMap == aHCharMap )
+            return SAL_N_ELEMENTS( aHCharMap );
+        if( pMap == aHCharHtmlMap )
+            return SAL_N_ELEMENTS( aHCharHtmlMap );
+        if( pMap == aHCharHtmlAbsMap )
+            return SAL_N_ELEMENTS( aHCharHtmlAbsMap );
+        if( pMap == aVCharMap )
+            return SAL_N_ELEMENTS( aVCharMap );
+        if( pMap == aVCharHtmlMap )
+            return SAL_N_ELEMENTS( aVCharHtmlMap );
+        if( pMap == aVCharHtmlAbsMap )
+            return SAL_N_ELEMENTS( aVCharHtmlAbsMap );
+        if( pMap == aHPageHtmlMap )
+            return SAL_N_ELEMENTS( aHPageHtmlMap );
+        if( pMap == aHFlyHtmlMap )
+            return SAL_N_ELEMENTS( aHFlyHtmlMap );
+        if( pMap == aVFlyHtmlMap )
+            return SAL_N_ELEMENTS( aVFlyHtmlMap );
+        if( pMap == aVMultiSelectionMap )
+            return SAL_N_ELEMENTS( aVMultiSelectionMap );
+        if( pMap == aHMultiSelectionMap )
+            return SAL_N_ELEMENTS( aHMultiSelectionMap );
+        return SAL_N_ELEMENTS(aHPageMap);
     }
     return 0;
 }
@@ -458,7 +457,7 @@ SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(
             {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
         };
         USHORT nIndex;
-        for(nIndex = 0; nIndex < sizeof(aHoriIds) / sizeof(StringIdPair_Impl); ++nIndex)
+        for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex)
         {
             if(aHoriIds[nIndex].eHori == eStringId)
             {
@@ -467,7 +466,7 @@ SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(
             }
         }
         nIndex = 0;
-        for(nIndex = 0; nIndex < sizeof(aVertIds) / sizeof(StringIdPair_Impl); ++nIndex)
+        for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex)
         {
             if(aVertIds[nIndex].eHori == eStringId)
             {
@@ -484,8 +483,7 @@ ULONG lcl_GetLBRelationsForRelations( const USHORT _nRel )
 {
     ULONG nLBRelations = 0L;
 
-    sal_uInt16 nRelMapSize = sizeof(aRelationMap) / sizeof(RelationMap);
-    for ( sal_uInt16 nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
+    for ( sal_uInt16 nRelMapPos = 0; nRelMapPos < SAL_N_ELEMENTS(aRelationMap); ++nRelMapPos )
     {
         if ( aRelationMap[nRelMapPos].nRelation == _nRel )
         {
@@ -1628,7 +1626,7 @@ ULONG SvxSwPosSizeTabPage::FillRelLB(FrmMap *pMap, USHORT nMapPos, USHORT nAlign
         if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
         {
             String sOldEntry(rLB.GetSelectEntry());
-            USHORT nRelCount = sizeof(aAsCharRelationMap) / sizeof(RelationMap);
+            USHORT nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
             SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
 
             for (std::size_t _nMapPos = 0; _nMapPos < nMapCount; _nMapPos++)
@@ -1675,7 +1673,7 @@ ULONG SvxSwPosSizeTabPage::FillRelLB(FrmMap *pMap, USHORT nMapPos, USHORT nAlign
         }
         else
         {
-            USHORT nRelCount = sizeof(aRelationMap) / sizeof(RelationMap);
+            USHORT nRelCount = SAL_N_ELEMENTS(aRelationMap);
 
             // OD 14.11.2003 #i22341# - special handling for map <aVCharMap>,
             // because its ambigous in its <eStrId>/<eMirrorStrId>.
diff --git a/extensions/source/nsplugin/source/npshell.cxx b/extensions/source/nsplugin/source/npshell.cxx
index d19b7b6..8e7bc55 100644
--- a/extensions/source/nsplugin/source/npshell.cxx
+++ b/extensions/source/nsplugin/source/npshell.cxx
@@ -72,6 +72,7 @@
 
 #include <string.h>
 #include <errno.h>
+#include <sal/macros.h>
 #include "boost/scoped_array.hpp"
 #include "tools/pathutils.hxx"
 
diff --git a/extensions/source/nsplugin/source/so_main.cxx b/extensions/source/nsplugin/source/so_main.cxx
index eaead5f..3211c00 100644
--- a/extensions/source/nsplugin/source/so_main.cxx
+++ b/extensions/source/nsplugin/source/so_main.cxx
@@ -66,6 +66,7 @@
 #include "nsp_func.hxx"
 
 #include "sal/main.h"
+#include <sal/macros.h>
 
 #include "rtl/process.h"
 #include "rtl/bootstrap.hxx"
@@ -85,7 +86,6 @@
 #include "com/sun/star/bridge/XUnoUrlResolver.hpp"
 
 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-#define ARLEN(x) sizeof (x) / sizeof *(x)
 
 using namespace ::rtl;
 using namespace ::osl;
@@ -389,7 +389,7 @@ Reference< lang::XMultiServiceFactory > SAL_CALL start_office(NSP_PIPE_FD read_f
         oslProcessError rc = osl_executeProcess(
             aOfficePath.pData,
             ar_args,
-            ARLEN( ar_args ),
+            SAL_N_ELEMENTS( ar_args ),
             osl_Process_DETACHED,
             sec.getHandle(),
             0, // => current working dir
diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx
index ae14c90..9f6e4b2 100644
--- a/extensions/source/propctrlr/formmetadata.cxx
+++ b/extensions/source/propctrlr/formmetadata.cxx
@@ -36,7 +36,7 @@
 #include <svtools/localresaccess.hxx>
 #include <tools/debug.hxx>
 #include <cppuhelper/extract.hxx>
-
+#include <sal/macros.h>
 #include <algorithm>
 #include <functional>
 
@@ -360,7 +360,7 @@ namespace pcr
         };
 
         s_pPropertyInfos = aPropertyInfos;
-        s_nCount = sizeof(aPropertyInfos) / sizeof(OPropertyInfoImpl);
+        s_nCount = SAL_N_ELEMENTS(aPropertyInfos);
 
         // sort
         ::std::sort( s_pPropertyInfos, s_pPropertyInfos + s_nCount, PropertyInfoLessByName() );
diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx
index 310d585..ef93d21 100644
--- a/extensions/source/update/check/updatecheck.cxx
+++ b/extensions/source/update/check/updatecheck.cxx
@@ -49,6 +49,7 @@
 #include <osl/process.h>
 #include <osl/module.hxx>
 #include <osl/file.hxx>
+#include <sal/macros.h>
 
 #ifdef WNT
 #ifdef _MSC_VER
@@ -577,7 +578,7 @@ UpdateCheckThread::run()
                 // Increase next by 15, 60, .. minutes
                 static const sal_Int32 nRetryInterval[] = { 900, 3600, 14400, 86400 };
                 
-                if( n < sizeof(nRetryInterval) / sizeof(sal_Int32) )
+                if( n < SAL_N_ELEMENTS(nRetryInterval) )
                     ++n;
                 
                 tv.Seconds = nRetryInterval[n-1];
@@ -689,7 +690,7 @@ DownloadThread::run()
                 // Increase next by 1, 5, 15, 60, .. minutes
                 static const sal_Int16 nRetryInterval[] = { 60, 300, 900, 3600 };
                 
-                if( n < sizeof(nRetryInterval) / sizeof(sal_Int16) )
+                if( n < SAL_N_ELEMENTS(nRetryInterval) )
                     ++n;
                 
                 tv.Seconds = nRetryInterval[n-1];
diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx
index 6f875a7..c8b9749 100644
--- a/extensions/source/update/check/updatecheckconfig.cxx
+++ b/extensions/source/update/check/updatecheckconfig.cxx
@@ -39,6 +39,7 @@
 #include <osl/security.hxx>
 #include <osl/time.h>
 #include <osl/file.hxx>
+#include <sal/macros.h>
 
 #ifdef WNT
 #ifdef _MSC_VER
@@ -91,7 +92,7 @@ static const sal_Char * const aUpdateEntryProperties[] = {
     OLD_VERSION 
 };
     
-static const sal_uInt32 nUpdateEntryProperties = sizeof(aUpdateEntryProperties) / sizeof(sal_Char *);
+static const sal_uInt32 nUpdateEntryProperties = SAL_N_ELEMENTS(aUpdateEntryProperties);
 
 //------------------------------------------------------------------------------
 
diff --git a/setup_native/source/ulfconv/ulfconv.cxx b/setup_native/source/ulfconv/ulfconv.cxx
index 201685c..11f1316 100644
--- a/setup_native/source/ulfconv/ulfconv.cxx
+++ b/setup_native/source/ulfconv/ulfconv.cxx
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <sal/alloca.h>
+#include <sal/macros.h>
 
 #include <rtl/ustring.hxx>
 
@@ -189,7 +190,7 @@ void read_encoding_table(char * file, EncodingMap& aEncodingMap)
         *cp = '\0';
         
         // find the correct mapping for codepage
-        const unsigned int members = sizeof( _ms_encoding_list ) / sizeof( _pair );
+        const unsigned int members = SAL_N_ELEMENTS( _ms_encoding_list );
         const _pair *encoding = _pair_search( codepage, _ms_encoding_list, members );
             
         if ( encoding != NULL ) {
diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
index dd47d27..be0e1ec 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
@@ -38,6 +38,7 @@
 #pragma warning(pop)
 #endif
 #include <sal/config.h>
+#include <sal/macros.h>
 #include <osl/thread.h>
 #include "securityenvironment_mscryptimpl.hxx"
 
@@ -114,11 +115,10 @@ CertErrorToString arErrStrings[] =
 
 void traceTrustStatus(DWORD err)
 {
-    int numErrors = sizeof(arErrStrings) / sizeof(CertErrorToString);
     xmlsec_trace("The certificate error status is: ");
     if (err == 0)
         xmlsec_trace("%s", arErrStrings[0].name);
-    for (int i = 1; i < numErrors; i++)
+    for (int i = 1; i < SAL_N_ELEMENTS(arErrStrings); i++)
     {
         if (arErrStrings[i].error & err)
             xmlsec_trace("%s", arErrStrings[i].name);
diff --git a/xmlsecurity/source/xmlsec/nss/secerror.cxx b/xmlsecurity/source/xmlsec/nss/secerror.cxx
index 8c44540..274841e 100644
--- a/xmlsecurity/source/xmlsec/nss/secerror.cxx
+++ b/xmlsecurity/source/xmlsec/nss/secerror.cxx
@@ -34,6 +34,7 @@
 #include "sslerr.h"
 #include "nspr.h"
 #include "certt.h"
+#include <sal/macros.h>
 
 #include "../diagnose.hxx"
 
@@ -61,7 +62,7 @@ const char *
 getCertError(PRErrorCode errNum)
 {
     static char sEmpty[] = "";
-    const int numDesc = sizeof(allDesc) / sizeof(ErrDesc);
+    const int numDesc = SAL_N_ELEMENTS(allDesc);
     for (int i = 0; i < numDesc; i++)
     {
         if (allDesc[i].errNum == errNum)
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
index 0dada06..466c532 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
@@ -37,6 +37,7 @@
 #include "ocsp.h"
 
 #include <sal/config.h>
+#include <sal/macros.h>
 #include "securityenvironment_nssimpl.hxx"
 #include "x509certificate_nssimpl.hxx"
 #include <rtl/uuid.h>
@@ -882,7 +883,7 @@ verifyCertificate( const Reference< csss::XCertificate >& aCert,
            {certificateUsageEmailRecipient, "certificateUsageEmailRecipient"}
         };
 
-        int numUsages = sizeof(arUsages) / sizeof(UsageDescription);
+        int numUsages = SAL_N_ELEMENTS(arUsages);
         for (int i = 0; i < numUsages; i++)
         {
             xmlsec_trace("Testing usage %d of %d: %s (0x%x)", i + 1,
-- 
1.7.1


--=-PqpRQIe1QgwtRJCvIGEk
Content-Disposition: attachment; filename="0001-more-Sal-n-elements-extensions.patch"
Content-Type: text/x-patch; name="0001-more-Sal-n-elements-extensions.patch"; charset="UTF-8"
Content-Transfer-Encoding: 7bit



More information about the LibreOffice mailing list