diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-11-11 20:40:18 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-11-16 22:58:38 -0800 |
commit | 66c09c83aa2f64b31dc657f90447c269621545b7 (patch) | |
tree | 211b6c3ea96175770e25a62a1220d898f4a9e0c7 | |
parent | 8751095511c7d9065ab12a40e90e38bdd9d728e4 (diff) |
Fix gcc -Wwrite-strings warnings
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r-- | exec.c | 2 | ||||
-rw-r--r-- | handle.c | 6 | ||||
-rw-r--r-- | pf.c | 18 | ||||
-rw-r--r-- | wq.h | 2 | ||||
-rw-r--r-- | xmodmap.c | 2 | ||||
-rw-r--r-- | xmodmap.h | 3 |
6 files changed, 18 insertions, 15 deletions
@@ -280,7 +280,7 @@ PrintKeyTable(Bool exprs, FILE *fp) max--; for (j = 0; j <= max; j++) { register KeySym ks = keymap[j]; - char *s; + const char *s; if (ks != NoSymbol) s = XKeysymToString (ks); else @@ -144,7 +144,7 @@ static int skip_chars ( const char *s, int len ); static int skip_space ( const char *s, int len ); static struct dt { - char *command; /* name of input command */ + const char *command; /* name of input command */ int length; /* length of command */ void (*proc)(char *, int); /* handler */ } dispatch_table[] = { @@ -277,7 +277,7 @@ add_to_work_queue(union op *p) /* this can become a macro someday */ static Bool parse_number(const char *str, unsigned long *val) { - char *fmt = "%ld"; + const char *fmt = "%ld"; if (*str == '0') { str++; @@ -324,7 +324,7 @@ static void do_keycode(char *line, int len) { int dummy; - char *fmt = "%d"; + const char *fmt = "%d"; KeyCode keycode; if (len < 3 || !line || *line == '\0') { /* 5=a minimum */ @@ -78,17 +78,19 @@ void process_file (const char *filename) /* NULL means use stdin */ } -void process_line (char *buffer) +void process_line (const char *line) { int len; int i; - char *cp; - - /* copy buffer since it may point to unwritable date */ - len = strlen(buffer); - cp = chk_malloc(len + 1); - strcpy(cp, buffer); - buffer = cp; + char *cp, *buffer; + + /* copy line to buffer since it may point to unwritable data */ + len = strlen(line); + cp = buffer = strdup(line); + if (buffer == NULL) { + fprintf(stderr, "%s: Could not allocate %d bytes\n", ProgramName, len); + Exit(-1); + } for (i = 0; i < len; i++) { /* look for blank lines */ register char c = buffer[i]; @@ -135,7 +135,7 @@ extern struct wq { extern struct modtab { - char *name; + const char *name; int length; int value; } modifier_table[]; @@ -39,7 +39,7 @@ int min_keycode, max_keycode; Bool verbose = False; Bool dontExecute = False; -static void +void _X_NORETURN Exit(int status) { @@ -37,7 +37,7 @@ extern int parse_errors; extern void initialize_map(void); extern void process_file(const char *filename); -extern void process_line(char *buffer); +extern void process_line(const char *buffer); extern void handle_line(char *line, int len); extern void print_work_queue(void); extern int execute_work_queue(void); @@ -55,4 +55,5 @@ extern void PrintKeyTable(Bool exprs, FILE *fp); extern void PrintPointerMap(FILE *fp); extern int SetPointerMap(unsigned char *map, int n); +extern void _X_NORETURN Exit(int status); extern void *chk_malloc(size_t n_bytes); |