Various -Werror,-Wvla-cxx-extension

...as enabled by default now in recent Clang 18 trunk

Change-Id: I59f9bbdf2ce064f170df01e6d7ec2341884ab5e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158563
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2023-10-27 13:44:27 +02:00
parent 1d86a0b632
commit f029f8dfb0
6 changed files with 30 additions and 14 deletions

View file

@ -344,7 +344,7 @@ MacabHeader *MacabRecords::createHeaderForRecordType(const CFArrayRef _records,
/* While searching through the properties for required properties, these
* sal_Bools will keep track of what we have found.
*/
bool bFoundRequiredProperties[requiredProperties.size()];
auto const bFoundRequiredProperties = std::make_unique<bool[]>(requiredProperties.size());
/* We have three MacabHeaders: headerDataForProperty is where we

View file

@ -19,6 +19,10 @@
#pragma once
#include <sal/config.h>
#include <memory>
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <unotools/resmgr.hxx>
@ -47,15 +51,15 @@ namespace connectivity::macab
CFRetain(sOrig);
CFIndex nStringLength = CFStringGetLength(sOrig);
UniChar unichars[nStringLength+1];
auto const unichars = std::make_unique<UniChar[]>(nStringLength+1);
//'close' the string buffer correctly
unichars[nStringLength] = '\0';
CFStringGetCharacters (sOrig, CFRangeMake(0,nStringLength), unichars);
CFStringGetCharacters (sOrig, CFRangeMake(0,nStringLength), unichars.get());
CFRelease(sOrig);
return OUString(reinterpret_cast<sal_Unicode *>(unichars));
return OUString(reinterpret_cast<sal_Unicode *>(unichars.get()));
}

View file

@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <memory>
#include "NSString_OOoAdditions.hxx"
@implementation NSString (OOoAdditions)
@ -32,14 +36,14 @@
{
unsigned int nFileNameLength = [self length];
UniChar unichars[nFileNameLength+1];
auto const unichars = std::make_unique<UniChar[]>(nFileNameLength+1);
//'close' the string buffer correctly
unichars[nFileNameLength] = '\0';
[self getCharacters:unichars];
[self getCharacters:unichars.get()];
return OUString(reinterpret_cast<sal_Unicode *>(unichars));
return OUString(reinterpret_cast<sal_Unicode *>(unichars.get()));
}
@end

View file

@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <memory>
// For MAXHOSTNAMELEN constant
#include <sys/param.h>
@ -157,13 +160,13 @@ static OUString CFStringToOUString(const CFStringRef sOrig) {
CFIndex nStringLen = CFStringGetLength(sOrig)+1;
// Allocate a c string buffer
char sBuffer[nStringLen];
auto const sBuffer = std::make_unique<char[]>(nStringLen);
CFStringGetCString(sOrig, sBuffer, nStringLen, kCFStringEncodingASCII);
CFStringGetCString(sOrig, sBuffer.get(), nStringLen, kCFStringEncodingASCII);
CFRelease(sOrig);
return OUString::createFromAscii(sBuffer);
return OUString::createFromAscii(sBuffer.get());
}
static OUString GetOUString( NSString* pStr )

View file

@ -19,6 +19,8 @@
#include <sal/config.h>
#include <memory>
#include <sal/macros.h>
#include <tools/helpers.hxx>
#include <tools/long.hxx>
@ -2048,7 +2050,7 @@ static NSArray *getMergedAccessibilityChildren(NSArray *pDefaultChildren, NSArra
// Skip the posting of SalEvent::ExtTextInput and
// SalEvent::EndExtTextInput events for private use area characters.
NSUInteger nLen = [pChars length];
unichar pBuf[ nLen + 1 ];
auto const pBuf = std::make_unique<unichar[]>( nLen + 1 );
NSUInteger nBufLen = 0;
for ( NSUInteger i = 0; i < nLen; i++ )
{
@ -2060,7 +2062,7 @@ static NSArray *getMergedAccessibilityChildren(NSArray *pDefaultChildren, NSArra
}
pBuf[nBufLen] = 0;
pNewMarkedText = [NSString stringWithCharacters:pBuf length:nBufLen];
pNewMarkedText = [NSString stringWithCharacters:pBuf.get() length:nBufLen];
if (!pNewMarkedText || ![pNewMarkedText length])
bNeedsExtTextInput = false;
}

View file

@ -18,6 +18,9 @@
*/
#include <sal/config.h>
#include <memory>
#include <sal/log.hxx>
#include <config_folders.h>
@ -77,8 +80,8 @@ public:
bool FontHasCharacter(CTFontRef pFont, const OUString& rString, sal_Int32 nIndex, sal_Int32 nLen)
{
CGGlyph glyphs[nLen];
return CTFontGetGlyphsForCharacters(pFont, reinterpret_cast<const UniChar*>(rString.getStr() + nIndex), glyphs, nLen);
auto const glyphs = std::make_unique<CGGlyph[]>(nLen);
return CTFontGetGlyphsForCharacters(pFont, reinterpret_cast<const UniChar*>(rString.getStr() + nIndex), glyphs.get(), nLen);
}
}