[Qemu-devel] [PATCH v2 05/29] i8254: use QEMU_ALIGN_DOWN

Marc-André Lureau posted 29 patches 8 years, 7 months ago
[Qemu-devel] [PATCH v2 05/29] i8254: use QEMU_ALIGN_DOWN
Posted by Marc-André Lureau 8 years, 7 months ago
I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/timer/i8254_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
index 976d5200f1..ee064aa819 100644
--- a/hw/timer/i8254_common.c
+++ b/hw/timer/i8254_common.c
@@ -93,7 +93,7 @@ int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time)
         }
         break;
     case 2:
-        base = (d / s->count) * s->count;
+        base = QEMU_ALIGN_DOWN(d, s->count);
         if ((d - base) == 0 && d != 0) {
             next_time = base + s->count;
         } else {
@@ -101,7 +101,7 @@ int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time)
         }
         break;
     case 3:
-        base = (d / s->count) * s->count;
+        base = QEMU_ALIGN_DOWN(d, s->count);
         period2 = ((s->count + 1) >> 1);
         if ((d - base) < period2) {
             next_time = base + period2;
-- 
2.13.1.395.gf7b71de06


Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 05/29] i8254: use QEMU_ALIGN_DOWN
Posted by Philippe Mathieu-Daudé 8 years, 7 months ago
On 07/13/2017 01:31 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   hw/timer/i8254_common.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
> index 976d5200f1..ee064aa819 100644
> --- a/hw/timer/i8254_common.c
> +++ b/hw/timer/i8254_common.c
> @@ -93,7 +93,7 @@ int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time)
>           }
>           break;
>       case 2:
> -        base = (d / s->count) * s->count;
> +        base = QEMU_ALIGN_DOWN(d, s->count);
>           if ((d - base) == 0 && d != 0) {
>               next_time = base + s->count;
>           } else {
> @@ -101,7 +101,7 @@ int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time)
>           }
>           break;
>       case 3:
> -        base = (d / s->count) * s->count;
> +        base = QEMU_ALIGN_DOWN(d, s->count);
>           period2 = ((s->count + 1) >> 1);
>           if ((d - base) < period2) {
>               next_time = base + period2;
> 

Re: [Qemu-devel] [PATCH v2 05/29] i8254: use QEMU_ALIGN_DOWN
Posted by Richard Henderson 8 years, 7 months ago
On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/timer/i8254_common.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~