summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabe Black <gabeblack@chromium.org>2013-03-16 04:03:40 -0700
committerChromeBot <chrome-bot@google.com>2013-03-19 16:55:44 -0700
commitac8805e7e9bd40c03baf44e37b26f28d9b763ab5 (patch)
tree9297d954f0fc50bb9de01fb9672ddaea076e2f01
parent77f55ca1cd282ac6c540ea3a8bacbc35c2600d60 (diff)
downloadvboot-ac8805e7e9bd40c03baf44e37b26f28d9b763ab5.tar.gz
Get rid of some crufty macros.
These were macros that were never used, or that were only set to one thing and could be substituted up front. I left in code guarded by the HAVE_ENDIAN_H and HAVE_LITTLE_ENDIAN macros even though those are never defined because they guard a reportedly significantly faster implementation of some functionality, at least according to a comment in the source. It would be a good idea to enable that code path and see if it really does make a big difference before removing it entirely. BUG=None TEST=Built for Link, Daisy, and the host with FEATURES=test. Built depthcharge for Link and booted in normal mode. BRANCH=None Change-Id: I934a4dd0da169ac018ba07350d56924ab88b1acc Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: https://gerrit.chromium.org/gerrit/45687 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Gabe Black <gabeblack@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org>
-rw-r--r--firmware/include/bmpblk_header.h4
-rw-r--r--firmware/include/load_kernel_fw.h4
-rw-r--r--firmware/include/sysincludes.h16
-rw-r--r--firmware/include/utility.h17
-rw-r--r--firmware/include/vboot_struct.h12
-rw-r--r--firmware/lib/cgptlib/include/gpt.h4
-rw-r--r--firmware/lib/cryptolib/rsa.c8
-rw-r--r--firmware/lib/cryptolib/sha1.c2
-rw-r--r--firmware/lib/cryptolib/sha512.c20
-rw-r--r--firmware/lib/include/bmpblk_font.h4
-rw-r--r--firmware/lib/include/rollback_index.h4
-rw-r--r--firmware/lib/rollback_index.c6
-rw-r--r--firmware/lib/tpm_lite/include/tlcl_internal.h16
-rw-r--r--firmware/lib/tpm_lite/tlcl.c9
-rw-r--r--firmware/lib/vboot_api_firmware.c4
-rw-r--r--firmware/lib/vboot_api_init.c2
-rw-r--r--firmware/lib/vboot_firmware.c13
-rw-r--r--firmware/lib/vboot_kernel.c6
-rw-r--r--firmware/stub/tpm_lite_stub.c8
-rw-r--r--firmware/stub/vboot_api_stub.c3
-rw-r--r--firmware/stub/vboot_api_stub_disk.c3
-rw-r--r--firmware/stub/vboot_api_stub_init.c3
-rw-r--r--firmware/stub/vboot_api_stub_sf.c3
-rw-r--r--tests/big_firmware_tests.c2
-rw-r--r--tests/big_kernel_tests.c2
-rw-r--r--tests/cgptlib_test.c3
-rw-r--r--tests/cgptlib_test.h3
-rw-r--r--tests/rollback_index2_tests.c3
-rw-r--r--tests/rollback_index3_tests.c3
-rw-r--r--tests/sha_tests.c3
-rw-r--r--tests/stateful_util_tests.c3
-rw-r--r--tests/timer_utils.h2
-rw-r--r--tests/tpm_bootmode_tests.c3
-rw-r--r--tests/utility_string_tests.c11
-rw-r--r--tests/utility_tests.c19
-rw-r--r--tests/vboot_api_devmode_tests.c3
-rw-r--r--tests/vboot_api_firmware_tests.c3
-rw-r--r--tests/vboot_api_init_tests.c3
-rw-r--r--tests/vboot_audio_tests.c3
-rw-r--r--tests/vboot_common_tests.c3
-rw-r--r--tests/vboot_firmware_tests.c3
-rw-r--r--tests/vboot_nvstorage_test.c3
-rw-r--r--utility/load_kernel_test.c7
43 files changed, 57 insertions, 199 deletions
diff --git a/firmware/include/bmpblk_header.h b/firmware/include/bmpblk_header.h
index 5957c31c..1b04bf70 100644
--- a/firmware/include/bmpblk_header.h
+++ b/firmware/include/bmpblk_header.h
@@ -47,8 +47,6 @@
#include "sysincludes.h"
-__pragma(pack(push, 1)) /* Support packing for MSVC. */
-
#define BMPBLOCK_SIGNATURE "$BMP"
#define BMPBLOCK_SIGNATURE_SIZE (4)
@@ -149,6 +147,4 @@ typedef enum Compression {
#define RENDER_HWID "$HWID"
#define RENDER_HWID_RTOL "$HWID.rtol"
-__pragma(pack(pop)) /* Support packing for MSVC. */
-
#endif /* VBOOT_REFERENCE_BMPBLK_HEADER_H_ */
diff --git a/firmware/include/load_kernel_fw.h b/firmware/include/load_kernel_fw.h
index 7e8d6960..7439e57c 100644
--- a/firmware/include/load_kernel_fw.h
+++ b/firmware/include/load_kernel_fw.h
@@ -17,9 +17,9 @@
/* Boot flags for LoadKernel().boot_flags */
/* Developer switch is on */
-#define BOOT_FLAG_DEVELOPER UINT64_C(0x01)
+#define BOOT_FLAG_DEVELOPER (0x01ULL)
/* In recovery mode */
-#define BOOT_FLAG_RECOVERY UINT64_C(0x02)
+#define BOOT_FLAG_RECOVERY (0x02ULL)
typedef struct LoadKernelParams {
/* Inputs to LoadKernel() */
diff --git a/firmware/include/sysincludes.h b/firmware/include/sysincludes.h
index 34aebdab..490b51cc 100644
--- a/firmware/include/sysincludes.h
+++ b/firmware/include/sysincludes.h
@@ -25,20 +25,4 @@
#include <memory.h>
#endif
-#define POSSIBLY_UNUSED __attribute__((unused))
-
-#ifdef __STRICT_ANSI__
-#define INLINE
-#else
-#define INLINE inline
-#endif
-
-#ifndef _MSC_VER
-#define __pragma(...)
-#endif
-
-/* 64-bit operations, for platforms where they need to be function calls */
-#define UINT64_RSHIFT(v, shiftby) (((uint64_t)(v)) >> (shiftby))
-#define UINT64_MULT32(v, multby) (((uint64_t)(v)) * ((uint32_t)(multby)))
-
#endif /* VBOOT_REFERENCE_SYSINCLUDES_H_ */
diff --git a/firmware/include/utility.h b/firmware/include/utility.h
index 8fe82772..f6575ed5 100644
--- a/firmware/include/utility.h
+++ b/firmware/include/utility.h
@@ -20,23 +20,6 @@
#define VBDEBUG(params)
#endif
-#ifndef VBOOT_PERFORMANCE
-/*
- * Define performance macros as nothing. If you enable VBOOT_PERFORMANCE,
- * you must define these macros in your platform's biosincludes.h.
- *
- * Intended usage for using a performance counter called 'foo':
- *
- * VBPERFSTART("foo")
- * ...code to be tested...
- * VBPERFEND("foo")
- *
- * Names should be <= 8 characters to be compatible with all platforms.
- */
-#define VBPERFSTART(name)
-#define VBPERFEND(name)
-#endif
-
#ifdef VBOOT_DEBUG
#define VbAssert(expr) do { if (!(expr)) { \
VbExError("assert fail: %s at %s:%d\n", \
diff --git a/firmware/include/vboot_struct.h b/firmware/include/vboot_struct.h
index 8023cdc9..ee912a30 100644
--- a/firmware/include/vboot_struct.h
+++ b/firmware/include/vboot_struct.h
@@ -11,8 +11,6 @@
#include "sysincludes.h"
-__pragma(pack(push, 1)) /* Support packing for MSVC. */
-
/* Public key data */
typedef struct VbPublicKey {
/* Offset of key data from start of this struct */
@@ -47,10 +45,10 @@ typedef struct VbSignature {
/* Flags for key_block_flags */
/* The following flags set where the key is valid */
-#define KEY_BLOCK_FLAG_DEVELOPER_0 UINT64_C(0x01) /* Developer switch off */
-#define KEY_BLOCK_FLAG_DEVELOPER_1 UINT64_C(0x02) /* Developer switch on */
-#define KEY_BLOCK_FLAG_RECOVERY_0 UINT64_C(0x04) /* Not recovery mode */
-#define KEY_BLOCK_FLAG_RECOVERY_1 UINT64_C(0x08) /* Recovery mode */
+#define KEY_BLOCK_FLAG_DEVELOPER_0 (0x01ULL) /* Developer switch off */
+#define KEY_BLOCK_FLAG_DEVELOPER_1 (0x02ULL) /* Developer switch on */
+#define KEY_BLOCK_FLAG_RECOVERY_0 (0x04ULL) /* Not recovery mode */
+#define KEY_BLOCK_FLAG_RECOVERY_1 (0x08ULL) /* Recovery mode */
/*
* Key block, containing the public key used to sign some other chunk of data.
@@ -505,6 +503,4 @@ typedef struct VbSharedDataHeader {
#define VB_SHARED_DATA_VERSION 2 /* Version for struct_version */
-__pragma(pack(pop)) /* Support packing for MSVC. */
-
#endif /* VBOOT_REFERENCE_VBOOT_STRUCT_H_ */
diff --git a/firmware/lib/cgptlib/include/gpt.h b/firmware/lib/cgptlib/include/gpt.h
index 5e60e957..0418655b 100644
--- a/firmware/lib/cgptlib/include/gpt.h
+++ b/firmware/lib/cgptlib/include/gpt.h
@@ -12,8 +12,6 @@
#include "sysincludes.h"
-__pragma(pack(push,1)) /* Support packing for MSVC. */
-
#define GPT_HEADER_SIGNATURE "EFI PART"
#define GPT_HEADER_SIGNATURE2 "CHROMEOS"
#define GPT_HEADER_SIGNATURE_SIZE sizeof(GPT_HEADER_SIGNATURE)
@@ -114,6 +112,4 @@ typedef struct {
#define GPTENTRY_EXPECTED_SIZE 128
-__pragma(pack(pop)) /* Support packing for MSVC. */
-
#endif /* VBOOT_REFERENCE_CGPTLIB_GPT_H_ */
diff --git a/firmware/lib/cryptolib/rsa.c b/firmware/lib/cryptolib/rsa.c
index d552e13e..897816e8 100644
--- a/firmware/lib/cryptolib/rsa.c
+++ b/firmware/lib/cryptolib/rsa.c
@@ -39,14 +39,14 @@ static void montMulAdd(const RSAPublicKey *key,
uint32_t* c,
const uint32_t a,
const uint32_t* b) {
- uint64_t A = UINT64_MULT32(a, b[0]) + c[0];
+ uint64_t A = (uint64_t)a * b[0] + c[0];
uint32_t d0 = (uint32_t)A * key->n0inv;
- uint64_t B = UINT64_MULT32(d0, key->n[0]) + (uint32_t)A;
+ uint64_t B = (uint64_t)d0 * key->n[0] + (uint32_t)A;
uint32_t i;
for (i = 1; i < key->len; ++i) {
- A = (A >> 32) + UINT64_MULT32(a, b[i]) + c[i];
- B = (B >> 32) + UINT64_MULT32(d0, key->n[i]) + (uint32_t)A;
+ A = (A >> 32) + (uint64_t)a * b[i] + c[i];
+ B = (B >> 32) + (uint64_t)d0 * key->n[i] + (uint32_t)A;
c[i - 1] = (uint32_t)B;
}
diff --git a/firmware/lib/cryptolib/sha1.c b/firmware/lib/cryptolib/sha1.c
index fa7e6653..0a3f8f6a 100644
--- a/firmware/lib/cryptolib/sha1.c
+++ b/firmware/lib/cryptolib/sha1.c
@@ -247,7 +247,7 @@ uint8_t* SHA1_final(SHA1_CTX *ctx) {
SHA1_update(ctx, (uint8_t*)"\0", 1);
}
for (i = 0; i < 8; ++i) {
- uint8_t tmp = (uint8_t)UINT64_RSHIFT(cnt, (7 - i) * 8);
+ uint8_t tmp = (uint8_t)((uint64_t)cnt >> ((7 - i) * 8));
SHA1_update(ctx, &tmp, 1);
}
diff --git a/firmware/lib/cryptolib/sha512.c b/firmware/lib/cryptolib/sha512.c
index 3a45be51..66c9a35f 100644
--- a/firmware/lib/cryptolib/sha512.c
+++ b/firmware/lib/cryptolib/sha512.c
@@ -57,16 +57,16 @@
*((str) + 0) = (uint8_t) ((x) >> 24); \
}
-#define UNPACK64(x, str) \
- { \
- *((str) + 7) = (uint8_t) x; \
- *((str) + 6) = (uint8_t) UINT64_RSHIFT(x, 8); \
- *((str) + 5) = (uint8_t) UINT64_RSHIFT(x, 16); \
- *((str) + 4) = (uint8_t) UINT64_RSHIFT(x, 24); \
- *((str) + 3) = (uint8_t) UINT64_RSHIFT(x, 32); \
- *((str) + 2) = (uint8_t) UINT64_RSHIFT(x, 40); \
- *((str) + 1) = (uint8_t) UINT64_RSHIFT(x, 48); \
- *((str) + 0) = (uint8_t) UINT64_RSHIFT(x, 56); \
+#define UNPACK64(x, str) \
+ { \
+ *((str) + 7) = (uint8_t) x; \
+ *((str) + 6) = (uint8_t) ((uint64_t)x >> 8); \
+ *((str) + 5) = (uint8_t) ((uint64_t)x >> 16); \
+ *((str) + 4) = (uint8_t) ((uint64_t)x >> 24); \
+ *((str) + 3) = (uint8_t) ((uint64_t)x >> 32); \
+ *((str) + 2) = (uint8_t) ((uint64_t)x >> 40); \
+ *((str) + 1) = (uint8_t) ((uint64_t)x >> 48); \
+ *((str) + 0) = (uint8_t) ((uint64_t)x >> 56); \
}
#define PACK64(str, x) \
diff --git a/firmware/lib/include/bmpblk_font.h b/firmware/lib/include/bmpblk_font.h
index b79274cc..24f908ea 100644
--- a/firmware/lib/include/bmpblk_font.h
+++ b/firmware/lib/include/bmpblk_font.h
@@ -39,8 +39,6 @@
#include "bmpblk_header.h"
-__pragma(pack(push, 1)) /* Support packing for MSVC. */
-
#define FONT_SIGNATURE "FONT"
#define FONT_SIGNATURE_SIZE 4
@@ -62,6 +60,4 @@ typedef struct FontArrayEntryHeader {
*/
} __attribute__((packed)) FontArrayEntryHeader;
-__pragma(pack(pop)) /* Support packing for MSVC. */
-
#endif /* VBOOT_REFERENCE_BMPBLK_FONT_H_ */
diff --git a/firmware/lib/include/rollback_index.h b/firmware/lib/include/rollback_index.h
index c8b0147b..748dce97 100644
--- a/firmware/lib/include/rollback_index.h
+++ b/firmware/lib/include/rollback_index.h
@@ -18,8 +18,6 @@
/* Structure definitions for TPM spaces */
-__pragma(pack(push, 1)) /* Support packing for MSVC. */
-
/* Kernel space - KERNEL_NV_INDEX, locked with physical presence. */
#define ROLLBACK_SPACE_KERNEL_VERSION 2
#define ROLLBACK_SPACE_KERNEL_UID 0x4752574C /* 'GRWL' */
@@ -68,8 +66,6 @@ typedef struct RollbackSpaceFirmware {
uint8_t crc8;
} __attribute__((packed)) RollbackSpaceFirmware;
-__pragma(pack(pop)) /* Support packing for MSVC. */
-
/* All functions return TPM_SUCCESS (zero) if successful, non-zero if error */
/*
diff --git a/firmware/lib/rollback_index.c b/firmware/lib/rollback_index.c
index 11bc12d5..e430bea6 100644
--- a/firmware/lib/rollback_index.c
+++ b/firmware/lib/rollback_index.c
@@ -38,9 +38,6 @@ uint32_t WriteSpaceKernel(RollbackSpaceKernel *rsk);
static int g_rollback_recovery_mode = 0;
-/* disable MSVC warning on const logical expression (as in } while(0);) */
-__pragma(warning (disable: 4127))
-
#define RETURN_ON_FAILURE(tpm_command) do { \
uint32_t result_; \
if ((result_ = (tpm_command)) != TPM_SUCCESS) { \
@@ -484,9 +481,6 @@ uint32_t SetupTPM(int recovery_mode, int developer_mode,
return TPM_SUCCESS;
}
-/* Disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
#ifdef DISABLE_ROLLBACK_TPM
/* Dummy implementations which don't support TPM rollback protection */
diff --git a/firmware/lib/tpm_lite/include/tlcl_internal.h b/firmware/lib/tpm_lite/include/tlcl_internal.h
index 91d3ee15..51fe6ef3 100644
--- a/firmware/lib/tpm_lite/include/tlcl_internal.h
+++ b/firmware/lib/tpm_lite/include/tlcl_internal.h
@@ -22,8 +22,8 @@
* command buffer. FromTpmTYPE gets a value of type TYPE from a TPM command
* buffer into a variable.
*/
-POSSIBLY_UNUSED
-static INLINE void ToTpmUint32(uint8_t *buffer, uint32_t x) {
+__attribute__((unused))
+static inline void ToTpmUint32(uint8_t *buffer, uint32_t x) {
buffer[0] = (uint8_t)(x >> 24);
buffer[1] = (uint8_t)((x >> 16) & 0xff);
buffer[2] = (uint8_t)((x >> 8) & 0xff);
@@ -33,8 +33,8 @@ static INLINE void ToTpmUint32(uint8_t *buffer, uint32_t x) {
/*
* See comment for above function.
*/
-POSSIBLY_UNUSED
-static INLINE void FromTpmUint32(const uint8_t *buffer, uint32_t *x) {
+__attribute__((unused))
+static inline void FromTpmUint32(const uint8_t *buffer, uint32_t *x) {
*x = ((buffer[0] << 24) |
(buffer[1] << 16) |
(buffer[2] << 8) |
@@ -44,8 +44,8 @@ static INLINE void FromTpmUint32(const uint8_t *buffer, uint32_t *x) {
/*
* See comment for above function.
*/
-POSSIBLY_UNUSED
-static INLINE void ToTpmUint16(uint8_t *buffer, uint16_t x) {
+__attribute__((unused))
+static inline void ToTpmUint16(uint8_t *buffer, uint16_t x) {
buffer[0] = (uint8_t)(x >> 8);
buffer[1] = (uint8_t)(x & 0xff);
}
@@ -53,8 +53,8 @@ static INLINE void ToTpmUint16(uint8_t *buffer, uint16_t x) {
/*
* See comment for above function.
*/
-POSSIBLY_UNUSED
-static INLINE void FromTpmUint16(const uint8_t *buffer, uint16_t *x) {
+__attribute__((unused))
+static inline void FromTpmUint16(const uint8_t *buffer, uint16_t *x) {
*x = (buffer[0] << 8) | buffer[1];
}
diff --git a/firmware/lib/tpm_lite/tlcl.c b/firmware/lib/tpm_lite/tlcl.c
index 7acca9a1..50b3877b 100644
--- a/firmware/lib/tpm_lite/tlcl.c
+++ b/firmware/lib/tpm_lite/tlcl.c
@@ -27,12 +27,13 @@
#endif
/* Sets the size field of a TPM command. */
-static INLINE void SetTpmCommandSize(uint8_t* buffer, uint32_t size) {
+static inline void SetTpmCommandSize(uint8_t* buffer, uint32_t size) {
ToTpmUint32(buffer + sizeof(uint16_t), size);
}
/* Gets the size field of a TPM command. */
-POSSIBLY_UNUSED static INLINE int TpmCommandSize(const uint8_t* buffer) {
+__attribute__((unused))
+static inline int TpmCommandSize(const uint8_t* buffer) {
uint32_t size;
FromTpmUint32(buffer + sizeof(uint16_t), &size);
return (int) size;
@@ -44,14 +45,14 @@ int TlclPacketSize(const uint8_t* packet) {
}
/* Gets the code field of a TPM command. */
-static INLINE int TpmCommandCode(const uint8_t* buffer) {
+static inline int TpmCommandCode(const uint8_t* buffer) {
uint32_t code;
FromTpmUint32(buffer + sizeof(uint16_t) + sizeof(uint32_t), &code);
return code;
}
/* Gets the return code field of a TPM result. */
-static INLINE int TpmReturnCode(const uint8_t* buffer) {
+static inline int TpmReturnCode(const uint8_t* buffer) {
return TpmCommandCode(buffer);
}
diff --git a/firmware/lib/vboot_api_firmware.c b/firmware/lib/vboot_api_firmware.c
index 0d0c2262..5889e939 100644
--- a/firmware/lib/vboot_api_firmware.c
+++ b/firmware/lib/vboot_api_firmware.c
@@ -62,10 +62,8 @@ VbError_t VbSelectFirmware(VbCommonParams *cparams,
/* Update TPM if necessary */
if (shared->fw_version_tpm_start < shared->fw_version_tpm) {
- VBPERFSTART("VB_TPMU");
tpm_status =
RollbackFirmwareWrite(shared->fw_version_tpm);
- VBPERFEND("VB_TPMU");
if (0 != tpm_status) {
VBDEBUG(("Can't write FW version to TPM.\n"));
VbNvSet(&vnc, VBNV_RECOVERY_REQUEST,
@@ -76,9 +74,7 @@ VbError_t VbSelectFirmware(VbCommonParams *cparams,
}
/* Lock firmware versions in TPM */
- VBPERFSTART("VB_TPML");
tpm_status = RollbackFirmwareLock();
- VBPERFEND("VB_TPML");
if (0 != tpm_status) {
VBDEBUG(("Unable to lock firmware version in TPM.\n"));
VbNvSet(&vnc, VBNV_RECOVERY_REQUEST,
diff --git a/firmware/lib/vboot_api_init.c b/firmware/lib/vboot_api_init.c
index ec33f351..39c90562 100644
--- a/firmware/lib/vboot_api_init.c
+++ b/firmware/lib/vboot_api_init.c
@@ -167,7 +167,6 @@ VbError_t VbInit(VbCommonParams *cparams, VbInitParams *iparams)
VbNvGet(&vnc, VBNV_CLEAR_TPM_OWNER_REQUEST,
&clear_tpm_owner_request);
- VBPERFSTART("VB_TPMI");
/*
* Initialize the TPM. If the developer mode state has changed
* since the last boot, we need to clear TPM ownership. If the
@@ -179,7 +178,6 @@ VbError_t VbInit(VbCommonParams *cparams, VbInitParams *iparams)
clear_tpm_owner_request,
/* two outputs on success */
&is_virt_dev, &tpm_version);
- VBPERFEND("VB_TPMI");
if (0 != tpm_status) {
VBDEBUG(("Unable to setup TPM and read "
diff --git a/firmware/lib/vboot_firmware.c b/firmware/lib/vboot_firmware.c
index c2e8293f..405a545a 100644
--- a/firmware/lib/vboot_firmware.c
+++ b/firmware/lib/vboot_firmware.c
@@ -130,15 +130,12 @@ int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
}
/* Verify the key block */
- VBPERFSTART("VB_VKB");
if ((0 != KeyBlockVerify(key_block, vblock_size,
root_key, 0))) {
VBDEBUG(("Key block verification failed.\n"));
*check_result = VBSD_LF_CHECK_VERIFY_KEYBLOCK;
- VBPERFEND("VB_VKB");
continue;
}
- VBPERFEND("VB_VKB");
/* Check for rollback of key version. */
key_version = key_block->data_key.key_version;
@@ -169,7 +166,6 @@ int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
}
/* Verify the preamble, which follows the key block. */
- VBPERFSTART("VB_VPB");
preamble = (VbFirmwarePreambleHeader *)
((uint8_t *)key_block + key_block->key_block_size);
if ((0 != VerifyFirmwarePreamble(
@@ -179,10 +175,8 @@ int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
VBDEBUG(("Preamble verfication failed.\n"));
*check_result = VBSD_LF_CHECK_VERIFY_PREAMBLE;
RSAPublicKeyFree(data_key);
- VBPERFEND("VB_VPB");
continue;
}
- VBPERFEND("VB_VPB");
/* Check for rollback of firmware version. */
combined_version = (uint32_t)((key_version << 16) |
@@ -230,7 +224,6 @@ int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
VbError_t rv;
/* Read the firmware data */
- VBPERFSTART("VB_RFD");
DigestInit(&lfi->body_digest_context,
data_key->algorithm);
lfi->body_size_accum = 0;
@@ -243,7 +236,6 @@ int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
"index %d\n", index));
*check_result = VBSD_LF_CHECK_GET_FW_BODY;
RSAPublicKeyFree(data_key);
- VBPERFEND("VB_RFD");
continue;
}
if (lfi->body_size_accum !=
@@ -253,13 +245,10 @@ int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
(int)preamble->body_signature.data_size));
*check_result = VBSD_LF_CHECK_HASH_WRONG_SIZE;
RSAPublicKeyFree(data_key);
- VBPERFEND("VB_RFD");
continue;
}
- VBPERFEND("VB_RFD");
/* Verify firmware data */
- VBPERFSTART("VB_VFD");
body_digest = DigestFinal(&lfi->body_digest_context);
if (0 != VerifyDigest(body_digest,
&preamble->body_signature,
@@ -268,11 +257,9 @@ int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
*check_result = VBSD_LF_CHECK_VERIFY_BODY;
RSAPublicKeyFree(data_key);
VbExFree(body_digest);
- VBPERFEND("VB_VFD");
continue;
}
VbExFree(body_digest);
- VBPERFEND("VB_VFD");
}
/* Done with the data key, so can free it now */
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index 26eba7e7..41d44f6a 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -140,9 +140,6 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
return 0;
}
-/* disable MSVC warning on const logical expression (as in } while(0);) */
-__pragma(warning(disable: 4127))
-
VbError_t LoadKernel(LoadKernelParams *params)
{
VbSharedDataHeader *shared =
@@ -486,16 +483,13 @@ VbError_t LoadKernel(LoadKernelParams *params)
}
/* Read the kernel data */
- VBPERFSTART("VB_RKD");
if (0 != VbExDiskRead(params->disk_handle,
part_start + body_offset_sectors,
body_sectors, params->kernel_buffer)) {
VBDEBUG(("Unable to read kernel data.\n"));
- VBPERFEND("VB_RKD");
shpart->check_result = VBSD_LKP_CHECK_READ_DATA;
goto bad_kernel;
}
- VBPERFEND("VB_RKD");
/* Verify kernel data */
if (0 != VerifyData((const uint8_t *)params->kernel_buffer,
diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c
index 60065e64..6818f2b1 100644
--- a/firmware/stub/tpm_lite_stub.c
+++ b/firmware/stub/tpm_lite_stub.c
@@ -57,7 +57,7 @@ static VbError_t DoError(VbError_t result, const char* format, ...) {
/* Print |n| bytes from array |a|, with newlines.
*/
-POSSIBLY_UNUSED static void PrintBytes(const uint8_t* a, int n) {
+__attribute__((unused)) static void PrintBytes(const uint8_t* a, int n) {
int i;
for (i = 0; i < n; i++) {
VBDEBUG(("%02x ", a[i]));
@@ -112,7 +112,8 @@ static VbError_t TpmExecute(const uint8_t *in, const uint32_t in_len,
/* Gets the tag field of a TPM command.
*/
-POSSIBLY_UNUSED static INLINE int TpmTag(const uint8_t* buffer) {
+__attribute__((unused))
+static inline int TpmTag(const uint8_t* buffer) {
uint16_t tag;
FromTpmUint16(buffer, &tag);
return (int) tag;
@@ -121,7 +122,8 @@ POSSIBLY_UNUSED static INLINE int TpmTag(const uint8_t* buffer) {
/* Gets the size field of a TPM command.
*/
-POSSIBLY_UNUSED static INLINE int TpmResponseSize(const uint8_t* buffer) {
+__attribute__((unused))
+static inline int TpmResponseSize(const uint8_t* buffer) {
uint32_t size;
FromTpmUint32(buffer + sizeof(uint16_t), &size);
return (int) size;
diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c
index 1829764f..fd531ac7 100644
--- a/firmware/stub/vboot_api_stub.c
+++ b/firmware/stub/vboot_api_stub.c
@@ -15,9 +15,6 @@
#include "vboot_api.h"
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
void VbExSleepMs(uint32_t msec)
{
}
diff --git a/firmware/stub/vboot_api_stub_disk.c b/firmware/stub/vboot_api_stub_disk.c
index 463b2f98..aca38afa 100644
--- a/firmware/stub/vboot_api_stub_disk.c
+++ b/firmware/stub/vboot_api_stub_disk.c
@@ -15,9 +15,6 @@
#include "vboot_api.h"
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
VbError_t VbExDiskGetInfo(VbDiskInfo** infos_ptr, uint32_t* count,
uint32_t disk_flags) {
diff --git a/firmware/stub/vboot_api_stub_init.c b/firmware/stub/vboot_api_stub_init.c
index 76a29175..76052da1 100644
--- a/firmware/stub/vboot_api_stub_init.c
+++ b/firmware/stub/vboot_api_stub_init.c
@@ -15,9 +15,6 @@
#include "vboot_api.h"
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
/* U-Boot's printf uses '%L' for uint64_t. gcc uses '%l'. */
#define MAX_FMT 255
static char fmtbuf[MAX_FMT+1];
diff --git a/firmware/stub/vboot_api_stub_sf.c b/firmware/stub/vboot_api_stub_sf.c
index 41a16467..96eeb85c 100644
--- a/firmware/stub/vboot_api_stub_sf.c
+++ b/firmware/stub/vboot_api_stub_sf.c
@@ -15,9 +15,6 @@
#include "vboot_api.h"
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
void *VbExMalloc(size_t size)
{
void *p = malloc(size);
diff --git a/tests/big_firmware_tests.c b/tests/big_firmware_tests.c
index f460115f..ca1dea8e 100644
--- a/tests/big_firmware_tests.c
+++ b/tests/big_firmware_tests.c
@@ -16,7 +16,7 @@
#include "utility.h"
/* Choose a firmware size greater than the range of 32-bits unsigned. */
-#define BIG_FIRMWARE_SIZE UINT64_C(0x100000000)
+#define BIG_FIRMWARE_SIZE (0x100000000ULL)
#define ROOT_KEY_BASE_NAME "testkeys/key_rsa8192"
#define FIRMWARE_KEY_BASE_NAME "testkeys/key_rsa1024"
diff --git a/tests/big_kernel_tests.c b/tests/big_kernel_tests.c
index 5524bad6..cc4ceca0 100644
--- a/tests/big_kernel_tests.c
+++ b/tests/big_kernel_tests.c
@@ -16,7 +16,7 @@
#include "utility.h"
/* Choose a kernel size greater than the range of 32-bits unsigned. */
-#define BIG_KERNEL_SIZE UINT64_C(0x100000000)
+#define BIG_KERNEL_SIZE (0x100000000ULL)
#define FIRMWARE_KEY_BASE_NAME "testkeys/key_rsa2048"
#define KERNEL_KEY_BASE_NAME "testkeys/key_rsa1024"
diff --git a/tests/cgptlib_test.c b/tests/cgptlib_test.c
index b48543f3..bbff7808 100644
--- a/tests/cgptlib_test.c
+++ b/tests/cgptlib_test.c
@@ -1371,9 +1371,6 @@ static int ErrorTextTest(void)
return TEST_OK;
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char *argv[])
{
int i;
diff --git a/tests/cgptlib_test.h b/tests/cgptlib_test.h
index 5f8b0429..8668c9c5 100644
--- a/tests/cgptlib_test.h
+++ b/tests/cgptlib_test.h
@@ -18,9 +18,6 @@ typedef int (*test_func)();
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
-/* disable MSVC warning on const logical expression (as in } while(0);) */
-__pragma(warning (disable: 4127))
-
#define EXPECT(expr) \
do { \
if (!(expr)) { \
diff --git a/tests/rollback_index2_tests.c b/tests/rollback_index2_tests.c
index b670812d..d5f29743 100644
--- a/tests/rollback_index2_tests.c
+++ b/tests/rollback_index2_tests.c
@@ -973,9 +973,6 @@ static void RollbackS3ResumeTest(void)
"RollbackS3Resume() other error");
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[])
{
CrcTestFirmware();
diff --git a/tests/rollback_index3_tests.c b/tests/rollback_index3_tests.c
index ece8bc08..30af89df 100644
--- a/tests/rollback_index3_tests.c
+++ b/tests/rollback_index3_tests.c
@@ -14,9 +14,6 @@
#include "rollback_index.h"
#include "test_common.h"
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[])
{
int is_virt_dev;
diff --git a/tests/sha_tests.c b/tests/sha_tests.c
index 6cc7e0f6..b462ccc0 100644
--- a/tests/sha_tests.c
+++ b/tests/sha_tests.c
@@ -78,9 +78,6 @@ int SHA512_tests(void) {
return success;
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int success = 1;
/* Initialize long_msg with 'a' x 1,000,000 */
diff --git a/tests/stateful_util_tests.c b/tests/stateful_util_tests.c
index 077a2ae9..e41feacb 100644
--- a/tests/stateful_util_tests.c
+++ b/tests/stateful_util_tests.c
@@ -283,9 +283,6 @@ static void StatefulMemcpyTest(void) {
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int error_code = 0;
diff --git a/tests/timer_utils.h b/tests/timer_utils.h
index f0d6b299..69380722 100644
--- a/tests/timer_utils.h
+++ b/tests/timer_utils.h
@@ -6,9 +6,7 @@
#ifndef VBOOT_REFERENCE_TIMER_UTILS_H_
#define VBOOT_REFERENCE_TIMER_UTILS_H_
-#ifndef _MSC_VER
#include <inttypes.h>
-#endif
#include <time.h>
diff --git a/tests/tpm_bootmode_tests.c b/tests/tpm_bootmode_tests.c
index 3fd7a956..48552c58 100644
--- a/tests/tpm_bootmode_tests.c
+++ b/tests/tpm_bootmode_tests.c
@@ -68,9 +68,6 @@ static void BootStateTest(void) {
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int error_code = 0;
diff --git a/tests/utility_string_tests.c b/tests/utility_string_tests.c
index 42254a4a..fe11d70b 100644
--- a/tests/utility_string_tests.c
+++ b/tests/utility_string_tests.c
@@ -80,24 +80,24 @@ static void Uint64ToStringTest(void) {
TestU64ToS(0x9A, 2, 0, "10011010");
TestU64ToS(0x71, 2, 12, "000001110001");
TestU64ToS(
- ~UINT64_C(0), 2, 0,
+ ~0ULL, 2, 0,
"1111111111111111111111111111111111111111111111111111111111111111");
/* Decimal */
TestU64ToS(0, 10, 0, "0");
TestU64ToS(12345, 10, 0, "12345");
TestU64ToS(67890, 10, 8, "00067890");
- TestU64ToS(~UINT64_C(0), 10, 0, "18446744073709551615");
+ TestU64ToS(~0ULL, 10, 0, "18446744073709551615");
/* Hex */
TestU64ToS(0, 16, 0, "0");
TestU64ToS(0x12345678, 16, 0, "12345678");
TestU64ToS(0x9ABCDEF, 16, 8, "09abcdef");
- TestU64ToS(~UINT64_C(0), 16, 0, "ffffffffffffffff");
+ TestU64ToS(~0ULL, 16, 0, "ffffffffffffffff");
/* Zero pad corner cases */
/* Don't pad if over length */
- TestU64ToS(UINT64_C(0x1234567890), 16, 8, "1234567890");
+ TestU64ToS(0x1234567890ULL, 16, 8, "1234567890");
/* Fail if padding won't fit in buffer */
TEST_EQ(0, Uint64ToString(dest, 8, 123, 10, 8), "Uint64ToString bad pad");
TEST_EQ(0, strcmp(dest, ""), "Uint64ToString bad pad result");
@@ -105,9 +105,6 @@ static void Uint64ToStringTest(void) {
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int error_code = 0;
diff --git a/tests/utility_tests.c b/tests/utility_tests.c
index 5ecb0b06..7e21c77a 100644
--- a/tests/utility_tests.c
+++ b/tests/utility_tests.c
@@ -19,8 +19,8 @@
/* Test utility.h and sysincludes.h macros */
static void MacrosTest(void) {
int64_t a = -10, b = -20;
- uint64_t u = UINT64_C(0xABCD00000000);
- uint64_t v = UINT64_C(0xABCD000000);
+ uint64_t u = (0xABCD00000000ULL);
+ uint64_t v = (0xABCD000000ULL);
TEST_EQ(CombineUint16Pair(1, 2), 0x00010002, "CombineUint16Pair");
TEST_EQ(CombineUint16Pair(0xFFFE, 0xFFFF), 0xFFFEFFFF,
@@ -37,13 +37,13 @@ static void MacrosTest(void) {
TEST_EQ(Min(b, a), b, "Min uint64 2");
TEST_EQ(Min(b, b), b, "Min uint64 same");
- TEST_EQ(UINT64_RSHIFT(u, 8), v, "UINT64_RSHIFT 8");
- TEST_EQ(UINT64_RSHIFT(u, 0), u, "UINT64_RSHIFT 0");
- TEST_EQ(UINT64_RSHIFT(u, 36), UINT64_C(0xABC), "UINT64_RSHIFT 36");
+ TEST_EQ(u >> 8, v, "uint64_t >> 8");
+ TEST_EQ(u >> 0, u, "uint64_t >> 0");
+ TEST_EQ(u >> 36, (uint64_t)0xABC, "uint64_t >> 36");
- TEST_EQ(UINT64_MULT32(v, 0), 0, "UINT64_MULT32 0");
- TEST_EQ(UINT64_MULT32(v, 1), v, "UINT64_MULT32 1");
- TEST_EQ(UINT64_MULT32(v, 256), u, "UINT64_MULT32 256");
+ TEST_EQ(v * (uint32_t)0, 0, "uint64_t * uint32_t 0");
+ TEST_EQ(v * (uint32_t)1, v, "uint64_t * uint32_t 1");
+ TEST_EQ(v * (uint32_t)256, u, "uint64_t * uint32_t 256");
}
@@ -62,9 +62,6 @@ static void SafeMemcmpTest(void) {
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int error_code = 0;
diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c
index 1ca58b99..af20030f 100644
--- a/tests/vboot_api_devmode_tests.c
+++ b/tests/vboot_api_devmode_tests.c
@@ -319,9 +319,6 @@ static void VbBootDeveloperSoundTest(void) {
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int error_code = 0;
diff --git a/tests/vboot_api_firmware_tests.c b/tests/vboot_api_firmware_tests.c
index e6a84ee0..a31b532e 100644
--- a/tests/vboot_api_firmware_tests.c
+++ b/tests/vboot_api_firmware_tests.c
@@ -236,9 +236,6 @@ static void VbSelectFirmwareTest(void) {
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int error_code = 0;
diff --git a/tests/vboot_api_init_tests.c b/tests/vboot_api_init_tests.c
index bde10a7c..7834b907 100644
--- a/tests/vboot_api_init_tests.c
+++ b/tests/vboot_api_init_tests.c
@@ -512,9 +512,6 @@ static void VbInitTestTPM(void)
TEST_EQ(rfs_clear_tpm_request, 1, "rfs tpm clear request");
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char *argv[])
{
VbInitTest();
diff --git a/tests/vboot_audio_tests.c b/tests/vboot_audio_tests.c
index 4d633516..a1ecf71b 100644
--- a/tests/vboot_audio_tests.c
+++ b/tests/vboot_audio_tests.c
@@ -214,9 +214,6 @@ static void VbAudioTest(void) {
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int error_code = 0;
diff --git a/tests/vboot_common_tests.c b/tests/vboot_common_tests.c
index 73cbeb55..df4fdc21 100644
--- a/tests/vboot_common_tests.c
+++ b/tests/vboot_common_tests.c
@@ -228,9 +228,6 @@ static void VbSharedDataTest(void)
"VbSharedDataSetKernelKey null");
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[])
{
StructPackingTest();
diff --git a/tests/vboot_firmware_tests.c b/tests/vboot_firmware_tests.c
index 0443b061..24a6c285 100644
--- a/tests/vboot_firmware_tests.c
+++ b/tests/vboot_firmware_tests.c
@@ -423,9 +423,6 @@ static void LoadFirmwareTest(void) {
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int error_code = 0;
diff --git a/tests/vboot_nvstorage_test.c b/tests/vboot_nvstorage_test.c
index 15c229f3..91e8a89a 100644
--- a/tests/vboot_nvstorage_test.c
+++ b/tests/vboot_nvstorage_test.c
@@ -170,9 +170,6 @@ static void VbNvStorageTest(void) {
}
-/* disable MSVC warnings on unused arguments */
-__pragma(warning (disable: 4100))
-
int main(int argc, char* argv[]) {
int error_code = 0;
diff --git a/utility/load_kernel_test.c b/utility/load_kernel_test.c
index f5585c38..307b8ee2 100644
--- a/utility/load_kernel_test.c
+++ b/utility/load_kernel_test.c
@@ -131,12 +131,13 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "usage: %s [options] <drive_image> [<sign_key>]\n",
argv[0]);
fprintf(stderr, "\noptions:\n");
+ /* These cases are because uint64_t isn't necessarily the same as ULL. */
fprintf(stderr, " -b NUM boot flag bits (default %" PRIu64 "):\n",
- BOOT_FLAG_RECOVERY);
+ (uint64_t)BOOT_FLAG_RECOVERY);
fprintf(stderr, " %" PRIu64 " = developer mode on\n",
- BOOT_FLAG_DEVELOPER);
+ (uint64_t)BOOT_FLAG_DEVELOPER);
fprintf(stderr, " %" PRIu64 " = recovery mode on\n",
- BOOT_FLAG_RECOVERY);
+ (uint64_t)BOOT_FLAG_RECOVERY);
return 1;
}