summaryrefslogtreecommitdiff
path: root/meta-security/meta-tpm/recipes-tpm2/ibmswtpm2/files/fix-wrong-cast.patch
blob: f2938e0e09f6bea55b73de65078d620d93d15823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Fix strict aliasing issue of gcc10

fixes:

TpmFail.c: In function 'TpmLogFailure':
TpmFail.c:217:23: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  217 |     s_failFunction = *(UINT32 *)&function; /* kgold */
      |                       ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Upstream-Status: Submitted

Signed-off-by: Jens Rehsack <sno@NetBSD.org>

Index: src/TpmFail.c
===================================================================
--- src.orig/TpmFail.c	2020-09-10 15:43:57.085063875 +0200
+++ src/TpmFail.c	2020-09-10 15:48:35.563302634 +0200
@@ -214,7 +214,7 @@
     // On a 64-bit machine, this may truncate the address of the string
     // of the function name where the error occurred.
 #if FAIL_TRACE
-    s_failFunction = *(UINT32 *)&function;	/* kgold */
+    memcpy(&s_failFunction, function, sizeof(uint32_t));	/* kgold */
     s_failLine = line;
 #else
     s_failFunction = 0;