diff options
author | Jason Gerecke <killertofu@gmail.com> | 2015-01-29 10:10:50 -0800 |
---|---|---|
committer | Jason Gerecke <killertofu@gmail.com> | 2015-02-02 18:00:47 -0800 |
commit | 3e89ef073e3327826c33241f555f59d3e3dea3f7 (patch) | |
tree | feb8afb2393d819739a6fb2c141beef45a052bc3 /tools | |
parent | fc28497c0415ecd3487769303eee32f6c8315886 (diff) | |
download | xf86-input-wacom-3e89ef073e3327826c33241f555f59d3e3dea3f7.tar.gz |
tools: Fix up const warnings
Resolve numerous "initialization discards ‘const’ qualifier from pointer
target type" warnings that were present.
Note that in the process of fixing the warning in 'parse_actions', a
small buffer overflow was also corrected (the statement
'sprintf(new_words[0], "+%d", i)' writes one character more than
originally existed in new_words[0]).
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools-shared.c | 2 | ||||
-rw-r--r-- | tools/tools-shared.h | 2 | ||||
-rw-r--r-- | tools/xsetwacom.c | 33 |
3 files changed, 15 insertions, 22 deletions
diff --git a/tools/tools-shared.c b/tools/tools-shared.c index f999cf4..4796c3c 100644 --- a/tools/tools-shared.c +++ b/tools/tools-shared.c @@ -111,7 +111,7 @@ int set_serial_attr(int fd, unsigned int baud) } -int write_to_tablet(int fd, char *command) +int write_to_tablet(int fd, const char *command) { int len = 0; diff --git a/tools/tools-shared.h b/tools/tools-shared.h index 0a1e41f..05cb563 100644 --- a/tools/tools-shared.h +++ b/tools/tools-shared.h @@ -22,7 +22,7 @@ void version(void); int open_device(const char *path); int set_serial_attr(int fd, unsigned int baud); -int write_to_tablet(int fd, char *command); +int write_to_tablet(int fd, const char *command); int stop_tablet(int fd); int start_tablet(int fd); int wait_for_tablet(int fd); diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index db3a776..22b47de 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -550,8 +550,8 @@ is_deprecated_parameter(const char *name) } struct modifier { - char *name; - char *converted; + const char *name; + const char *converted; }; static struct modifier modifiers[] = { @@ -964,7 +964,7 @@ static void list(Display *dpy, int argc, char **argv) * specialkeys. * @return The X Keysym representing specialkey. */ -static char *convert_specialkey(const char *specialkey) +static const char *convert_specialkey(const char *specialkey) { struct modifier *m = modifiers; @@ -1201,7 +1201,7 @@ static int special_map_keystrokes(Display *dpy, int argc, char **argv, unsigned KeySym ks; KeyCode kc; int need_press = 0, need_release = 0; - char *key = argv[i]; + const char *key = argv[i]; if (strlen(key) > 1) { @@ -1332,25 +1332,18 @@ static Bool parse_actions(Display *dpy, int argc, char **argv, unsigned long* da int i = 0; int nwords = 0; char **words = NULL; - + /* translate cmdline commands */ words = strjoinsplit(argc, argv, &nwords); if (nwords==1 && sscanf(words[0], "%d", &i) == 1) { /* Mangle "simple" button maps into proper actions */ - char **new_words = realloc(words, sizeof(char*)*2); - if (new_words == NULL) - { - fprintf(stderr, "Unable to reallocate memory.\n"); - return False; - } - - sprintf(new_words[0], "+%d", i); - new_words[1] = new_words[0]; - new_words[0] = "button"; - - words = new_words; - nwords = 2; + char *nargv[1]; + + free(words); + nargv[0] = alloca(32); + sprintf(nargv[0], "button +%d", i); + words = strjoinsplit(1, nargv, &nwords); } for (i = 0; i < nwords && *nitems < size; i++) @@ -1876,7 +1869,7 @@ static void get_mode(Display *dpy, XDevice *dev, param_t* param, int argc, char static void get_rotate(Display *dpy, XDevice *dev, param_t* param, int argc, char **argv) { - char *rotation = NULL; + const char *rotation = NULL; Atom prop, type; int format; unsigned char* data; @@ -2870,7 +2863,7 @@ static void test_is_modifier(void) static void test_convert_specialkey(void) { char i; - char *converted; + const char *converted; char buff[5]; struct modifier *m; |