[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] hw/timer: fix int underflow
From: |
Дмитрий Фролов |
Subject: |
Re: [PATCH] hw/timer: fix int underflow |
Date: |
Tue, 14 Jan 2025 09:41:33 +0300 |
Hello, Peter.
I beg a pardon, but I guess, we have a misunderstanding here.
The problem is that comparison "if (limit < 0)" will never
be true. Thus, "true" branch is unreachable. According to
the comment below, it was assumed that "limit" may be
negative, and this means, that "QEMU is running too slow...".
"limit" is declared as "long long" and it is initialized
with diff of two unsigned values:
"timeout - imx_gpt_update_count(s)".
Unsigned subtraction will never give a signed result!
if timeout > imx_gpt_update_count(s), the result will be > 0.
if timeout < imx_gpt_update_count(s), the result will also
be > 0 (underflow). Then, actually, this (positive) result
will be implicitly casted to "long long" and assigned to
"limit". This makes no sense!
So, to my opinion, explicit cast to "long long" is necessary
here to get the expected behavior.
With best regards,
Dmitry.
- Re: [PATCH] hw/timer: fix int underflow,
Дмитрий Фролов <=