diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2018-07-01 23:36:44 +0900 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2018-07-02 08:03:41 +0900 |
commit | 4eeca10a8a1bdef73c0ad7dc8e4d74bb31507676 (patch) | |
tree | 889e0d9af9f128bfa947d2db2cba5ceb5a697675 | |
parent | config include: fix leak on relative include path (diff) | |
download | sway-4eeca10a8a1bdef73c0ad7dc8e4d74bb31507676.tar.gz sway-4eeca10a8a1bdef73c0ad7dc8e4d74bb31507676.tar.zst sway-4eeca10a8a1bdef73c0ad7dc8e4d74bb31507676.zip |
load_config: move NULL path check before first use
Found through static analysis
-rw-r--r-- | sway/config.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sway/config.c b/sway/config.c index 8b6f7b6f..0aae1696 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -302,6 +302,11 @@ static char *get_config_path(void) { | |||
302 | const char *current_config_path; | 302 | const char *current_config_path; |
303 | 303 | ||
304 | static bool load_config(const char *path, struct sway_config *config) { | 304 | static bool load_config(const char *path, struct sway_config *config) { |
305 | if (path == NULL) { | ||
306 | wlr_log(L_ERROR, "Unable to find a config file!"); | ||
307 | return false; | ||
308 | } | ||
309 | |||
305 | wlr_log(L_INFO, "Loading config from %s", path); | 310 | wlr_log(L_INFO, "Loading config from %s", path); |
306 | current_config_path = path; | 311 | current_config_path = path; |
307 | 312 | ||
@@ -310,11 +315,6 @@ static bool load_config(const char *path, struct sway_config *config) { | |||
310 | return false; | 315 | return false; |
311 | } | 316 | } |
312 | 317 | ||
313 | if (path == NULL) { | ||
314 | wlr_log(L_ERROR, "Unable to find a config file!"); | ||
315 | return false; | ||
316 | } | ||
317 | |||
318 | FILE *f = fopen(path, "r"); | 318 | FILE *f = fopen(path, "r"); |
319 | if (!f) { | 319 | if (!f) { |
320 | wlr_log(L_ERROR, "Unable to open %s for reading", path); | 320 | wlr_log(L_ERROR, "Unable to open %s for reading", path); |