From 7ce85378403c17388f69deec24878fefb374701e Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 22 Oct 2024 16:46:54 -0700 Subject: [PATCH 1/4] build warnings as errors --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 7fcc7b2..48203f1 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ #CFLAGS_msr_batch.o := -DDEBUG #CFLAGS_msr-smp.o := -DDEBUG +CFLAGS := -Wall -Wextra -Werror + obj-m += msr-safe.o msr-safe-objs := msr_entry.o msr_allowlist.o msr-smp.o msr_batch.o msr_version.o From c7fd90f83e80aa0cb3630516dbefda5d537435f7 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Fri, 25 Oct 2024 10:41:34 -0700 Subject: [PATCH 2/4] fix warnings in msrsave --- msrsave/msrsave.c | 6 ++---- msrsave/msrsave.h | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/msrsave/msrsave.c b/msrsave/msrsave.c index f1603b8..2b9434e 100644 --- a/msrsave/msrsave.c +++ b/msrsave/msrsave.c @@ -40,7 +40,7 @@ static int msr_parse_allowlist(const char *allowlist_path, size_t *num_msr_ptr, enum {BUFFER_SIZE = 8192}; int err = 0; int tmp_err = 0; - int i; + size_t i; int tmp_fd = -1; int allowlist_fd = -1; size_t num_scan = 0; @@ -53,7 +53,6 @@ static int msr_parse_allowlist(const char *allowlist_path, size_t *num_msr_ptr, uint64_t *msr_mask = NULL; struct stat allowlist_stat; char tmp_path[NAME_MAX] = "/tmp/msrsave_allowlist_XXXXXX"; - char err_msg[NAME_MAX]; char copy_buffer[BUFFER_SIZE]; /* Copy allowlist into temporary file */ @@ -253,7 +252,7 @@ static int msr_parse_allowlist(const char *allowlist_path, size_t *num_msr_ptr, return err; } -int msr_save(const char *save_path, const char *allowlist_path, const char *msr_path_format, int num_cpu, FILE *output_log, FILE *error_log) +int msr_save(const char *save_path, const char *allowlist_path, const char *msr_path_format, int num_cpu, FILE *error_log) { int err = 0; int tmp_err = 0; @@ -407,7 +406,6 @@ int msr_restore(const char *restore_path, const char *allowlist_path, const char FILE *restore_fid = NULL; struct stat restore_stat; struct stat allowlist_stat; - char err_msg[NAME_MAX]; err = msr_parse_allowlist(allowlist_path, &num_msr, &msr_offset, &msr_mask, error_log); if (err) diff --git a/msrsave/msrsave.h b/msrsave/msrsave.h index 0c07360..607bf1f 100644 --- a/msrsave/msrsave.h +++ b/msrsave/msrsave.h @@ -13,7 +13,6 @@ int msr_save(const char *out_path, const char *allowlist_path, const char *msr_path, int num_cpu, - FILE *output_log, FILE *error_log); int msr_restore(const char *in_path, From 78d27db68ad26a1744880b2805dee7aac4794aba Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Fri, 25 Oct 2024 10:44:27 -0700 Subject: [PATCH 3/4] too many arguments --- msrsave/msrsave_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msrsave/msrsave_main.c b/msrsave/msrsave_main.c index 546bd11..0fb51bc 100644 --- a/msrsave/msrsave_main.c +++ b/msrsave/msrsave_main.c @@ -104,7 +104,7 @@ int main(int argc, char **argv) } else { - err = msr_save(file_name, msr_allowlist_path, msr_path, num_cpu, stdout, stderr); + err = msr_save(file_name, msr_allowlist_path, msr_path, num_cpu, stderr); } } From b5a448d0302705300478960021cf43d1e9af09e1 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Fri, 25 Oct 2024 10:53:37 -0700 Subject: [PATCH 4/4] int to size_t --- msrsave/msrsave.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/msrsave/msrsave.c b/msrsave/msrsave.c index 2b9434e..ecf03a2 100644 --- a/msrsave/msrsave.c +++ b/msrsave/msrsave.c @@ -256,7 +256,8 @@ int msr_save(const char *save_path, const char *allowlist_path, const char *msr_ { int err = 0; int tmp_err = 0; - int i, j; + int i; + size_t j; int msr_fd = -1; size_t num_msr = 0; uint64_t *msr_offset = NULL; @@ -393,7 +394,8 @@ int msr_restore(const char *restore_path, const char *allowlist_path, const char { int err = 0; int tmp_err = 0; - int i, j; + int i; + size_t j; int msr_fd = -1; int do_print_header = 1; size_t num_msr = 0;