On 4/30/24 07:00, Peter Maydell wrote:
+    if (uadd64_overflow(timeout, offset, &nexttick)) {
+        nexttick = UINT64_MAX;
+    }
+    if (nexttick > INT64_MAX / gt_cntfrq_period_ns(cpu)) {
+        /*
+         * If the timeout is too long for the signed 64-bit range
+         * of a QEMUTimer, let it expire early.
+         */
+        timer_mod_ns(cpu->wfxt_timer, INT64_MAX);
+    } else {
+        timer_mod(cpu->wfxt_timer, nexttick);
+    }

The use of both UINT64_MAX and INT64_MAX is confusing.  Perhaps

    if (uadd64_overflow(timeout, offset, &nexttick) ||
        nexttick > INT64_MAX / gt_cntfrq_period_ns(cpu)) {
        nexttick = INT64_MAX;
    }
    timer_mod(cpu->wfxt_timer, nexttick);


Anyway,
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>


r~

Reply via email to