Module Name:    src
Committed By:   kamil
Date:           Sat Feb 23 19:56:51 UTC 2019

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_display.c

Log Message:
Rearrange code in amdgpu_display.c to prevent build error

GCC reports that stat can be uninitialized when used, prevent this with
changing the construction of the code a little bit.

Keep original indent in order to not generate diff with upstream.

Solution suggested by <mrg>

Detected with GCC7 when building NetBSD/i386 with kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
    src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_display.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/amdgpu/amdgpu_display.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_display.c:1.4 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_display.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_display.c:1.4	Mon Aug 27 15:22:54 2018
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_display.c	Sat Feb 23 19:56:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_display.c,v 1.4 2018/08/27 15:22:54 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_display.c,v 1.5 2019/02/23 19:56:51 kamil Exp $	*/
 
 /*
  * Copyright 2007-8 Advanced Micro Devices, Inc.
@@ -26,7 +26,7 @@
  *          Alex Deucher
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_display.c,v 1.4 2018/08/27 15:22:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_display.c,v 1.5 2019/02/23 19:56:51 kamil Exp $");
 
 #include <drm/drmP.h>
 #include <drm/amdgpu_drm.h>
@@ -101,7 +101,8 @@ static void amdgpu_flip_work_func(struct
 	 * In practice this won't execute very often unless on very fast
 	 * machines because the time window for this to happen is very small.
 	 */
-	while (amdgpuCrtc->enabled && --repcnt) {
+	if (amdgpuCrtc->enabled) {
+	while (--repcnt) {
 		/* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank
 		 * start in hpos, and to the "fudged earlier" vblank start in
 		 * vpos.
@@ -134,6 +135,7 @@ static void amdgpu_flip_work_func(struct
 				 "hpos %d\n", work->crtc_id, min_udelay,
 				 vblank->framedur_ns / 1000,
 				 vblank->linedur_ns / 1000, stat, vpos, hpos);
+	}
 
 	/* do the flip (mmio) */
 	adev->mode_info.funcs->page_flip(adev, work->crtc_id, work->base);

Reply via email to