1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

Constify (a few) parameters.c where possible

Corresponding to flashrom svn r1354.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
Stefan Tauner 2011-06-26 17:38:17 +00:00
parent b4061f61cd
commit 6665244bc7
3 changed files with 15 additions and 15 deletions

12
flash.h
View File

@ -205,21 +205,21 @@ void map_flash_registers(struct flashchip *flash);
int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len); int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len);
int erase_flash(struct flashchip *flash); int erase_flash(struct flashchip *flash);
int probe_flash(int startchip, struct flashchip *fill_flash, int force); int probe_flash(int startchip, struct flashchip *fill_flash, int force);
int read_flash_to_file(struct flashchip *flash, char *filename); int read_flash_to_file(struct flashchip *flash, const char *filename);
int min(int a, int b); int min(int a, int b);
int max(int a, int b); int max(int a, int b);
void tolower_string(char *str); void tolower_string(char *str);
char *extract_param(char **haystack, char *needle, char *delim); char *extract_param(char **haystack, const char *needle, const char *delim);
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message); int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, const char *message);
int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran); int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran);
char *strcat_realloc(char *dest, const char *src); char *strcat_realloc(char *dest, const char *src);
void print_version(void); void print_version(void);
void print_banner(void); void print_banner(void);
void list_programmers_linebreak(int startcol, int cols, int paren); void list_programmers_linebreak(int startcol, int cols, int paren);
int selfcheck(void); int selfcheck(void);
int doit(struct flashchip *flash, int force, char *filename, int read_it, int write_it, int erase_it, int verify_it); int doit(struct flashchip *flash, int force, const char *filename, int read_it, int write_it, int erase_it, int verify_it);
int read_buf_from_file(unsigned char *buf, unsigned long size, char *filename); int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename);
int write_buf_to_file(unsigned char *buf, unsigned long size, char *filename); int write_buf_to_file(unsigned char *buf, unsigned long size, const char *filename);
#define OK 0 #define OK 0
#define NT 1 /* Not tested */ #define NT 1 /* Not tested */

View File

@ -649,7 +649,7 @@ char *strcat_realloc(char *dest, const char *src)
* needle and remove everything from the first occurrence of needle to the next * needle and remove everything from the first occurrence of needle to the next
* delimiter from haystack. * delimiter from haystack.
*/ */
char *extract_param(char **haystack, char *needle, char *delim) char *extract_param(char **haystack, const char *needle, const char *delim)
{ {
char *param_pos, *opt_pos, *rest; char *param_pos, *opt_pos, *rest;
char *opt = NULL; char *opt = NULL;
@ -706,7 +706,7 @@ char *extract_param(char **haystack, char *needle, char *delim)
return opt; return opt;
} }
char *extract_programmer_param(char *param_name) char *extract_programmer_param(const char *param_name)
{ {
return extract_param(&programmer_param, param_name, ","); return extract_param(&programmer_param, param_name, ",");
} }
@ -735,7 +735,7 @@ int check_erased_range(struct flashchip *flash, int start, int len)
* @message string to print in the "FAILED" message * @message string to print in the "FAILED" message
* @return 0 for success, -1 for failure * @return 0 for success, -1 for failure
*/ */
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message) int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, const char *message)
{ {
int i, ret = 0; int i, ret = 0;
uint8_t *readbuf = malloc(len); uint8_t *readbuf = malloc(len);
@ -1217,7 +1217,7 @@ int verify_flash(struct flashchip *flash, uint8_t *buf)
return ret; return ret;
} }
int read_buf_from_file(unsigned char *buf, unsigned long size, char *filename) int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename)
{ {
unsigned long numbytes; unsigned long numbytes;
FILE *image; FILE *image;
@ -1250,7 +1250,7 @@ int read_buf_from_file(unsigned char *buf, unsigned long size, char *filename)
return 0; return 0;
} }
int write_buf_to_file(unsigned char *buf, unsigned long size, char *filename) int write_buf_to_file(unsigned char *buf, unsigned long size, const char *filename)
{ {
unsigned long numbytes; unsigned long numbytes;
FILE *image; FILE *image;
@ -1274,7 +1274,7 @@ int write_buf_to_file(unsigned char *buf, unsigned long size, char *filename)
return 0; return 0;
} }
int read_flash_to_file(struct flashchip *flash, char *filename) int read_flash_to_file(struct flashchip *flash, const char *filename)
{ {
unsigned long size = flash->total_size * 1024; unsigned long size = flash->total_size * 1024;
unsigned char *buf = calloc(size, sizeof(char)); unsigned char *buf = calloc(size, sizeof(char));
@ -1577,7 +1577,7 @@ void emergency_help_message(void)
} }
/* The way to go if you want a delimited list of programmers*/ /* The way to go if you want a delimited list of programmers*/
void list_programmers(char *delim) void list_programmers(const char *delim)
{ {
enum programmer p; enum programmer p;
for (p = 0; p < PROGRAMMER_INVALID; p++) { for (p = 0; p < PROGRAMMER_INVALID; p++) {
@ -1846,7 +1846,7 @@ int chip_safety_check(struct flashchip *flash, int force, int read_it, int write
* but right now it allows us to split off the CLI code. * but right now it allows us to split off the CLI code.
* Besides that, the function itself is a textbook example of abysmal code flow. * Besides that, the function itself is a textbook example of abysmal code flow.
*/ */
int doit(struct flashchip *flash, int force, char *filename, int read_it, int write_it, int erase_it, int verify_it) int doit(struct flashchip *flash, int force, const char *filename, int read_it, int write_it, int erase_it, int verify_it)
{ {
uint8_t *oldcontents; uint8_t *oldcontents;
uint8_t *newcontents; uint8_t *newcontents;

View File

@ -505,7 +505,7 @@ extern int programmer_may_write;
extern unsigned long flashbase; extern unsigned long flashbase;
void check_chip_supported(const struct flashchip *flash); void check_chip_supported(const struct flashchip *flash);
int check_max_decode(enum chipbustype buses, uint32_t size); int check_max_decode(enum chipbustype buses, uint32_t size);
char *extract_programmer_param(char *param_name); char *extract_programmer_param(const char *param_name);
/* layout.c */ /* layout.c */
int show_id(uint8_t *bios, int size, int force); int show_id(uint8_t *bios, int size, int force);