summaryrefslogtreecommitdiff
path: root/utility
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-05-07 12:59:47 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-14 20:13:04 -0700
commit52fa8c11f8e5217e17da74c04e8ad1e5aee9ff40 (patch)
treea4894fe06a3f1c9fcbbfe728955f75a8de59ed93 /utility
parent88a47ff99952bb4f270a4e80c80c578e39fb9477 (diff)
downloadvboot-52fa8c11f8e5217e17da74c04e8ad1e5aee9ff40.tar.gz
Makefile: Enable more warnings for host utilities / tests
This patch adds a bunch of more warnings that are already enabled in coreboot and thus already enabled for firmware builds anyway (because coreboot just passes its CFLAGS through). Enabling it in the vboot Makefile means they also apply to host utilities and tests, which sounds desirable for consistency. Fix enough of the cruft and bad coding practices that accumulated over the years of not having warnings enabled to get it to build again (this includes making functions static, removing dead code, cleaning up prototypes, etc.). Also remove -fno-strict-aliasing from the x86 firmware build options, because it's not clear why it's there (coreboot isn't doing this, so presumably it's not needed). BRANCH=None BUG=None TEST=make runtests Change-Id: Ie4a42083c4770a4eca133b22725be9ba85b24184 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1598721 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Diffstat (limited to 'utility')
-rw-r--r--utility/crossystem.c24
-rw-r--r--utility/dumpRSAPublicKey.c4
-rw-r--r--utility/tpmc.c10
-rw-r--r--utility/verify_data.c28
4 files changed, 14 insertions, 52 deletions
diff --git a/utility/crossystem.c b/utility/crossystem.c
index 68e3f510..3093f2a8 100644
--- a/utility/crossystem.c
+++ b/utility/crossystem.c
@@ -11,11 +11,6 @@
#include "crossystem.h"
-/*
- * Call arch specific init, if provided, otherwise use the 'weak' stub.
- */
-int __VbArchInit(void) { return 0; }
-int VbArchInit(void) __attribute__((weak, alias("__VbArchInit")));
/* Flags for Param */
#define IS_STRING 0x01 /* String (not present = integer) */
#define CAN_WRITE 0x02 /* Writable (not present = read-only */
@@ -118,7 +113,7 @@ static const int kNameWidth = 23;
/* Print help */
-void PrintHelp(const char *progname) {
+static void PrintHelp(const char *progname) {
const Param *p;
printf("\nUsage:\n"
@@ -146,7 +141,7 @@ void PrintHelp(const char *progname) {
/* Find the parameter in the list.
*
* Returns the parameter, or NULL if no match. */
-const Param* FindParam(const char* name) {
+static const Param* FindParam(const char* name) {
const Param* p;
if (!name)
return NULL;
@@ -161,7 +156,7 @@ const Param* FindParam(const char* name) {
/* Set the specified parameter.
*
* Returns 0 if success, non-zero if error. */
-int SetParam(const Param* p, const char* value) {
+static int SetParam(const Param* p, const char* value) {
if (!(p->flags & CAN_WRITE))
return 1; /* Parameter is read-only */
@@ -180,7 +175,7 @@ int SetParam(const Param* p, const char* value) {
/* Compares the parameter with the expected value.
*
* Returns 0 if success (match), non-zero if error (mismatch). */
-int CheckParam(const Param* p, char* expect) {
+static int CheckParam(const Param* p, const char* expect) {
if (p->flags & IS_STRING) {
char buf[VB_MAX_STRING_PROPERTY];
const char* v = VbGetSystemPropertyString(p->name, buf, sizeof(buf));
@@ -202,7 +197,7 @@ int CheckParam(const Param* p, char* expect) {
/* Print the specified parameter.
*
* Returns 0 if success, non-zero if error. */
-int PrintParam(const Param* p) {
+static int PrintParam(const Param* p) {
if (p->flags & IS_STRING) {
char buf[VB_MAX_STRING_PROPERTY];
const char* v = VbGetSystemPropertyString(p->name, buf, sizeof(buf));
@@ -223,7 +218,7 @@ int PrintParam(const Param* p) {
* parameters that specify the NO_PRINT_ALL flag.
*
* Returns 0 if success, non-zero if error. */
-int PrintAllParams(int force_all) {
+static int PrintAllParams(int force_all) {
const Param* p;
int retval = 0;
char buf[VB_MAX_STRING_PROPERTY];
@@ -263,11 +258,6 @@ int main(int argc, char* argv[]) {
else
progname = argv[0];
- if (VbArchInit()) {
- fprintf(stderr, "Failed to initialize\n");
- return -1;
- }
-
/* If no args specified, print all params */
if (argc == 1)
return PrintAllParams(0);
@@ -287,7 +277,7 @@ int main(int argc, char* argv[]) {
char* has_set = strchr(argv[i], '=');
char* has_expect = strchr(argv[i], '?');
char* name = strtok(argv[i], "=?");
- char* value = strtok(NULL, "=?");
+ const char* value = strtok(NULL, "=?");
const Param* p;
/* Make sure args are well-formed. '' or '=foo' or '?foo' not allowed. */
diff --git a/utility/dumpRSAPublicKey.c b/utility/dumpRSAPublicKey.c
index 9e90003f..d7f66e58 100644
--- a/utility/dumpRSAPublicKey.c
+++ b/utility/dumpRSAPublicKey.c
@@ -21,7 +21,7 @@
* routines.
*/
-int check(RSA* key) {
+static int check(RSA* key) {
const BIGNUM *n, *e;
int public_exponent, modulus;
@@ -45,7 +45,7 @@ int check(RSA* key) {
/* Pre-processes and outputs RSA public key to standard out.
*/
-void output(RSA* key) {
+static void output(RSA* key) {
int i, nwords;
const BIGNUM *key_n;
BIGNUM *N = NULL;
diff --git a/utility/tpmc.c b/utility/tpmc.c
index 2e1e5180..f5012eaf 100644
--- a/utility/tpmc.c
+++ b/utility/tpmc.c
@@ -65,10 +65,10 @@ char** args;
/* Converts a string in the form 0x[0-9a-f]+ to a 32-bit value. Returns 0 for
* success, non-zero for failure.
*/
-int HexStringToUint32(const char* string, uint32_t* value) {
+static int HexStringToUint32(const char* string, uint32_t* value) {
char tail[1];
/* strtoul is not as good because it overflows silently */
- char* format = strncmp(string, "0x", 2) ? "%8x%s" : "0x%8x%s";
+ const char* format = strncmp(string, "0x", 2) ? "%8x%s" : "0x%8x%s";
int n = sscanf(string, format, value, tail);
return n != 1;
}
@@ -76,7 +76,7 @@ int HexStringToUint32(const char* string, uint32_t* value) {
/* Converts a string in the form [0-9a-f]+ to an 8-bit value. Returns 0 for
* success, non-zero for failure.
*/
-int HexStringToUint8(const char* string, uint8_t* value) {
+static int HexStringToUint8(const char* string, uint8_t* value) {
char* end;
uint32_t large_value = strtoul(string, &end, 16);
if (*end != '\0' || large_value > 0xff) {
@@ -86,7 +86,7 @@ int HexStringToUint8(const char* string, uint8_t* value) {
return 0;
}
-int HexStringToArray(const char* string, uint8_t* value, int num_bytes) {
+static int HexStringToArray(const char* string, uint8_t* value, int num_bytes) {
int len = strlen(string);
if (!strncmp(string, "0x", 2)) {
string += 2;
@@ -108,7 +108,7 @@ int HexStringToArray(const char* string, uint8_t* value, int num_bytes) {
* found. Then returns min(result, OTHER_ERROR) since some error codes, such
* as TPM_E_RETRY, do not fit in a byte.
*/
-uint8_t ErrorCheck(uint32_t result, const char* cmd) {
+static uint8_t ErrorCheck(uint32_t result, const char* cmd) {
uint8_t exit_code = result > OTHER_ERROR ? OTHER_ERROR : result;
if (result == 0) {
return 0;
diff --git a/utility/verify_data.c b/utility/verify_data.c
index 50eeb9d2..1bf6756c 100644
--- a/utility/verify_data.c
+++ b/utility/verify_data.c
@@ -29,34 +29,6 @@
#define COL_RED "\e[0;31m"
#define COL_STOP "\e[m"
-uint8_t* read_signature(char* input_file, int len)
-{
- int i, sigfd;
- uint8_t* signature = NULL;
- if ((sigfd = open(input_file, O_RDONLY)) == -1) {
- fprintf(stderr, "Couldn't open signature file\n");
- return NULL;
- }
-
- /* Read the signature into a buffer*/
- signature = (uint8_t*) malloc(len);
- if (!signature) {
- close(sigfd);
- return NULL;
- }
-
- if( (i = read(sigfd, signature, len)) != len ) {
- fprintf(stderr, "Expected signature length %d, Received %d\n",
- len, i);
- close(sigfd);
- free(signature);
- return NULL;
- }
-
- close(sigfd);
- return signature;
-}
-
int main(int argc, char* argv[])
{
uint8_t workbuf[VB2_VERIFY_DIGEST_WORKBUF_BYTES]