diff mbox series

[1/2] lib/libtpm: Silence compiler warnings about bad zero-length array access

Message ID 20230918122659.92014-2-thuth@redhat.com
State Superseded
Headers show
Series Silence compiler warnings in tpm code | expand

Commit Message

Thomas Huth Sept. 18, 2023, 12:26 p.m. UTC
GCC v13.2.1 complains:

tcgbios.c: In function ‘tpm20_write_EfiSpecIdEventStruct’:
tcgbios.c:708:38: warning: array subscript ‘numAlgs’ is outside the
 bounds of an interior zero-length array ‘struct
 TCG_EfiSpecIdEventAlgorithmSize[0]’ [-Wzero-length-bounds]
  708 |                 event.hdr.digestSizes[numAlgs].algorithmId =
      |                 ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~

Let's use the undefined array length declaration instead to
make GCC here happy again.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 lib/libtpm/tcgbios_int.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/libtpm/tcgbios_int.h b/lib/libtpm/tcgbios_int.h
index 22df31d..cc38455 100644
--- a/lib/libtpm/tcgbios_int.h
+++ b/lib/libtpm/tcgbios_int.h
@@ -89,7 +89,7 @@  struct TCG_EfiSpecIdEventStruct {
 	struct TCG_EfiSpecIdEventAlgorithmSize {
 		uint16_t algorithmId;
 		uint16_t digestSize;
-	} digestSizes[0];
+	} digestSizes[];
 	/*
 	uint8_t vendorInfoSize;
 	uint8_t vendorInfo[0];