Merge pull request #2253 from Hello71/issue2249

config.c: fix current_config uninit warning (#2249)
This commit is contained in:
Drew DeVault 2018-07-12 12:49:11 -07:00 committed by GitHub
commit da8149c066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -560,7 +560,7 @@ static char *expand_line(const char *block, const char *line, bool add_brace) {
bool read_config(FILE *file, struct sway_config *config) { bool read_config(FILE *file, struct sway_config *config) {
bool reading_main_config = false; bool reading_main_config = false;
char *current_config, *config_pos; char *this_config = NULL, *config_pos;
long config_size = 0; long config_size = 0;
if (config->current_config == NULL) { if (config->current_config == NULL) {
reading_main_config = true; reading_main_config = true;
@ -569,8 +569,8 @@ bool read_config(FILE *file, struct sway_config *config) {
config_size = ftell(file); config_size = ftell(file);
rewind(file); rewind(file);
config_pos = current_config = malloc(config_size + 1); config_pos = this_config = malloc(config_size + 1);
if (current_config == NULL) { if (this_config == NULL) {
wlr_log(WLR_ERROR, "Unable to allocate buffer for config contents"); wlr_log(WLR_ERROR, "Unable to allocate buffer for config contents");
return false; return false;
} }
@ -616,7 +616,7 @@ bool read_config(FILE *file, struct sway_config *config) {
list_foreach(stack, free); list_foreach(stack, free);
list_free(stack); list_free(stack);
free(line); free(line);
free(current_config); free(this_config);
return false; return false;
} }
wlr_log(WLR_DEBUG, "Expanded line: %s", expanded); wlr_log(WLR_DEBUG, "Expanded line: %s", expanded);
@ -678,8 +678,8 @@ bool read_config(FILE *file, struct sway_config *config) {
list_free(stack); list_free(stack);
if (reading_main_config) { if (reading_main_config) {
current_config[config_size - 1] = '\0'; this_config[config_size - 1] = '\0';
config->current_config = current_config; config->current_config = this_config;
} }
return success; return success;
} }