[coreboot-gerrit] Change in coreboot[master]: security/tpm: Fix coding style and uninitialized variable
Philipp Deppenwiese (Code Review)
gerrit at coreboot.org
Tue Dec 5 20:21:18 CET 2017
Philipp Deppenwiese has uploaded this change for review. ( https://review.coreboot.org/22734
Change subject: security/tpm: Fix coding style and uninitialized variable
......................................................................
security/tpm: Fix coding style and uninitialized variable
Change-Id: Ifa93c91aab97c663df66dfdc4d1afb3a43736adb
Signed-off-by: Philipp Deppenwiese <zaolin at das-labor.org>
---
M src/security/tpm/tss/tcg-1.2/tss.c
1 file changed, 23 insertions(+), 28 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/22734/1
diff --git a/src/security/tpm/tss/tcg-1.2/tss.c b/src/security/tpm/tss/tcg-1.2/tss.c
index b6a61c1..1602ba1 100644
--- a/src/security/tpm/tss/tcg-1.2/tss.c
+++ b/src/security/tpm/tss/tcg-1.2/tss.c
@@ -16,26 +16,24 @@
#include <arch/early_variables.h>
#include <assert.h>
-#include <string.h>
#include <security/tpm/tis.h>
-#include <vb2_api.h>
#include <security/tpm/tss.h>
+#include <string.h>
+#include <vb2_api.h>
-#include "tss_internal.h"
#include "tss_commands.h"
+#include "tss_internal.h"
#ifdef FOR_TEST
#include <stdio.h>
-#define VBDEBUG(format, args...) printf(format, ## args)
+#define VBDEBUG(format, args...) printf(format, ##args)
#else
#include <console/console.h>
-#define VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ## args)
+#define VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ##args)
#endif
-static int tpm_send_receive(const uint8_t *request,
- uint32_t request_length,
- uint8_t *response,
- uint32_t *response_length)
+static int tpm_send_receive(const uint8_t *request, uint32_t request_length,
+ uint8_t *response, uint32_t *response_length)
{
size_t len = *response_length;
if (tis_sendrecv(request, request_length, response, &len))
@@ -54,12 +52,12 @@
}
/* Gets the size field of a TPM command. */
-__attribute__((unused))
-static inline int tpm_command_size(const uint8_t *buffer)
+__attribute__((unused)) static inline int
+tpm_command_size(const uint8_t *buffer)
{
uint32_t size;
from_tpm_uint32(buffer + sizeof(uint16_t), &size);
- return (int) size;
+ return (int)size;
}
/* Gets the code field of a TPM command. */
@@ -85,8 +83,8 @@
uint32_t response_length = max_length;
uint32_t result;
- result = tpm_send_receive(request, tpm_command_size(request),
- response, &response_length);
+ result = tpm_send_receive(request, tpm_command_size(request), response,
+ &response_length);
if (result != 0) {
/* Communication with TPM failed, so response is garbage */
VBDEBUG("TPM: command 0x%x send/receive failed: 0x%x\n",
@@ -100,20 +98,19 @@
* (and possibly expected length from the response header). See
* crosbug.com/17017 */
- VBDEBUG("TPM: command 0x%x returned 0x%x\n",
- tpm_command_code(request), result);
+ VBDEBUG("TPM: command 0x%x returned 0x%x\n", tpm_command_code(request),
+ result);
-return result;
+ return result;
}
-
/* Sends a TPM command and gets a response. Returns 0 if success or the TPM
* error code if error. Waits for the self test to complete if needed. */
uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response,
int max_length)
{
- uint32_t result = tlcl_send_receive_no_retry(request, response,
- max_length);
+ uint32_t result =
+ tlcl_send_receive_no_retry(request, response, max_length);
/* If the command fails because the self test has not completed, try it
* again after attempting to ensure that the self test has completed. */
if (result == TPM_E_NEEDS_SELFTEST || result == TPM_E_DOING_SELFTEST) {
@@ -122,8 +119,8 @@
return result;
#if defined(TPM_BLOCKING_CONTINUESELFTEST) || defined(VB_RECOVERY_MODE)
/* Retry only once */
- result = tlcl_send_receive_no_retry(request, response,
- max_length);
+ result =
+ tlcl_send_receive_no_retry(request, response, max_length);
#else
/* This needs serious testing. The TPM specification says: "iii.
* The caller MUST wait for the actions of TPM_ContinueSelfTest
@@ -209,7 +206,7 @@
struct s_tpm_nv_write_cmd cmd;
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
const int total_length =
- kTpmRequestHeaderLength + kWriteInfoLength + length;
+ kTpmRequestHeaderLength + kWriteInfoLength + length;
VBDEBUG("TPM: tlcl_write(0x%x, %d)\n", index, length);
memcpy(&cmd, &tpm_nv_write_cmd, sizeof(cmd));
@@ -245,7 +242,6 @@
return result;
}
-
uint32_t tlcl_assert_physical_presence(void)
{
@@ -327,13 +323,12 @@
uint32_t tlcl_set_global_lock(void)
{
- uint32_t x;
+ uint32_t x = 0;
VBDEBUG("TPM: Set global lock\n");
- return tlcl_write(TPM_NV_INDEX0, (uint8_t *) &x, 0);
+ return tlcl_write(TPM_NV_INDEX0, (uint8_t *)&x, 0);
}
-uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest,
- uint8_t *out_digest)
+uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest, uint8_t *out_digest)
{
struct s_tpm_extend_cmd cmd;
uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength];
--
To view, visit https://review.coreboot.org/22734
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa93c91aab97c663df66dfdc4d1afb3a43736adb
Gerrit-Change-Number: 22734
Gerrit-PatchSet: 1
Gerrit-Owner: Philipp Deppenwiese <zaolin.daisuki at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171205/b097c730/attachment.html>
More information about the coreboot-gerrit
mailing list