mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	load_config: move NULL path check before first use
Found through static analysis
This commit is contained in:
		
							parent
							
								
									8c526bbb03
								
							
						
					
					
						commit
						4eeca10a8a
					
				
					 1 changed files with 5 additions and 5 deletions
				
			
		| 
						 | 
					@ -302,6 +302,11 @@ static char *get_config_path(void) {
 | 
				
			||||||
const char *current_config_path;
 | 
					const char *current_config_path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool load_config(const char *path, struct sway_config *config) {
 | 
					static bool load_config(const char *path, struct sway_config *config) {
 | 
				
			||||||
 | 
						if (path == NULL) {
 | 
				
			||||||
 | 
							wlr_log(L_ERROR, "Unable to find a config file!");
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_log(L_INFO, "Loading config from %s", path);
 | 
						wlr_log(L_INFO, "Loading config from %s", path);
 | 
				
			||||||
	current_config_path = path;
 | 
						current_config_path = path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -310,11 +315,6 @@ static bool load_config(const char *path, struct sway_config *config) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (path == NULL) {
 | 
					 | 
				
			||||||
		wlr_log(L_ERROR, "Unable to find a config file!");
 | 
					 | 
				
			||||||
		return false;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	FILE *f = fopen(path, "r");
 | 
						FILE *f = fopen(path, "r");
 | 
				
			||||||
	if (!f) {
 | 
						if (!f) {
 | 
				
			||||||
		wlr_log(L_ERROR, "Unable to open %s for reading", path);
 | 
							wlr_log(L_ERROR, "Unable to open %s for reading", path);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue