X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=breezed.git;a=blobdiff_plain;f=breezed.c;h=6c4895b09ac637afea90d89c41a132628b49216b;hp=e8043dfd8c7108f14e240962e9be513157df6d2e;hb=269a286192181e8357e5b8ccbb126bdb1e1af6de;hpb=a88d3fc7f89e628686ce18c290f5eca403a3b598 diff --git a/breezed.c b/breezed.c index e8043df..6c4895b 100644 --- a/breezed.c +++ b/breezed.c @@ -155,7 +155,7 @@ void define_temperature_thresholds(char *definition) { exit(EXIT_FAILURE); } - nb_temperature_thresholds = 1; + nb_temperature_thresholds = 0; char *s, *u; @@ -171,14 +171,12 @@ void define_temperature_thresholds(char *definition) { speed_names = safe_malloc(nb_temperature_thresholds * sizeof(char *)); - temperature_thresholds[0] = -1; - s = definition; - int k = 1; + int k = 0; while(s) { s = next_word(token, s, buffer_size); u = token; - while(*u && *u != ':') u++; + while(*u && *u != ':') { u++; } if(*u) { *u = '\0'; temperature_thresholds[k] = atoi(token); @@ -193,10 +191,21 @@ void define_temperature_thresholds(char *definition) { if(k > 0 && temperature_thresholds[k] < temperature_thresholds[k-1]) { fprintf(stderr, "The temperature thresholds have to be increasing.\n"); - exit(0); + exit(EXIT_FAILURE); } k++; } + + if(nb_temperature_thresholds <= 0) { + fprintf(stderr, "There has to be at least one temperature.\n"); + exit(EXIT_FAILURE); + } + + if(temperature_thresholds[0] > 0) { + fprintf(stderr, "The lowest temperature has to be 0.\n"); + exit(EXIT_FAILURE); + } + } void evaluate_one_configuration_line(char *line, int line_number) { @@ -615,8 +624,10 @@ Written by Francois Fleuret (francois@fleuret.org).\n", nb_rounds_since_last_change = 0; last_level = new_level; if(debug) { - printf("Temperature is %dC setting the fan level to %d.\n", - temperature, new_level); + printf("Temperature is %dC setting the fan level to %d (%s).\n", + temperature, + new_level, + speed_names[new_level]); } }