[vlc-commits] [Git][videolan/vlc][master] vout: apple: avoid warning about VLA folded into array

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Sep 24 06:09:49 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
dd8071a1 by Marvin Scholz at 2025-09-24T05:47:36+00:00
vout: apple: avoid warning about VLA folded into array

A const int is not an integer constant and recent compiler versions
warn about this, we can easily avoid this by not hardcoding any size
at all and just check the sizes of the two arrays match for safety.

- - - - -


1 changed file:

- modules/video_output/apple/VLCSampleBufferDisplay.m


Changes:

=====================================
modules/video_output/apple/VLCSampleBufferDisplay.m
=====================================
@@ -131,12 +131,8 @@ typedef NS_ENUM(NSUInteger, VLCSampleBufferPixelFlip) {
         uint32_t srcHeight = CVPixelBufferGetHeight(pixelBuffer);
         uint32_t dstWidth = rotated ? srcHeight : srcWidth;
         uint32_t dstHeight = rotated ? srcWidth : srcHeight;
-#if defined(TARGET_OS_VISION) && TARGET_OS_VISION
-        const int numValues = 5;
-#else
-        const int numValues = 6;
-#endif
-        CFTypeRef keys[numValues] = {
+
+        CFTypeRef keys[] = {
             kCVPixelBufferPixelFormatTypeKey,
             kCVPixelBufferWidthKey,
             kCVPixelBufferHeightKey,
@@ -149,7 +145,7 @@ typedef NS_ENUM(NSUInteger, VLCSampleBufferPixelFlip) {
 #endif
         };
 
-        CFTypeRef values[numValues] = {
+        CFTypeRef values[] = {
             (__bridge CFNumberRef)(@(CVPixelBufferGetPixelFormatType(pixelBuffer))),
             (__bridge CFNumberRef)(@(dstWidth)),
             (__bridge CFNumberRef)(@(dstHeight)),
@@ -159,8 +155,10 @@ typedef NS_ENUM(NSUInteger, VLCSampleBufferPixelFlip) {
             kCFBooleanTrue
 #endif
         };
+        _Static_assert(ARRAY_SIZE(keys) == ARRAY_SIZE(values),
+            "Mismatch between keys and values array sizes");
 
-        CFDictionaryRef poolAttr = CFDictionaryCreate(NULL, keys, values, numValues, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        CFDictionaryRef poolAttr = CFDictionaryCreate(NULL, keys, values, ARRAY_SIZE(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
 
         OSStatus status = CVPixelBufferPoolCreate(NULL, NULL, poolAttr, &_rotationPool);
         CFRelease(poolAttr);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/dd8071a150d28c7abcdea6429c7a452a25150b3f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/dd8071a150d28c7abcdea6429c7a452a25150b3f
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list