Module Name:    src
Committed By:   mrg
Date:           Tue Aug 15 05:01:58 UTC 2023

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core:
            amdgpu_dc_stream.c

Log Message:
avoid a GCC 12 warning.

there's a 1-element long array and a loop conditional that tries to see
if indexes for it are not identical.  as these indexes will always both
be 0, the only valid index, the condition is always false.  GCC 12
triggers a strange warning on this code that can never run (see below),
so simply assert the array size is 1 and comment the rest.

amdgpu_dc_stream.c:470:55: error: array subscript [0, 0] is outside array 
bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
  470 |                                 stream->writeback_info[j] = 
stream->writeback_info[i];


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
    src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c:1.2 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c:1.3
--- src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c:1.2	Sat Dec 18 23:45:02 2021
+++ src/sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c	Tue Aug 15 05:01:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_dc_stream.c,v 1.2 2021/12/18 23:45:02 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_dc_stream.c,v 1.3 2023/08/15 05:01:57 mrg Exp $	*/
 
 /*
  * Copyright 2012-15 Advanced Micro Devices, Inc.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_dc_stream.c,v 1.2 2021/12/18 23:45:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_dc_stream.c,v 1.3 2023/08/15 05:01:57 mrg Exp $");
 
 #include <linux/delay.h>
 #include <linux/slab.h>
@@ -465,9 +465,18 @@ bool dc_stream_remove_writeback(struct d
 	/* remove writeback info for disabled writeback pipes from stream */
 	for (i = 0, j = 0; i < stream->num_wb_info; i++) {
 		if (stream->writeback_info[i].wb_enabled) {
+#ifdef __NetBSD__
+			/*
+			 * XXXGCC12
+			 * The array is only 1 entry long, so i and j must
+			 * always be 0 here, so the below test fails.
+			 */
+			CTASSERT(ARRAY_SIZE(stream->writeback_info) == 1);
+#else
 			if (i != j)
 				/* trim the array */
 				stream->writeback_info[j] = stream->writeback_info[i];
+#endif
 			j++;
 		}
 	}

Reply via email to