Mesa (master): freedreno/a2xx: Fix compiler warning in disasm.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 17 22:19:15 UTC 2020


Module: Mesa
Branch: master
Commit: 4080f8bf2b02441f637bc3f0c00c96060e2f02f0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4080f8bf2b02441f637bc3f0c00c96060e2f02f0

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jul 17 10:48:56 2020 -0700

freedreno/a2xx: Fix compiler warning in disasm.

warning: converting a packed ‘instr_cf_t’ {aka ‘union <anonymous>’}
pointer (alignment 1) to a ‘uint16_t’ {aka ‘short unsigned int’} pointer
(alignment 2) may result in an unaligned pointer value
[-Waddress-of-packed-member]

We may know that we'll only ever have aligned instr_cf_ts, but gcc
doesn't.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5955>

---

 src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c b/src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c
index 6f5028c3fb6..b5647307038 100644
--- a/src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c
+++ b/src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c
@@ -576,7 +576,8 @@ static void print_cf(instr_cf_t *cf, int level)
 {
 	printf("%s", levels[level]);
 	if (debug & PRINT_RAW) {
-		uint16_t *words = (uint16_t *)cf;
+		uint16_t words[3];
+		memcpy(&words, cf, sizeof(words));
 		printf("    %04x %04x %04x            \t",
 				words[0], words[1], words[2]);
 	}



More information about the mesa-commit mailing list