tdf#147021: Use std::size() instead of SAL_N_ELEMENTS in several modules

Change-Id: Ifcfd17b089c14033780792deb2d8e23fa26cd2b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204733
Tested-by: Jenkins
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
This commit is contained in:
Muhammad Naeem
2026-05-11 14:40:51 +02:00
committed by Jonathan Clark
parent 6bfe01ec89
commit 098e175fb5
8 changed files with 18 additions and 14 deletions
@@ -18,7 +18,7 @@
*/
#include <sal/types.h>
#include <sal/macros.h>
#include <iterator>
#include "onlinecheck.hxx"
@@ -36,7 +36,7 @@ extern "C" bool WNT_hasInternetConnection()
bool fIsConnected = InternetGetConnectedStateExW(
&dwFlags,
szConnectionName,
SAL_N_ELEMENTS(szConnectionName),
std::size(szConnectionName),
0 );
return fIsConnected;
@@ -28,6 +28,7 @@
#include <osl/time.h>
#include <osl/diagnose.h>
#include <osl/file.hxx>
#include <iterator>
#include <sal/macros.h>
#include <o3tl/char16_t2wchar_t.hxx>
@@ -74,7 +75,7 @@ const char * const aUpdateEntryProperties[] = {
OLD_VERSION
};
const sal_uInt32 nUpdateEntryProperties = SAL_N_ELEMENTS(aUpdateEntryProperties);
const sal_uInt32 nUpdateEntryProperties = static_cast<sal_uInt32>(std::size(aUpdateEntryProperties));
css::uno::Any NamedValueByNameAccess::getValue(const char * pName)
{
+2 -2
View File
@@ -82,7 +82,7 @@ FilterCache::FilterCache()
css::uno::Sequence< OUString >(sStandardProps, 3);
m_aStandardProps[E_READ_ALL] =
css::uno::Sequence< OUString >(sStandardProps,
SAL_N_ELEMENTS(sStandardProps));
std::size(sStandardProps));
i = 0;
OUString sTypeProps[7];
@@ -103,7 +103,7 @@ FilterCache::FilterCache()
css::uno::Sequence< OUString >(sTypeProps, 1);
m_aTypeProps[E_READ_ALL] =
css::uno::Sequence< OUString >(sTypeProps,
SAL_N_ELEMENTS(sTypeProps));
std::size(sTypeProps));
}
+2 -3
View File
@@ -29,11 +29,10 @@
#include <svx/labelitemwindow.hxx>
#include <iterator>
#include <utility>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/toolbox.hxx>
#include <sal/macros.h>
#include <osl/diagnose.h>
#include <tools/debug.hxx>
@@ -271,7 +270,7 @@ namespace frm
};
FeatureDescription const * pSupportedFeatures = aSupportedFeatures;
FeatureDescription const * pSupportedFeaturesEnd = aSupportedFeatures + SAL_N_ELEMENTS( aSupportedFeatures );
FeatureDescription const * pSupportedFeaturesEnd = aSupportedFeatures + std::size( aSupportedFeatures );
for ( ; pSupportedFeatures < pSupportedFeaturesEnd; ++pSupportedFeatures )
{
if ( pSupportedFeatures->nId )
@@ -34,6 +34,7 @@
#include <cstddef>
#include <cassert>
#include <iterator>
#include <memory>
#include <string_view>
#include <utility>
@@ -577,7 +578,7 @@ static void do_msvcr_magic(OUString const &jvm_dll)
};
char const* importName = reinterpret_cast<char *>(dos_hdr) + imports->Name + VAtoPhys;
sal_Int32 importNameLen = rtl_str_getLength(importName);
for (size_t i = 0; i < SAL_N_ELEMENTS(msvcrts); ++i)
for (size_t i = 0; i < std::size(msvcrts); ++i)
{
if (0 == rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
msvcrts[i].data(), msvcrts[i].size(),
+4 -3
View File
@@ -31,6 +31,7 @@
#include <salhelper/thread.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/string_view.hxx>
#include <iterator>
#include <memory>
#include <utility>
#include <algorithm>
@@ -1162,21 +1163,21 @@ void addJavaInfosDirScan(
#else // MACOSX
OUString excMessage = u"[Java framework] sunjavaplugin: "
"Error in function addJavaInfosDirScan in util.cxx."_ustr;
int cJavaNames= SAL_N_ELEMENTS(g_arJavaNames);
int cJavaNames = static_cast<int>(std::size(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= SAL_N_ELEMENTS(g_arSearchPaths);
int cSearchPaths = static_cast<int>(std::size(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 = SAL_N_ELEMENTS(g_arCollectDirs);
int cCollectDirs = static_cast<int>(std::size(g_arCollectDirs));
std::unique_ptr<OUString[]> sarCollectDirs(new OUString[cCollectDirs]);
OUString *arCollectDirs = sarCollectDirs.get();
for(int d = 0; d < cCollectDirs; d++)
+2 -1
View File
@@ -18,6 +18,7 @@
*/
#include <rtl/ref.hxx>
#include <iterator>
#include <sal/macros.h>
#include <sal/log.hxx>
#include <comphelper/processfactory.hxx>
@@ -255,7 +256,7 @@ static EventInfoHash& getEventTransInfo()
EventInfoHash tmp;
OUString sEventInfo;
const TranslatePropMap* pTransProp = aTranslatePropMap_Impl;
int nCount = SAL_N_ELEMENTS(aTranslatePropMap_Impl);
int nCount = static_cast<int>(std::size(aTranslatePropMap_Impl));
int i = 0;
while (i < nCount)
+2 -1
View File
@@ -67,6 +67,7 @@
// this one is header-only
#include <comphelper/sequence.hxx>
#include <iterator>
#include <mutex>
#include <thread>
#include <utility>
@@ -92,7 +93,7 @@ OUString generateRandomPipeId()
// compute some good pipe id:
sal_uInt8 bytes[ 32 ];
if (rtl_random_getBytes(
nullptr, bytes, SAL_N_ELEMENTS(bytes) ) != rtl_Random_E_None) {
nullptr, bytes, std::size(bytes) ) != rtl_Random_E_None) {
throw RuntimeException( u"random pool error!?"_ustr, nullptr );
}
OUStringBuffer buf;