freedreno/a2xx: Fix compiler warning in disasm.
authorEric Anholt <eric@anholt.net>
Fri, 17 Jul 2020 17:48:56 +0000 (10:48 -0700)
committerMarge Bot <eric+marge@anholt.net>
Fri, 17 Jul 2020 21:47:32 +0000 (21:47 +0000)
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

index 6f5028c3fb642291d4fa54d5d51f56fadd09ae83..b5647307038c7081473fb66b7fa789dd308891fb 100644 (file)
@@ -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]);
        }