summaryrefslogtreecommitdiff
path: root/futility
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 /futility
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 'futility')
-rw-r--r--futility/cmd_create.c4
-rw-r--r--futility/cmd_dump_fmap.c4
-rw-r--r--futility/cmd_gbb_utility.c2
-rw-r--r--futility/cmd_load_fmap.c2
-rw-r--r--futility/cmd_show.c2
-rw-r--r--futility/cmd_sign.c2
-rw-r--r--futility/cmd_validate_rec_mrc.c2
-rw-r--r--futility/file_type.h8
-rw-r--r--futility/file_type.inc2
-rw-r--r--futility/futility.c12
-rw-r--r--futility/updater.c12
-rw-r--r--futility/updater.h7
-rw-r--r--futility/updater_archive.c5
-rw-r--r--futility/vb2_helper.c1
14 files changed, 36 insertions, 29 deletions
diff --git a/futility/cmd_create.c b/futility/cmd_create.c
index 9996449b..fe8fd733 100644
--- a/futility/cmd_create.c
+++ b/futility/cmd_create.c
@@ -80,7 +80,7 @@ static void print_help(int argc, char *argv[])
}
-static int vb1_make_keypair()
+static int vb1_make_keypair(void)
{
struct vb2_private_key *privkey = NULL;
struct vb2_packed_key *pubkey = NULL;
@@ -161,7 +161,7 @@ done:
return ret;
}
-static int vb2_make_keypair()
+static int vb2_make_keypair(void)
{
struct vb2_private_key *privkey = 0;
struct vb2_public_key *pubkey = 0;
diff --git a/futility/cmd_dump_fmap.c b/futility/cmd_dump_fmap.c
index 1c5b070c..2ab981bc 100644
--- a/futility/cmd_dump_fmap.c
+++ b/futility/cmd_dump_fmap.c
@@ -187,8 +187,8 @@ static void sort_nodes(int num, struct node_s *ary[])
}
}
-static void line(int indent, char *name,
- uint32_t start, uint32_t end, uint32_t size, char *append)
+static void line(int indent, const char *name, uint32_t start, uint32_t end,
+ uint32_t size, const char *append)
{
int i;
for (i = 0; i < indent; i++)
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c
index 796eca7a..02f4757f 100644
--- a/futility/cmd_gbb_utility.c
+++ b/futility/cmd_gbb_utility.c
@@ -83,7 +83,7 @@ static struct option long_opts[] = {
{NULL, 0, NULL, 0},
};
-static char *short_opts = ":gsc:o:k:b:r:";
+static const char *short_opts = ":gsc:o:k:b:r:";
/* Change the has_arg field of a long_opts entry */
static void opt_has_arg(const char *name, int val)
diff --git a/futility/cmd_load_fmap.c b/futility/cmd_load_fmap.c
index 897a0850..a732b1a6 100644
--- a/futility/cmd_load_fmap.c
+++ b/futility/cmd_load_fmap.c
@@ -52,7 +52,7 @@ static const struct option long_opts[] = {
{"help", 0, NULL, OPT_HELP},
{NULL, 0, NULL, 0},
};
-static char *short_opts = ":o:";
+static const char *short_opts = ":o:";
static int copy_to_area(char *file, uint8_t *buf, uint32_t len, char *area)
diff --git a/futility/cmd_show.c b/futility/cmd_show.c
index b33f019c..50f668b8 100644
--- a/futility/cmd_show.c
+++ b/futility/cmd_show.c
@@ -436,7 +436,7 @@ static const struct option long_opts[] = {
{"help", 0, NULL, OPT_HELP},
{NULL, 0, NULL, 0},
};
-static char *short_opts = ":f:k:t";
+static const char *short_opts = ":f:k:t";
static int show_type(char *filename)
diff --git a/futility/cmd_sign.c b/futility/cmd_sign.c
index cc2b3e62..8b6b2520 100644
--- a/futility/cmd_sign.c
+++ b/futility/cmd_sign.c
@@ -630,7 +630,7 @@ static const struct option long_opts[] = {
{"help", 0, NULL, OPT_HELP},
{NULL, 0, NULL, 0},
};
-static char *short_opts = ":s:b:k:S:B:v:f:d:l:";
+static const char *short_opts = ":s:b:k:S:B:v:f:d:l:";
/* Return zero on success */
static int parse_number_opt(const char *arg, const char *name, uint32_t *dest)
diff --git a/futility/cmd_validate_rec_mrc.c b/futility/cmd_validate_rec_mrc.c
index e4b57d89..2f609156 100644
--- a/futility/cmd_validate_rec_mrc.c
+++ b/futility/cmd_validate_rec_mrc.c
@@ -49,7 +49,7 @@ struct mrc_metadata {
#define REGF_METADATA_BLOCK_SIZE REGF_BLOCK_GRANULARITY
#define REGF_UNALLOCATED_BLOCK 0xffff
-unsigned long compute_ip_checksum(const void *addr, unsigned long length)
+static unsigned long compute_ip_checksum(const void *addr, unsigned long length)
{
const uint8_t *ptr;
volatile union {
diff --git a/futility/file_type.h b/futility/file_type.h
index a1be2172..a389713b 100644
--- a/futility/file_type.h
+++ b/futility/file_type.h
@@ -57,7 +57,12 @@ int futil_file_type_sign(enum futil_file_type type,
const char *filename,
uint8_t *buf, uint32_t len);
-/* Declare the file_type functions. */
+/*
+ * Declare the file_type functions. Certain functions are reused for more than
+ * one file type, leading to redundant declarations here.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
#define R_(FOO) \
enum futil_file_type FOO(uint8_t *buf, uint32_t len);
#define S_(FOO) \
@@ -69,5 +74,6 @@ int futil_file_type_sign(enum futil_file_type type,
#undef NONE
#undef S_
#undef R_
+#pragma GCC diagnostic pop
#endif /* VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_ */
diff --git a/futility/file_type.inc b/futility/file_type.inc
index b48c6c42..5fd83c2a 100644
--- a/futility/file_type.inc
+++ b/futility/file_type.inc
@@ -68,7 +68,7 @@ FILE_TYPE(RAW_KERNEL, "vmlinuz", "raw linux kernel",
NONE,
S_(ft_sign_raw_kernel))
FILE_TYPE(CHROMIUMOS_DISK, "disk_img", "chromiumos disk image",
- NONE,
+ R_(ft_recognize_gpt),
NONE,
NONE)
FILE_TYPE(RWSIG, "rwsig", "RW device image",
diff --git a/futility/futility.c b/futility/futility.c
index f0a42e20..3fc09c88 100644
--- a/futility/futility.c
+++ b/futility/futility.c
@@ -31,7 +31,7 @@
static int log_fd = -1;
/* Write the string and a newline. Silently give up on errors */
-static void log_str(char *prefix, char *str)
+static void log_str(const char *prefix, const char *str)
{
int len, done, n;
@@ -238,7 +238,7 @@ static int do_help(int argc, char *argv[])
if (cmd) {
/* Let the command provide its own help */
argv[0] = argv[1];
- argv[1] = "--help";
+ argv[1] = (char *)"--help";
return run_command(cmd, argc, argv);
}
}
@@ -358,11 +358,11 @@ int main(int argc, char *argv[], char *envp[])
* by rearranging argv[].
*/
if (helpind) {
- int i;
+ int j;
optind--;
- for (i = helpind; i < optind; i++)
- argv[i] = argv[i + 1];
- argv[i] = "help";
+ for (j = helpind; j < optind; j++)
+ argv[j] = argv[j + 1];
+ argv[j] = (char *)"help";
}
/* We require a command name. */
diff --git a/futility/updater.c b/futility/updater.c
index 37fe6657..8dad7d41 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -185,7 +185,7 @@ char *host_shell(const char *command)
/* An helper function to return "mainfw_act" system property. */
-static int host_get_mainfw_act()
+static int host_get_mainfw_act(void)
{
char buf[VB_MAX_STRING_PROPERTY];
@@ -201,13 +201,13 @@ static int host_get_mainfw_act()
}
/* A helper function to return the "tpm_fwver" system property. */
-static int host_get_tpm_fwver()
+static int host_get_tpm_fwver(void)
{
return VbGetSystemPropertyInt("tpm_fwver");
}
/* A helper function to return the "hardware write protection" status. */
-static int host_get_wp_hw()
+static int host_get_wp_hw(void)
{
/* wpsw refers to write protection 'switch', not 'software'. */
int v = VbGetSystemPropertyInt("wpsw_cur");
@@ -220,13 +220,13 @@ static int host_get_wp_hw()
}
/* A helper function to return "fw_vboot2" system property. */
-static int host_get_fw_vboot2()
+static int host_get_fw_vboot2(void)
{
return VbGetSystemPropertyInt("fw_vboot2");
}
/* A help function to get $(mosys platform version). */
-static int host_get_platform_version()
+static int host_get_platform_version(void)
{
char *result = host_shell("mosys platform version");
int rev = -1;
@@ -341,7 +341,7 @@ static int host_get_wp(const char *programmer)
}
/* Helper function to return host software write protection status. */
-static int host_get_wp_sw()
+static int host_get_wp_sw(void)
{
return host_get_wp(PROG_HOST);
}
diff --git a/futility/updater.h b/futility/updater.h
index bb30ffb1..57e5b0b7 100644
--- a/futility/updater.h
+++ b/futility/updater.h
@@ -47,7 +47,7 @@ struct firmware_section {
};
struct system_property {
- int (*getter)();
+ int (*getter)(void);
int value;
int initialized;
};
@@ -106,7 +106,8 @@ struct updater_config {
struct updater_config_arguments {
char *image, *ec_image, *pd_image;
char *archive, *quirks, *mode;
- char *programmer, *model, *signature_id;
+ const char *programmer;
+ char *model, *signature_id;
char *emulation, *sys_props, *write_protection;
char *output_dir;
char *repack, *unpack;
@@ -167,7 +168,7 @@ enum updater_error_codes update_firmware(struct updater_config *cfg);
* Allocates and initializes a updater_config object with default values.
* Returns the newly allocated object, or NULL on error.
*/
-struct updater_config *updater_new_config();
+struct updater_config *updater_new_config(void);
/*
* Releases all resources in an updater configuration object.
diff --git a/futility/updater_archive.c b/futility/updater_archive.c
index 6503ad01..afa04b98 100644
--- a/futility/updater_archive.c
+++ b/futility/updater_archive.c
@@ -403,9 +403,8 @@ int archive_has_entry(struct archive *ar, const char *name)
* The arg argument will also be passed to callback.
* Returns 0 on success otherwise non-zero as failure.
*/
-int archive_walk(
- struct archive *ar, void *arg,
- int (*callback)(const char *path, void *arg))
+static int archive_walk(struct archive *ar, void *arg,
+ int (*callback)(const char *path, void *arg))
{
if (!ar)
return archive_fallback_walk(NULL, arg, callback);
diff --git a/futility/vb2_helper.c b/futility/vb2_helper.c
index 475a0597..fae1d255 100644
--- a/futility/vb2_helper.c
+++ b/futility/vb2_helper.c
@@ -21,6 +21,7 @@
#include "file_type.h"
#include "futility.h"
+#include "futility_options.h"
int vb2_lookup_hash_alg(const char *str, enum vb2_hash_algorithm *alg)
{