15a2072
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a2072
From: Hans de Goede <hdegoede@redhat.com>
15a2072
Date: Fri, 15 Jun 2018 09:58:50 +0200
15a2072
Subject: [PATCH] TPM: Fix compiler warnings
15a2072
15a2072
Stop defining our own Event type in tpm.c instead use the one from
15a2072
the header, so that it matches the function prototype.
15a2072
Note this requires some further code changes to go from all lowercaps
15a2072
of the private Event type to the CamelCaps from the header.
15a2072
15a2072
Also cast buf, which gets passed as a efi_physicall_address_t to an
15a2072
integer, to avoid the compiler complaining about passing a pointer as
15a2072
an integer.
15a2072
15a2072
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
15a2072
---
15a2072
 grub-core/kern/efi/tpm.c | 24 ++++++++----------------
15a2072
 1 file changed, 8 insertions(+), 16 deletions(-)
15a2072
15a2072
diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c
15a2072
index 36e1f69df16..0d3ebe22e57 100644
15a2072
--- a/grub-core/kern/efi/tpm.c
15a2072
+++ b/grub-core/kern/efi/tpm.c
15a2072
@@ -161,21 +161,12 @@ grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf,
15a2072
   }
15a2072
 }
15a2072
 
15a2072
-typedef struct {
15a2072
-	grub_uint32_t pcrindex;
15a2072
-	grub_uint32_t eventtype;
15a2072
-	grub_uint8_t digest[20];
15a2072
-	grub_uint32_t eventsize;
15a2072
-	grub_uint8_t event[1];
15a2072
-} Event;
15a2072
-
15a2072
-
15a2072
 static grub_err_t
15a2072
 grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf,
15a2072
 		    grub_size_t size, grub_uint8_t pcr,
15a2072
 		    const char *description)
15a2072
 {
15a2072
-  Event *event;
15a2072
+  TCG_PCR_EVENT *event;
15a2072
   grub_efi_status_t status;
15a2072
   grub_efi_tpm_protocol_t *tpm;
15a2072
   grub_efi_physical_address_t lastevent;
15a2072
@@ -188,18 +179,19 @@ grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf,
15a2072
   if (!grub_tpm_present(tpm))
15a2072
     return 0;
15a2072
 
15a2072
-  event = grub_zalloc(sizeof (Event) + grub_strlen(description) + 1);
15a2072
+  event = grub_zalloc(sizeof (TCG_PCR_EVENT) + grub_strlen(description) + 1);
15a2072
   if (!event)
15a2072
     return grub_error (GRUB_ERR_OUT_OF_MEMORY,
15a2072
 		       N_("cannot allocate TPM event buffer"));
15a2072
 
15a2072
-  event->pcrindex = pcr;
15a2072
-  event->eventtype = EV_IPL;
15a2072
-  event->eventsize = grub_strlen(description) + 1;
15a2072
-  grub_memcpy(event->event, description, event->eventsize);
15a2072
+  event->PCRIndex = pcr;
15a2072
+  event->EventType = EV_IPL;
15a2072
+  event->EventSize = grub_strlen(description) + 1;
15a2072
+  grub_memcpy(event->Event, description, event->EventSize);
15a2072
 
15a2072
   algorithm = TCG_ALG_SHA;
15a2072
-  status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size,
15a2072
+  status = efi_call_7 (tpm->log_extend_event, tpm,
15a2072
+                       (unsigned long) buf, (grub_uint64_t) size,
15a2072
 		       algorithm, event, &eventnum, &lastevent);
15a2072
 
15a2072
   switch (status) {