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>
This commit is contained in:
Gabe Black
2013-03-16 04:03:40 -07:00
committed by ChromeBot
parent 77f55ca1cd
commit ac8805e7e9
43 changed files with 57 additions and 199 deletions

View File

@@ -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_ */

View File

@@ -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() */

View File

@@ -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_ */

View File

@@ -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", \

View File

@@ -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_ */

View File

@@ -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_ */

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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) \

View File

@@ -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_ */

View File

@@ -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 */
/*

View File

@@ -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 */

View File

@@ -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];
}

View File

@@ -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);
}

View File

@@ -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,

View File

@@ -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 "

View File

@@ -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 */

View File

@@ -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,

View File

@@ -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;

View File

@@ -15,9 +15,6 @@
#include "vboot_api.h"
/* disable MSVC warnings on unused arguments */
__pragma(warning (disable: 4100))
void VbExSleepMs(uint32_t msec)
{
}

View File

@@ -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) {

View File

@@ -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];

View File

@@ -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);

View File

@@ -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"

View File

@@ -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"

View File

@@ -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;

View File

@@ -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)) { \

View File

@@ -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();

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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>

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();

View File

@@ -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;

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}