aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorRex Hackbro <rex.hackbro@mailbox.org>2020-08-03 13:25:08 +0200
committerSimon Ser <contact@emersion.fr>2020-08-03 15:39:48 +0200
commit12a9ae013e439146484c14ed4419438491da4db5 (patch)
tree63ff29bce0da5a4669fb2c1e4fcae782adb80a38 /sway
parentd25e308f9cd10c1a92ae21d47530a010be3d68e1 (diff)
downloadsway-12a9ae013e439146484c14ed4419438491da4db5.tar.xz
fix force_display_urgency_hint parsing
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/force_display_urgency_hint.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sway/commands/force_display_urgency_hint.c b/sway/commands/force_display_urgency_hint.c
index 3202fc43..3d432cba 100644
--- a/sway/commands/force_display_urgency_hint.c
+++ b/sway/commands/force_display_urgency_hint.c
@@ -1,5 +1,6 @@
#include "sway/commands.h"
#include "sway/config.h"
+#include <errno.h>
struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) {
struct cmd_results *error = NULL;
@@ -8,13 +9,16 @@ struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) {
return error;
}
- char *err;
- int timeout = (int)strtol(argv[0], &err, 10);
- if (*err) {
- if (strcmp(err, "ms") != 0) {
- return cmd_results_new(CMD_INVALID,
- "Expected 'force_display_urgency_hint <timeout> ms'");
- }
+ errno = 0;
+ char *end;
+ int timeout = (int)strtol(argv[0], &end, 10);
+ if (errno || end == argv[0] || (*end && strcmp(end, "ms") != 0)) {
+ return cmd_results_new(CMD_INVALID, "timeout integer invalid");
+ }
+
+ if (argc > 1 && strcmp(argv[1], "ms") != 0) {
+ return cmd_results_new(CMD_INVALID,
+ "Expected 'force_display_urgency_hint <timeout> [ms]'");
}
config->urgent_timeout = timeout > 0 ? timeout : 0;