Andrew Geissler | cc58928 | 2020-09-18 13:34:40 -0500 | [diff] [blame] | 1 | Fix strict aliasing issue of gcc10 |
| 2 | |
| 3 | fixes: |
| 4 | |
| 5 | TpmFail.c: In function 'TpmLogFailure': |
| 6 | TpmFail.c:217:23: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] |
| 7 | 217 | s_failFunction = *(UINT32 *)&function; /* kgold */ |
| 8 | | ^~~~~~~~~~~~~~~~~~~ |
| 9 | cc1: all warnings being treated as errors |
| 10 | |
| 11 | Upstream-Status: Submitted |
| 12 | |
| 13 | Signed-off-by: Jens Rehsack <sno@NetBSD.org> |
| 14 | |
| 15 | Index: 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; |