Blame SOURCES/0157-TPM-Fix-compiler-warnings.patch

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