aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrestis Floros <orestisflo@gmail.com>2020-02-21 19:01:40 +0100
committerGitHub <noreply@github.com>2020-02-21 19:01:40 +0100
commita376d1e52f4203d43a2a276f292835c531460b7c (patch)
tree1a6bb351d9b964e1d0a7ae7e738840268b80b6a0
parentc5d50ac5fda35013e099320e6b337930c99bfe5b (diff)
parentb98b055459f62b11e9cffe249bc311db1d6af53e (diff)
downloadi3-a376d1e52f4203d43a2a276f292835c531460b7c.tar.gz
i3-a376d1e52f4203d43a2a276f292835c531460b7c.zip
Merge pull request #3950 from xzfc/small-fixes
Small fixes
-rw-r--r--i3-dump-log/main.c4
-rw-r--r--i3bar/src/workspaces.c2
-rw-r--r--include/ipc.h6
-rw-r--r--include/util.h2
-rw-r--r--include/xcb.h4
-rw-r--r--libi3/get_exe_path.c2
-rw-r--r--src/display_version.c3
-rw-r--r--src/manage.c2
-rw-r--r--src/util.c10
-rw-r--r--testcases/inject_randr1.5.c2
-rw-r--r--testcases/t/117-workspace.t15
11 files changed, 33 insertions, 19 deletions
diff --git a/i3-dump-log/main.c b/i3-dump-log/main.c
index 4f15f26f..ba60d396 100644
--- a/i3-dump-log/main.c
+++ b/i3-dump-log/main.c
@@ -246,8 +246,8 @@ int main(int argc, char *argv[]) {
sigaction(SIGINT, &action, NULL);
/* Since pthread_cond_wait() expects a mutex, we need to provide one.
- * To not lock i3 (that’s bad, mhkay?) we just define one outside of
- * the shared memory. */
+ * To not lock i3 (that’s bad, mhkay?) we just define one outside of
+ * the shared memory. */
pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&dummy_mutex);
while (!interrupted) {
diff --git a/i3bar/src/workspaces.c b/i3bar/src/workspaces.c
index 5b43c4a0..68686611 100644
--- a/i3bar/src/workspaces.c
+++ b/i3bar/src/workspaces.c
@@ -114,7 +114,7 @@ static int workspaces_string_cb(void *params_, const unsigned char *val, size_t
if ((config.strip_ws_numbers || config.strip_ws_name) && params->workspaces_walk->num >= 0) {
/* Special case: strip off the workspace number/name */
- static char ws_num[10];
+ static char ws_num[32];
snprintf(ws_num, sizeof(ws_num), "%d", params->workspaces_walk->num);
diff --git a/include/ipc.h b/include/ipc.h
index a608ef56..8ea9fd2e 100644
--- a/include/ipc.h
+++ b/include/ipc.h
@@ -145,9 +145,9 @@ void ipc_send_barconfig_update_event(Barconfig *barconfig);
void ipc_send_binding_event(const char *event_type, Binding *bind);
/**
- * Set the maximum duration that we allow for a connection with an unwriteable
- * socket.
- */
+ * Set the maximum duration that we allow for a connection with an unwriteable
+ * socket.
+ */
void ipc_set_kill_timeout(ev_tstamp new);
/**
diff --git a/include/util.h b/include/util.h
index 8459db10..f0db03a5 100644
--- a/include/util.h
+++ b/include/util.h
@@ -86,7 +86,7 @@ bool layout_from_name(const char *layout_str, layout_t *out);
* interpreted as a "named workspace".
*
*/
-long ws_name_to_number(const char *name);
+int ws_name_to_number(const char *name);
/**
* Updates *destination with new_value and returns true if it was changed or false
diff --git a/include/xcb.h b/include/xcb.h
index 32110c7d..36cc6fb9 100644
--- a/include/xcb.h
+++ b/include/xcb.h
@@ -49,8 +49,8 @@
#define ROOT_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \
XCB_EVENT_MASK_BUTTON_PRESS | \
XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* when the user adds a screen (e.g. video \
- projector), the root window gets a \
- ConfigureNotify */ \
+ * projector), the root window gets a \
+ * ConfigureNotify */ \
XCB_EVENT_MASK_POINTER_MOTION | \
XCB_EVENT_MASK_PROPERTY_CHANGE | \
XCB_EVENT_MASK_FOCUS_CHANGE | \
diff --git a/libi3/get_exe_path.c b/libi3/get_exe_path.c
index e933f5b6..430fb2e0 100644
--- a/libi3/get_exe_path.c
+++ b/libi3/get_exe_path.c
@@ -91,7 +91,7 @@ char *get_exe_path(const char *argv0) {
free(destpath);
sasprintf(&destpath, "%s/%s", component, argv0);
/* Of course this is not 100% equivalent to actually exec()ing the
- * binary, but meh. */
+ * binary, but meh. */
if (access(destpath, X_OK) == 0) {
free(path);
free(tmp);
diff --git a/src/display_version.c b/src/display_version.c
index da11bff3..e44540e0 100644
--- a/src/display_version.c
+++ b/src/display_version.c
@@ -98,7 +98,8 @@ void display_running_version(void) {
if (state != yajl_status_ok)
errx(EXIT_FAILURE, "Could not parse my own reply. That's weird. reply is %.*s", (int)reply_length, reply);
- printf("\rRunning i3 version: %s (pid %s)\n", human_readable_version, pid_from_atom);
+ printf("\r\x1b[K");
+ printf("Running i3 version: %s (pid %s)\n", human_readable_version, pid_from_atom);
if (loaded_config_file_name) {
struct stat sb;
diff --git a/src/manage.c b/src/manage.c
index b223d0f7..726c714c 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -29,7 +29,7 @@ static xcb_window_t _match_depth(i3Window *win, Con *con) {
}
/*
- * Remove all match criteria, the first swallowed window wins.
+ * Remove all match criteria, the first swallowed window wins.
*
*/
static void _remove_matches(Con *con) {
diff --git a/src/util.c b/src/util.c
index 969dc2a2..3544297c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -109,14 +109,12 @@ bool layout_from_name(const char *layout_str, layout_t *out) {
* interpreted as a "named workspace".
*
*/
-long ws_name_to_number(const char *name) {
+int ws_name_to_number(const char *name) {
/* positive integers and zero are interpreted as numbers */
char *endptr = NULL;
- long parsed_num = strtol(name, &endptr, 10);
- if (parsed_num == LONG_MIN ||
- parsed_num == LONG_MAX ||
- parsed_num < 0 ||
- endptr == name) {
+ errno = 0;
+ long long parsed_num = strtoll(name, &endptr, 10);
+ if (errno != 0 || parsed_num > INT32_MAX || parsed_num < 0 || endptr == name) {
parsed_num = -1;
}
diff --git a/testcases/inject_randr1.5.c b/testcases/inject_randr1.5.c
index 29b6a33d..819c029b 100644
--- a/testcases/inject_randr1.5.c
+++ b/testcases/inject_randr1.5.c
@@ -59,7 +59,7 @@ struct connstate {
ev_io *clientw;
/* serverw is a libev watcher for the connection to X11 which we initiated
- * on behalf of the client. */
+ * on behalf of the client. */
ev_io *serverw;
/* sequence is the client-side sequence number counter. In X11’s wire
diff --git a/testcases/t/117-workspace.t b/testcases/t/117-workspace.t
index c97d4fbf..48a0dbf6 100644
--- a/testcases/t/117-workspace.t
+++ b/testcases/t/117-workspace.t
@@ -130,6 +130,21 @@ $ws = get_ws("aa: $tmp");
ok(defined($ws), "workspace aa: $tmp was created");
is($ws->{num}, -1, 'workspace number is -1');
+cmd "workspace -42: $tmp";
+$ws = get_ws("-42: $tmp");
+ok(defined($ws), "workspace -42: $tmp was created");
+is($ws->{num}, -1, 'negative workspace number is ignored');
+
+cmd "workspace 2147483647: $tmp";
+$ws = get_ws("2147483647: $tmp");
+ok(defined($ws), "workspace 2147483647: $tmp was created");
+is($ws->{num}, 2147483647, 'workspace number is 2147483647');
+
+cmd "workspace 2147483648: $tmp";
+$ws = get_ws("2147483648: $tmp");
+ok(defined($ws), "workspace 2147483648: $tmp was created");
+is($ws->{num}, -1, 'workspace number past the limit is ignored');
+
################################################################################
# Check that we can go to workspace "4: foo" with the command
# "workspace number 4".