diff options
| author | Mattias Andrée <m@maandree.se> | 2025-03-05 20:36:07 +0100 | 
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2025-03-05 20:36:07 +0100 | 
| commit | 61821405d8f48117b82ce839c7196eb68c2d8266 (patch) | |
| tree | 8255c88a57d6ec4771284809763349f61267356f /src/options.c | |
| parent | Just use double, no mixing in float (diff) | |
| download | redshift-ng-61821405d8f48117b82ce839c7196eb68c2d8266.tar.gz redshift-ng-61821405d8f48117b82ce839c7196eb68c2d8266.tar.bz2 redshift-ng-61821405d8f48117b82ce839c7196eb68c2d8266.tar.xz | |
Style and warnings
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | src/options.c | 32 | 
1 files changed, 20 insertions, 12 deletions
| diff --git a/src/options.c b/src/options.c index 0f94c3c..95cb636 100644 --- a/src/options.c +++ b/src/options.c @@ -62,8 +62,9 @@ parse_gamma_string(const char *str, double gamma[3])  		gamma[0] = gamma[1] = gamma[2] = g;  	} else {  		/* Parse separate value for each channel */ -		*(s++) = '\0'; -		char *g_s = s; +		char *g_s; +		*s++ = '\0'; +		g_s = s;  		s = strchr(s, ':');  		if (s == NULL) return -1; @@ -82,8 +83,10 @@ static int  parse_transition_time(const char *str, const char **end)  {  	const char *min = NULL; +	long hours, minutes; +  	errno = 0; -	long hours = strtol(str, (char **)&min, 10); +	hours = strtol(str, (char **)&min, 10);  	if (errno != 0 || min == str || min[0] != ':' ||  	    hours < 0 || hours >= 24) {  		return -1; @@ -91,7 +94,7 @@ parse_transition_time(const char *str, const char **end)  	min += 1;  	errno = 0; -	long minutes = strtol(min, (char **)end, 10); +	minutes = strtol(min, (char **)end, 10);  	if (errno != 0 || *end == min || minutes < 0 || minutes >= 60) {  		return -1;  	} @@ -106,15 +109,17 @@ static int  parse_transition_range(const char *str, struct time_range *range)  {  	const char *next = NULL; -	int start_time = parse_transition_time(str, &next); +	int start_time; +	int end_time; + +	start_time = parse_transition_time(str, &next);  	if (start_time < 0) return -1; -	int end_time;  	if (next[0] == '\0') {  		end_time = start_time;  	} else if (next[0] == '-') { -		next += 1;  		const char *end = NULL; +		next += 1;  		end_time = parse_transition_time(next, &end);  		if (end_time < 0 || end[0] != '\0') return -1;  	} else { @@ -311,6 +316,8 @@ parse_command_line_option(  {  	int r;  	char *s; +	char *end; +	char *provider_name;  	switch (option) {  	case 'b': @@ -348,12 +355,11 @@ parse_command_line_option(  			exit(EXIT_SUCCESS);  		} -		char *provider_name = NULL; +		provider_name = NULL;  		/* Don't save the result of strtof(); we simply want  		   to know if value can be parsed as a float. */  		errno = 0; -		char *end;  		strtof(value, &end);  		if (errno == 0 && *end == ':') {  			/* Use instead as arguments to `manual'. */ @@ -611,12 +617,14 @@ options_parse_config_file(  	const struct gamma_method *gamma_methods,  	const struct location_provider *location_providers)  { +	struct config_ini_section *section; +	struct config_ini_setting *setting; +  	/* Read global config settings. */ -	struct config_ini_section *section = config_ini_get_section( -		config_state, "redshift"); +	section = config_ini_get_section(config_state, "redshift");  	if (section == NULL) return; -	struct config_ini_setting *setting = section->settings; +	setting = section->settings;  	while (setting != NULL) {  		int r = parse_config_file_option(  			setting->name, setting->value, options, | 
