From bcb2e5a7080cbe0ff21c8ffa5f77b5ba1ea0c472 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sun, 30 Dec 2012 01:23:17 +0000 Subject: Constify parameters and globals This makes some stuff const (partially to get a more convenient libflashrom interface). Corresponding to flashrom svn r1639. Signed-off-by: Nico Huber Signed-off-by: Stefan Tauner Acked-by: Stefan Tauner --- cli_classic.c | 2 +- flash.h | 4 ++-- flashrom.c | 8 ++++---- programmer.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cli_classic.c b/cli_classic.c index dd070c52..14fb8251 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -532,7 +532,7 @@ out: free(layoutfile); free(pparam); /* clean up global variables */ - free(chip_to_probe); + free((char *)chip_to_probe); /* Silence! Freeing is not modifying contents. */ chip_to_probe = NULL; #ifndef STANDALONE ret |= close_logfile(); diff --git a/flash.h b/flash.h index 76c69420..3149b4fb 100644 --- a/flash.h +++ b/flash.h @@ -222,7 +222,7 @@ void print_supported_wiki(void); extern int verbose_screen; extern int verbose_logfile; extern const char flashrom_version[]; -extern char *chip_to_probe; +extern const char *chip_to_probe; void map_flash_registers(struct flashctx *flash); int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); int erase_flash(struct flashctx *flash); @@ -231,7 +231,7 @@ int read_flash_to_file(struct flashctx *flash, const char *filename); int min(int a, int b); int max(int a, int b); void tolower_string(char *str); -char *extract_param(char **haystack, const char *needle, const char *delim); +char *extract_param(const char *const *haystack, const char *needle, const char *delim); int verify_range(struct flashctx *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len); int need_erase(uint8_t *have, uint8_t *want, unsigned int len, enum write_granularity gran); char *strcat_realloc(char *dest, const char *src); diff --git a/flashrom.c b/flashrom.c index 6f7d6806..fd438bb2 100644 --- a/flashrom.c +++ b/flashrom.c @@ -40,13 +40,13 @@ #include "hwaccess.h" const char flashrom_version[] = FLASHROM_VERSION; -char *chip_to_probe = NULL; +const char *chip_to_probe = NULL; int verbose_screen = MSG_INFO; int verbose_logfile = MSG_DEBUG2; static enum programmer programmer = PROGRAMMER_INVALID; -static char *programmer_param = NULL; +static const char *programmer_param = NULL; /* * Programmers supporting multiple buses can have differing size limits on @@ -351,7 +351,7 @@ int register_shutdown(int (*function) (void *data), void *data) return 0; } -int programmer_init(enum programmer prog, char *param) +int programmer_init(enum programmer prog, const char *param) { int ret; @@ -517,7 +517,7 @@ char *strcat_realloc(char *dest, const char *src) * needle and remove everything from the first occurrence of needle to the next * delimiter from haystack. */ -char *extract_param(char **haystack, const char *needle, const char *delim) +char *extract_param(const char *const *haystack, const char *needle, const char *delim) { char *param_pos, *opt_pos, *rest; char *opt = NULL; diff --git a/programmer.h b/programmer.h index 1eb0a996..8de42bcc 100644 --- a/programmer.h +++ b/programmer.h @@ -122,7 +122,7 @@ struct programmer_entry { extern const struct programmer_entry programmer_table[]; -int programmer_init(enum programmer prog, char *param); +int programmer_init(enum programmer prog, const char *param); int programmer_shutdown(void); enum bitbang_spi_master_type { -- cgit v1.2.3