Skip to content

Commit

Permalink
Merge pull request #37 from drakenclimber/pressure_cause_fix
Browse files Browse the repository at this point in the history
adaptived: pressure: Fix duration bug
  • Loading branch information
drakenclimber authored Feb 13, 2025
2 parents 21f6aa3 + 531fa5c commit 1d3b673
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion adaptived/src/causes/pressure.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ int pressure_init(struct adaptived_cause * const cse, struct json_object *args_o
opts->duration = -1;
} else if (ret) {
goto error;
} else {
if (opts->duration <= 0) {
adaptived_err("Duration must be greater than zero\n");
ret = -EINVAL;
goto error;
}
}
adaptived_info("%s: ret=%d, opts->duration=%d\n", __func__, ret, opts->duration);

Expand Down Expand Up @@ -237,7 +243,7 @@ int pressure_main(struct adaptived_cause * const cse, int time_since_last_run)
* (opts->current_duration >= opts->duration)
*/
if ((opts->duration < 0 && opts->current_duration > 0) ||
(opts->current_duration >= opts->duration)) {
(opts->duration > 0 && opts->current_duration >= opts->duration)) {
opts->current_duration = 0;
return 1;
}
Expand Down

0 comments on commit 1d3b673

Please sign in to comment.