blob: f2938e0e09f6bea55b73de65078d620d93d15823 [file] [log] [blame]
Andrew Geisslercc589282020-09-18 13:34:40 -05001Fix strict aliasing issue of gcc10
2
3fixes:
4
5TpmFail.c: In function 'TpmLogFailure':
6TpmFail.c:217:23: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
7 217 | s_failFunction = *(UINT32 *)&function; /* kgold */
8 | ^~~~~~~~~~~~~~~~~~~
9cc1: all warnings being treated as errors
10
11Upstream-Status: Submitted
12
13Signed-off-by: Jens Rehsack <sno@NetBSD.org>
14
15Index: src/TpmFail.c
16===================================================================
17--- src.orig/TpmFail.c 2020-09-10 15:43:57.085063875 +0200
18+++ src/TpmFail.c 2020-09-10 15:48:35.563302634 +0200
19@@ -214,7 +214,7 @@
20 // On a 64-bit machine, this may truncate the address of the string
21 // of the function name where the error occurred.
22 #if FAIL_TRACE
23- s_failFunction = *(UINT32 *)&function; /* kgold */
24+ memcpy(&s_failFunction, function, sizeof(uint32_t)); /* kgold */
25 s_failLine = line;
26 #else
27 s_failFunction = 0;