[SLOF] [PATCH slof 11/13] libtpm: Compile with -Wextra
Alexey Kardashevskiy
aik at ozlabs.ru
Wed Jan 27 19:57:50 AEDT 2021
-Wextra enables a bunch of rather useful checks which this fixes.
Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
---
lib/libtpm/tcgbios.c | 8 ++++----
lib/libtpm/tpm_drivers.c | 5 +++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
index 8e808115bc59..6baa5b44a8e6 100644
--- a/lib/libtpm/tcgbios.c
+++ b/lib/libtpm/tcgbios.c
@@ -356,7 +356,7 @@ tpm_simple_cmd(uint8_t locty, uint32_t ordinal, int param_size, uint16_t param,
memset(obuffer, 0, sizeof(obuffer));
ret = spapr_transmit(locty, &req.trqh, obuffer, &obuffer_len, to_t);
- ret = ret ? -1 : be32_to_cpu(trsh->errcode);
+ ret = ret ? -1 : (int) be32_to_cpu(trsh->errcode);
dprintf("Return from tpm_simple_cmd(%x, %x) = %x\n",
ordinal, param, ret);
@@ -382,7 +382,7 @@ tpm20_getcapability(uint32_t capability, uint32_t property, uint32_t count,
TPM_DURATION_TYPE_SHORT);
ret = (ret ||
rsize < be32_to_cpu(rsp->totlen)) ? -1
- : be32_to_cpu(rsp->errcode);
+ : (int) be32_to_cpu(rsp->errcode);
dprintf("TCGBIOS: Return value from sending TPM2_CC_GetCapability = 0x%08x\n",
ret);
@@ -664,7 +664,7 @@ static int tpm20_write_EfiSpecIdEventStruct(void)
};
struct tpms_pcr_selection *sel;
void *nsel, *end;
- int event_size;
+ unsigned event_size;
uint8_t *vendorInfoSize;
struct tpm_log_entry le = {
.hdr.eventtype = cpu_to_log32(EV_NO_ACTION),
@@ -1252,7 +1252,7 @@ tpm20_set_pcrbanks(uint32_t active_banks)
ret = spapr_transmit(0, &trpa.hdr, &rsp, &resp_length,
TPM_DURATION_TYPE_SHORT);
- ret = ret ? -1 : be32_to_cpu(rsp.errcode);
+ ret = ret ? -1 : (int) be32_to_cpu(rsp.errcode);
return ret;
}
diff --git a/lib/libtpm/tpm_drivers.c b/lib/libtpm/tpm_drivers.c
index 0e13561d0fa0..85cb3098712d 100644
--- a/lib/libtpm/tpm_drivers.c
+++ b/lib/libtpm/tpm_drivers.c
@@ -357,8 +357,7 @@ static bool spapr_vtpm_senddata(const uint8_t *const data, uint32_t len)
static bool spapr_vtpm_waitresponseready(enum tpm_duration_type to_t)
{
- uint32_t timeout = tpm2_durations[to_t];
- int i;
+ uint32_t i, timeout = tpm2_durations[to_t];
if (vtpm_drv_error_get() != VTPM_DRV_ERROR_NO_FAILURE) {
printf("%s: VTPM CRQ: In failure mode\n", __func__);
@@ -426,6 +425,8 @@ int spapr_transmit(uint8_t locty, struct tpm_req_header *req,
void *respbuffer, uint32_t *respbufferlen,
enum tpm_duration_type to_t)
{
+ if (locty)
+ return -1;
if (!spapr_vtpm_senddata((uint8_t *)req, be32_to_cpu(req->totlen)) ||
!spapr_vtpm_waitresponseready(to_t) ||
!spapr_vtpm_readresponse(respbuffer, respbufferlen) ||
--
2.17.1
More information about the SLOF
mailing list