Remove now-unused "input" argument of cmd_results_new

Patch tested by compiling with `__attribute__ ((format (printf, 2, 3)))`
applied to `cmd_results_new`.

String usage constants have been converted from pointers to arrays when
encountered. General handler format strings were sometimes modified to
include the old input string, especially for unknown command errors.
This commit is contained in:
M Stoeckl 2019-01-10 18:27:21 -05:00
parent 6d392150a7
commit 2a684cad5f
131 changed files with 503 additions and 601 deletions

View file

@ -11,8 +11,7 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "accel_profile",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (strcasecmp(argv[0], "adaptive") == 0) {
@ -20,9 +19,9 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
} else if (strcasecmp(argv[0], "flat") == 0) {
ic->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
} else {
return cmd_results_new(CMD_INVALID, "accel_profile",
return cmd_results_new(CMD_INVALID,
"Expected 'accel_profile <adaptive|flat>'");
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -12,8 +12,7 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "click_method",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (strcasecmp(argv[0], "none") == 0) {
@ -23,9 +22,9 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
} else if (strcasecmp(argv[0], "clickfinger") == 0) {
ic->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
} else {
return cmd_results_new(CMD_INVALID, "click_method",
return cmd_results_new(CMD_INVALID,
"Expected 'click_method <none|button_areas|clickfinger'>");
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -12,8 +12,7 @@ struct cmd_results *input_cmd_drag(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE,
"drag", "No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (parse_boolean(argv[0], true)) {
@ -22,5 +21,5 @@ struct cmd_results *input_cmd_drag(int argc, char **argv) {
ic->drag = LIBINPUT_CONFIG_DRAG_DISABLED;
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -12,8 +12,7 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE,
"drag_lock", "No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (parse_boolean(argv[0], true)) {
@ -22,5 +21,5 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
ic->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -12,7 +12,7 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (parse_boolean(argv[0], true)) {
@ -21,5 +21,5 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
ic->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -71,8 +71,7 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "events",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (strcasecmp(argv[0], "enabled") == 0) {
@ -83,7 +82,7 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
ic->send_events =
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
} else if (config->reading) {
return cmd_results_new(CMD_INVALID, "events",
return cmd_results_new(CMD_INVALID,
"Expected 'events <enabled|disabled|disabled_on_external_mouse>'");
} else if (strcasecmp(argv[0], "toggle") == 0) {
if (strcmp(ic->identifier, "*") == 0) {
@ -97,10 +96,10 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
toggle_send_events(ic);
}
} else {
return cmd_results_new(CMD_INVALID, "events",
return cmd_results_new(CMD_INVALID,
"Expected 'events <enabled|disabled|disabled_on_external_mouse|"
"toggle>'");
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -12,11 +12,10 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "left_handed",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->left_handed = parse_boolean(argv[0], true);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -40,8 +40,7 @@ struct cmd_results *input_cmd_map_from_region(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "map_from_region",
"No input device defined");
return cmd_results_new(CMD_FAILURE, "No input device defined");
}
ic->mapped_from_region =
@ -52,30 +51,27 @@ struct cmd_results *input_cmd_map_from_region(int argc, char **argv) {
&ic->mapped_from_region->y1, &mm1)) {
free(ic->mapped_from_region);
ic->mapped_from_region = NULL;
return cmd_results_new(CMD_FAILURE, "map_from_region",
"Invalid top-left coordinates");
return cmd_results_new(CMD_FAILURE, "Invalid top-left coordinates");
}
if (!parse_coords(argv[1], &ic->mapped_from_region->x2,
&ic->mapped_from_region->y2, &mm2)) {
free(ic->mapped_from_region);
ic->mapped_from_region = NULL;
return cmd_results_new(CMD_FAILURE, "map_from_region",
"Invalid bottom-right coordinates");
return cmd_results_new(CMD_FAILURE, "Invalid bottom-right coordinates");
}
if (ic->mapped_from_region->x1 > ic->mapped_from_region->x2 ||
ic->mapped_from_region->y1 > ic->mapped_from_region->y2) {
free(ic->mapped_from_region);
ic->mapped_from_region = NULL;
return cmd_results_new(CMD_FAILURE, "map_from_region",
"Invalid rectangle");
return cmd_results_new(CMD_FAILURE, "Invalid rectangle");
}
if (mm1 != mm2) {
free(ic->mapped_from_region);
ic->mapped_from_region = NULL;
return cmd_results_new(CMD_FAILURE, "map_from_region",
return cmd_results_new(CMD_FAILURE,
"Both coordinates must be in the same unit");
}
ic->mapped_from_region->mm = mm1;
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -13,11 +13,10 @@ struct cmd_results *input_cmd_map_to_output(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "map_to_output",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->mapped_to_output = strdup(argv[0]);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -12,8 +12,7 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "middle_emulation",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (parse_boolean(argv[0], true)) {
@ -22,5 +21,5 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
ic->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -12,11 +12,10 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "natural_scoll",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->natural_scroll = parse_boolean(argv[0], true);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -13,19 +13,17 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE,
"pointer_accel", "No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
float pointer_accel = parse_float(argv[0]);
if (isnan(pointer_accel)) {
return cmd_results_new(CMD_INVALID, "pointer_accel",
return cmd_results_new(CMD_INVALID,
"Invalid pointer accel; expected float.");
} if (pointer_accel < -1 || pointer_accel > 1) {
return cmd_results_new(CMD_INVALID, "pointer_accel",
"Input out of range [-1, 1]");
return cmd_results_new(CMD_INVALID, "Input out of range [-1, 1]");
}
ic->pointer_accel = pointer_accel;
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -11,16 +11,14 @@ struct cmd_results *input_cmd_repeat_delay(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE,
"repeat_delay", "No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
int repeat_delay = atoi(argv[0]);
if (repeat_delay < 0) {
return cmd_results_new(CMD_INVALID, "repeat_delay",
"Repeat delay cannot be negative");
return cmd_results_new(CMD_INVALID, "Repeat delay cannot be negative");
}
ic->repeat_delay = repeat_delay;
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -11,16 +11,14 @@ struct cmd_results *input_cmd_repeat_rate(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE,
"repeat_rate", "No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
int repeat_rate = atoi(argv[0]);
if (repeat_rate < 0) {
return cmd_results_new(CMD_INVALID, "repeat_rate",
"Repeat rate cannot be negative");
return cmd_results_new(CMD_INVALID, "Repeat rate cannot be negative");
}
ic->repeat_rate = repeat_rate;
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -10,30 +10,28 @@ struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "scroll_button",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (strcmp(*argv, "disable") == 0) {
ic->scroll_button = 0;
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}
char *message = NULL;
uint32_t button = get_mouse_button(*argv, &message);
if (message) {
error = cmd_results_new(CMD_INVALID, "scroll_button", message);
error = cmd_results_new(CMD_INVALID, message);
free(message);
return error;
} else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN
|| button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) {
return cmd_results_new(CMD_INVALID, "scroll_button",
return cmd_results_new(CMD_INVALID,
"X11 axis buttons are not supported for scroll_button");
} else if (!button) {
return cmd_results_new(CMD_INVALID, "scroll_button",
"Unknown button %s", *argv);
return cmd_results_new(CMD_INVALID, "Unknown button %s", *argv);
}
ic->scroll_button = button;
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -14,19 +14,18 @@ struct cmd_results *input_cmd_scroll_factor(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE,
"scroll_factor", "No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
float scroll_factor = parse_float(argv[0]);
if (isnan(scroll_factor)) {
return cmd_results_new(CMD_INVALID, "scroll_factor",
return cmd_results_new(CMD_INVALID,
"Invalid scroll factor; expected float.");
} else if (scroll_factor < 0) {
return cmd_results_new(CMD_INVALID, "scroll_factor",
return cmd_results_new(CMD_INVALID,
"Scroll factor cannot be negative.");
}
ic->scroll_factor = scroll_factor;
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -11,8 +11,7 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "scroll_method",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (strcasecmp(argv[0], "none") == 0) {
@ -24,9 +23,9 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
} else if (strcasecmp(argv[0], "on_button_down") == 0) {
ic->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
} else {
return cmd_results_new(CMD_INVALID, "scroll_method",
return cmd_results_new(CMD_INVALID,
"Expected 'scroll_method <none|two_finger|edge|on_button_down>'");
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -13,7 +13,7 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "tap", "No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (parse_boolean(argv[0], true)) {
@ -22,5 +22,5 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
ic->tap = LIBINPUT_CONFIG_TAP_DISABLED;
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -11,8 +11,7 @@ struct cmd_results *input_cmd_tap_button_map(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "tap_button_map",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
if (strcasecmp(argv[0], "lrm") == 0) {
@ -20,9 +19,9 @@ struct cmd_results *input_cmd_tap_button_map(int argc, char **argv) {
} else if (strcasecmp(argv[0], "lmr") == 0) {
ic->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LMR;
} else {
return cmd_results_new(CMD_INVALID, "tap_button_map",
return cmd_results_new(CMD_INVALID,
"Expected 'tap_button_map <lrm|lmr>'");
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -12,11 +12,10 @@ struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "xkb_capslock",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->xkb_capslock = parse_boolean(argv[0], false);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_layout(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "xkb_layout",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->xkb_layout = strdup(argv[0]);
wlr_log(WLR_DEBUG, "set-xkb_layout for config: %s layout: %s",
ic->identifier, ic->xkb_layout);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_model(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "xkb_model",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->xkb_model = strdup(argv[0]);
wlr_log(WLR_DEBUG, "set-xkb_model for config: %s model: %s",
ic->identifier, ic->xkb_model);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -12,11 +12,10 @@ struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "xkb_numlock",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->xkb_numlock = parse_boolean(argv[0], false);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_options(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "xkb_options",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->xkb_options = strdup(argv[0]);
wlr_log(WLR_DEBUG, "set-xkb_options for config: %s options: %s",
ic->identifier, ic->xkb_options);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "xkb_rules",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->xkb_rules = strdup(argv[0]);
wlr_log(WLR_DEBUG, "set-xkb_rules for config: %s rules: %s",
ic->identifier, ic->xkb_rules);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_variant(int argc, char **argv) {
}
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
return cmd_results_new(CMD_FAILURE, "xkb_variant",
"No input device defined.");
return cmd_results_new(CMD_FAILURE, "No input device defined.");
}
ic->xkb_variant = strdup(argv[0]);
wlr_log(WLR_DEBUG, "set-xkb_variant for config: %s variant: %s",
ic->identifier, ic->xkb_variant);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
return cmd_results_new(CMD_SUCCESS, NULL);
}