tpm2: Fix compilation error in TPM2B_CREATION_DATA_Marshal (Fedora 32/s390x)

This patch fixes the following compilation error on Fedora 32 / s390x:

tpm2/Marshal.c: In function 'TPM2B_CREATION_DATA_Marshal':
tpm2/Marshal.c:95:19: error: 'sizePtr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   95 |      (*buffer)[0] = (BYTE)((*source >> 8) & 0xff);
      |      ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tpm2/Marshal.c:2201:11: note: 'sizePtr' was declared here
 2201 |     BYTE *sizePtr;
      |           ^~~~~~~

The error is a false positive since sizePtr will have been initialized if
UINT16_Marshal() is called.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2020-08-16 20:25:12 -04:00 committed by Stefan Berger
parent dd8c4f7522
commit 5d2ae35cfc

View File

@ -2256,7 +2256,7 @@ UINT16
TPM2B_CREATION_DATA_Marshal(TPM2B_CREATION_DATA *source, BYTE **buffer, INT32 *size)
{
UINT16 written = 0;
BYTE *sizePtr;
BYTE *sizePtr = NULL; // libtpms added for s390x on Fedora 32
if (buffer != NULL) {
sizePtr = *buffer;