[flashrom] [PATCH 1/6] Make some char pointers const

Nico Huber nico.huber at secunet.com
Mon Dec 10 15:34:09 CET 2012


This makes some char pointers const to get a more convenient libflashrom
interface.

Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
 flash.h      |    4 ++--
 flashrom.c   |    8 ++++----
 programmer.h |    2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/flash.h b/flash.h
index 526087c..a4cdde2 100644
--- a/flash.h
+++ b/flash.h
@@ -221,7 +221,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);
@@ -230,7 +230,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 **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 e2ad170..b0366ec 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
@@ -305,7 +305,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;
 
@@ -470,7 +470,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 **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 dedec67..fb1b666 100644
--- a/programmer.h
+++ b/programmer.h
@@ -105,7 +105,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 {
-- 
1.7.9.5





More information about the flashrom mailing list