[PATCH:xmodmap 1/3] Fix gcc -Wwrite-strings warnings
Alan Coopersmith
alan.coopersmith at oracle.com
Fri Nov 11 21:27:04 PST 2011
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
exec.c | 2 +-
handle.c | 6 +++---
pf.c | 18 ++++++++++--------
wq.h | 2 +-
xmodmap.c | 2 +-
xmodmap.h | 3 ++-
6 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/exec.c b/exec.c
index 0508cd3..dbcb669 100644
--- a/exec.c
+++ b/exec.c
@@ -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
diff --git a/handle.c b/handle.c
index af2f5df..3f05a46 100644
--- a/handle.c
+++ b/handle.c
@@ -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 */
diff --git a/pf.c b/pf.c
index cfb41b7..0cc8101 100644
--- a/pf.c
+++ b/pf.c
@@ -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];
diff --git a/wq.h b/wq.h
index f541b7c..58c062e 100644
--- a/wq.h
+++ b/wq.h
@@ -135,7 +135,7 @@ extern struct wq {
extern struct modtab {
- char *name;
+ const char *name;
int length;
int value;
} modifier_table[];
diff --git a/xmodmap.c b/xmodmap.c
index 3d20e94..f49bc33 100644
--- a/xmodmap.c
+++ b/xmodmap.c
@@ -39,7 +39,7 @@ int min_keycode, max_keycode;
Bool verbose = False;
Bool dontExecute = False;
-static void
+void
_X_NORETURN
Exit(int status)
{
diff --git a/xmodmap.h b/xmodmap.h
index 5addd7b..1540b2a 100644
--- a/xmodmap.h
+++ b/xmodmap.h
@@ -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);
--
1.7.3.2
More information about the xorg-devel
mailing list