aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
authorLibravatar Alex Xu <alex_y_xu@yahoo.ca>2018-07-12 13:00:57 -0400
committerLibravatar Alex Xu <alex_y_xu@yahoo.ca>2018-07-12 13:00:57 -0400
commitfbecfc2d35b13e640167e73d62ff61c230559dad (patch)
treeb5e3aa7c2e5621e20284fef355dbcb6055d3fe2f /sway/config.c
parentMerge pull request #2250 from RyanDwyer/fix-crash (diff)
downloadsway-fbecfc2d35b13e640167e73d62ff61c230559dad.tar.gz
sway-fbecfc2d35b13e640167e73d62ff61c230559dad.tar.zst
sway-fbecfc2d35b13e640167e73d62ff61c230559dad.zip
config.c: fix current_config uninit warning (#2249)
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sway/config.c b/sway/config.c
index c59f4f0d..d2386f46 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -560,7 +560,7 @@ static char *expand_line(const char *block, const char *line, bool add_brace) {
560 560
561bool read_config(FILE *file, struct sway_config *config) { 561bool read_config(FILE *file, struct sway_config *config) {
562 bool reading_main_config = false; 562 bool reading_main_config = false;
563 char *current_config, *config_pos; 563 char *this_config = NULL, *config_pos;
564 long config_size = 0; 564 long config_size = 0;
565 if (config->current_config == NULL) { 565 if (config->current_config == NULL) {
566 reading_main_config = true; 566 reading_main_config = true;
@@ -569,8 +569,8 @@ bool read_config(FILE *file, struct sway_config *config) {
569 config_size = ftell(file); 569 config_size = ftell(file);
570 rewind(file); 570 rewind(file);
571 571
572 config_pos = current_config = malloc(config_size + 1); 572 config_pos = this_config = malloc(config_size + 1);
573 if (current_config == NULL) { 573 if (this_config == NULL) {
574 wlr_log(WLR_ERROR, "Unable to allocate buffer for config contents"); 574 wlr_log(WLR_ERROR, "Unable to allocate buffer for config contents");
575 return false; 575 return false;
576 } 576 }
@@ -616,7 +616,7 @@ bool read_config(FILE *file, struct sway_config *config) {
616 list_foreach(stack, free); 616 list_foreach(stack, free);
617 list_free(stack); 617 list_free(stack);
618 free(line); 618 free(line);
619 free(current_config); 619 free(this_config);
620 return false; 620 return false;
621 } 621 }
622 wlr_log(WLR_DEBUG, "Expanded line: %s", expanded); 622 wlr_log(WLR_DEBUG, "Expanded line: %s", expanded);
@@ -678,8 +678,8 @@ bool read_config(FILE *file, struct sway_config *config) {
678 list_free(stack); 678 list_free(stack);
679 679
680 if (reading_main_config) { 680 if (reading_main_config) {
681 current_config[config_size - 1] = '\0'; 681 this_config[config_size - 1] = '\0';
682 config->current_config = current_config; 682 config->current_config = this_config;
683 } 683 }
684 return success; 684 return success;
685} 685}