aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2019-11-20 22:41:41 -0500
committerDrew DeVault <sir@cmpwn.com>2019-11-21 09:49:25 -0500
commit66725f2e274df6e18f8190b1307c517e7cb27949 (patch)
treedbd826e9fb601c7c499090e4442340f26d02ef19 /sway
parentba8586e28269136a8c7278dc10ad6f712c693c2b (diff)
input/keyboard: cleanup xkb_file error handing
This fixes an inverted fclose return value check and simplifies the error handling and logging for xkb_file in sway_keyboard_compile_keymap
Diffstat (limited to 'sway')
-rw-r--r--sway/input/keyboard.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 3e196ae1..cdc4258d 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -581,20 +581,15 @@ struct xkb_keymap *sway_keyboard_compile_keymap(struct input_config *ic,
if (ic && ic->xkb_file) {
FILE *keymap_file = fopen(ic->xkb_file, "r");
if (!keymap_file) {
+ sway_log_errno(SWAY_ERROR, "cannot read xkb file %s", ic->xkb_file);
if (error) {
- size_t len = snprintf(NULL, 0, "cannot read XKB file %s: %s",
+ size_t len = snprintf(NULL, 0, "cannot read xkb file %s: %s",
ic->xkb_file, strerror(errno)) + 1;
*error = malloc(len);
if (*error) {
- snprintf(*error, len, "cannot read XKB file %s: %s",
- ic->xkb_file, strerror(errno));
- } else {
- sway_log_errno(SWAY_ERROR, "cannot read XKB file %s: %s",
+ snprintf(*error, len, "cannot read xkb_file %s: %s",
ic->xkb_file, strerror(errno));
}
- } else {
- sway_log_errno(SWAY_ERROR, "cannot read XKB file %s: %s",
- ic->xkb_file, strerror(errno));
}
goto cleanup;
}
@@ -602,9 +597,9 @@ struct xkb_keymap *sway_keyboard_compile_keymap(struct input_config *ic,
keymap = xkb_keymap_new_from_file(context, keymap_file,
XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
- if (!fclose(keymap_file)) {
- sway_log_errno(SWAY_ERROR, "cannot close XKB file %s: %s",
- ic->xkb_file, strerror(errno));
+ if (fclose(keymap_file) != 0) {
+ sway_log_errno(SWAY_ERROR, "Failed to close xkb file %s",
+ ic->xkb_file);
}
} else {
struct xkb_rule_names rules = {0};