Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/34577 )
Change subject: tree: Enable -Wwrite-strings ......................................................................
tree: Enable -Wwrite-strings
When compiling, this warning gives string literals the type const char[] to help catch accidental modification (which is undefined behaviour). There currently aren't any instances of this in flashrom, so let's enable this warning to keep it that way. This requires adding const qualifiers to the declarations of several variables that work with string literals.
Change-Id: I62d9bc194938a0c9a0e4cdff7ced8ea2e14cc1bc Signed-off-by: Jacob Garber jgarber1@ualberta.ca --- M Makefile M buspirate_spi.c M cli_classic.c M dmi.c M pony_spi.c M util/ich_descriptors_tool/ich_descriptors_tool.c 6 files changed, 6 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/77/34577/1
diff --git a/Makefile b/Makefile index 545e84a..1a20933 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ DIFF = diff PREFIX ?= /usr/local MANDIR ?= $(PREFIX)/share/man -CFLAGS ?= -Os -Wall -Wshadow -Wmissing-prototypes +CFLAGS ?= -Os -Wall -Wshadow -Wmissing-prototypes -Wwrite-strings EXPORTDIR ?= . RANLIB ?= ranlib PKG_CONFIG ?= pkg-config diff --git a/buspirate_spi.c b/buspirate_spi.c index fb066c2..bc6776b 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -112,7 +112,7 @@ return 0; }
-static int buspirate_wait_for_string(unsigned char *buf, char *key) +static int buspirate_wait_for_string(unsigned char *buf, const char *key) { unsigned int keylen = strlen(key); int ret; diff --git a/cli_classic.c b/cli_classic.c index 0591bfe..428efc1 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -77,7 +77,7 @@ exit(1); }
-static int check_filename(char *filename, char *type) +static int check_filename(char *filename, const char *type) { if (!filename || (filename[0] == '\0')) { fprintf(stderr, "Error: No %s file specified.\n", type); diff --git a/dmi.c b/dmi.c index ae90f7c..6132b47 100644 --- a/dmi.c +++ b/dmi.c @@ -69,7 +69,7 @@ static const struct { uint8_t type; uint8_t is_laptop; - char *name; + const char *name; } dmi_chassis_types[] = { {0x01, 2, "Other"}, {0x02, 2, "Unknown"}, diff --git a/pony_spi.c b/pony_spi.c index 6c03308..ed9d326 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -115,7 +115,7 @@ int i, data_out; char *arg = NULL; enum pony_type type = TYPE_SI_PROG; - char *name; + const char *name; int have_device = 0; int have_prog = 0;
diff --git a/util/ich_descriptors_tool/ich_descriptors_tool.c b/util/ich_descriptors_tool/ich_descriptors_tool.c index 2c7966d..768401e 100644 --- a/util/ich_descriptors_tool/ich_descriptors_tool.c +++ b/util/ich_descriptors_tool/ich_descriptors_tool.c @@ -111,7 +111,7 @@ printf("\n"); }
-static void usage(char *argv[], char *error) +static void usage(char *argv[], const char *error) { if (error != NULL) { fprintf(stderr, "%s\n", error);