aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/keyboard.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-11-20 22:41:41 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-11-21 09:49:25 -0500
commit66725f2e274df6e18f8190b1307c517e7cb27949 (patch)
treedbd826e9fb601c7c499090e4442340f26d02ef19 /sway/input/keyboard.c
parentAdd note about backends to output max_render_time (diff)
downloadsway-66725f2e274df6e18f8190b1307c517e7cb27949.tar.gz
sway-66725f2e274df6e18f8190b1307c517e7cb27949.tar.zst
sway-66725f2e274df6e18f8190b1307c517e7cb27949.zip
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/input/keyboard.c')
-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,
581 if (ic && ic->xkb_file) { 581 if (ic && ic->xkb_file) {
582 FILE *keymap_file = fopen(ic->xkb_file, "r"); 582 FILE *keymap_file = fopen(ic->xkb_file, "r");
583 if (!keymap_file) { 583 if (!keymap_file) {
584 sway_log_errno(SWAY_ERROR, "cannot read xkb file %s", ic->xkb_file);
584 if (error) { 585 if (error) {
585 size_t len = snprintf(NULL, 0, "cannot read XKB file %s: %s", 586 size_t len = snprintf(NULL, 0, "cannot read xkb file %s: %s",
586 ic->xkb_file, strerror(errno)) + 1; 587 ic->xkb_file, strerror(errno)) + 1;
587 *error = malloc(len); 588 *error = malloc(len);
588 if (*error) { 589 if (*error) {
589 snprintf(*error, len, "cannot read XKB file %s: %s", 590 snprintf(*error, len, "cannot read xkb_file %s: %s",
590 ic->xkb_file, strerror(errno));
591 } else {
592 sway_log_errno(SWAY_ERROR, "cannot read XKB file %s: %s",
593 ic->xkb_file, strerror(errno)); 591 ic->xkb_file, strerror(errno));
594 } 592 }
595 } else {
596 sway_log_errno(SWAY_ERROR, "cannot read XKB file %s: %s",
597 ic->xkb_file, strerror(errno));
598 } 593 }
599 goto cleanup; 594 goto cleanup;
600 } 595 }
@@ -602,9 +597,9 @@ struct xkb_keymap *sway_keyboard_compile_keymap(struct input_config *ic,
602 keymap = xkb_keymap_new_from_file(context, keymap_file, 597 keymap = xkb_keymap_new_from_file(context, keymap_file,
603 XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); 598 XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
604 599
605 if (!fclose(keymap_file)) { 600 if (fclose(keymap_file) != 0) {
606 sway_log_errno(SWAY_ERROR, "cannot close XKB file %s: %s", 601 sway_log_errno(SWAY_ERROR, "Failed to close xkb file %s",
607 ic->xkb_file, strerror(errno)); 602 ic->xkb_file);
608 } 603 }
609 } else { 604 } else {
610 struct xkb_rule_names rules = {0}; 605 struct xkb_rule_names rules = {0};