diff options
-rw-r--r-- | sway/input/input-manager.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 52da8f5e..b20b7b7e 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -34,13 +34,6 @@ static struct sway_seat *input_manager_get_seat( | |||
34 | return sway_seat_create(input, seat_name); | 34 | return sway_seat_create(input, seat_name); |
35 | } | 35 | } |
36 | 36 | ||
37 | static inline int strlen_num(int num) { | ||
38 | if (num == 0) { | ||
39 | return 2; | ||
40 | } | ||
41 | return (int)((ceil(log10(abs(num)))+2)); | ||
42 | } | ||
43 | |||
44 | static char *get_device_identifier(struct wlr_input_device *device) { | 37 | static char *get_device_identifier(struct wlr_input_device *device) { |
45 | int vendor = device->vendor; | 38 | int vendor = device->vendor; |
46 | int product = device->product; | 39 | int product = device->product; |
@@ -54,19 +47,14 @@ static char *get_device_identifier(struct wlr_input_device *device) { | |||
54 | } | 47 | } |
55 | } | 48 | } |
56 | 49 | ||
57 | int len = | 50 | const char *fmt = "%d:%d:%s"; |
58 | (strlen(name) + | 51 | int len = snprintf(NULL, 0, fmt, vendor, product, name) + 1; |
59 | strlen_num(device->vendor) + | ||
60 | strlen_num(device->product) + | ||
61 | 3) * sizeof(char); | ||
62 | |||
63 | char *identifier = malloc(len); | 52 | char *identifier = malloc(len); |
64 | if (!identifier) { | 53 | if (!identifier) { |
65 | sway_log(L_ERROR, "Unable to allocate unique input device name"); | 54 | sway_log(L_ERROR, "Unable to allocate unique input device name"); |
66 | return NULL; | 55 | return NULL; |
67 | } | 56 | } |
68 | 57 | ||
69 | const char *fmt = "%d:%d:%s"; | ||
70 | snprintf(identifier, len, fmt, vendor, product, name); | 58 | snprintf(identifier, len, fmt, vendor, product, name); |
71 | free(name); | 59 | free(name); |
72 | return identifier; | 60 | return identifier; |