[Qemu-devel] [PATCH 07/29] ds1338: use QEMU_IS_ALIGNED macro

Philippe Mathieu-Daudé posted 29 patches 8 years, 6 months ago
Only 28 patches received!
[Qemu-devel] [PATCH 07/29] ds1338: use QEMU_IS_ALIGNED macro
Posted by Philippe Mathieu-Daudé 8 years, 6 months ago
Applied using the Coccinelle semantic patch scripts/coccinelle/use_osdep.cocci

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/timer/ds1338.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
index 3849b74a68..a77fe14514 100644
--- a/hw/timer/ds1338.c
+++ b/hw/timer/ds1338.c
@@ -65,7 +65,7 @@ static void capture_current_time(DS1338State *s)
     s->nvram[1] = to_bcd(now.tm_min);
     if (s->nvram[2] & HOURS_12) {
         int tmp = now.tm_hour;
-        if (tmp % 12 == 0) {
+        if (QEMU_IS_ALIGNED(tmp, 12)) {
             tmp += 12;
         }
         if (tmp <= 12) {
@@ -154,7 +154,7 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
                 if (data & HOURS_PM) {
                     tmp += 12;
                 }
-                if (tmp % 12 == 0) {
+                if (QEMU_IS_ALIGNED(tmp, 12)) {
                     tmp -= 12;
                 }
                 now.tm_hour = tmp;
-- 
2.13.2


Re: [Qemu-devel] [PATCH 07/29] ds1338: use QEMU_IS_ALIGNED macro
Posted by Alastair D'Silva 8 years, 6 months ago
I'm not sure this makes sense - we're dealing with time here.

-- 
Alastair D'Silva           mob: 0423 762 819
skype: alastair_dsilva     msn: alastair@d-silva.org
blog: http://alastair.d-silva.org    Twitter: @EvilDeece



> -----Original Message-----
> From: Philippe Mathieu-Daudé [mailto:philippe.mathieu.daude@gmail.com]
> On Behalf Of Philippe Mathieu-Daudé
> Sent: Tuesday, 18 July 2017 4:10 PM
> To: qemu-trivial@nongnu.org; Peter Maydell <peter.maydell@linaro.org>;
> Alastair D'Silva <alastair@d-silva.org>; Corey Minyard
> <cminyard@mvista.com>
> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>; qemu-devel@nongnu.org;
> Eric Blake <eblake@redhat.com>
> Subject: [PATCH 07/29] ds1338: use QEMU_IS_ALIGNED macro
> 
> Applied using the Coccinelle semantic patch
> scripts/coccinelle/use_osdep.cocci
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/timer/ds1338.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c index
> 3849b74a68..a77fe14514 100644
> --- a/hw/timer/ds1338.c
> +++ b/hw/timer/ds1338.c
> @@ -65,7 +65,7 @@ static void capture_current_time(DS1338State *s)
>      s->nvram[1] = to_bcd(now.tm_min);
>      if (s->nvram[2] & HOURS_12) {
>          int tmp = now.tm_hour;
> -        if (tmp % 12 == 0) {
> +        if (QEMU_IS_ALIGNED(tmp, 12)) {
>              tmp += 12;
>          }
>          if (tmp <= 12) {
> @@ -154,7 +154,7 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
>                  if (data & HOURS_PM) {
>                      tmp += 12;
>                  }
> -                if (tmp % 12 == 0) {
> +                if (QEMU_IS_ALIGNED(tmp, 12)) {
>                      tmp -= 12;
>                  }
>                  now.tm_hour = tmp;
> --
> 2.13.2
> 
> 
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com



Re: [Qemu-devel] [PATCH 07/29] ds1338: use QEMU_IS_ALIGNED macro
Posted by Philippe Mathieu-Daudé 8 years, 6 months ago
On Tue, Jul 18, 2017 at 7:23 AM, Alastair D'Silva <alastair@d-silva.org> wrote:
> I'm not sure this makes sense - we're dealing with time here.

Indeed, thanks for your review!

>> --- a/hw/timer/ds1338.c
>> +++ b/hw/timer/ds1338.c
>> @@ -65,7 +65,7 @@ static void capture_current_time(DS1338State *s)
>>      s->nvram[1] = to_bcd(now.tm_min);
>>      if (s->nvram[2] & HOURS_12) {
>>          int tmp = now.tm_hour;
>> -        if (tmp % 12 == 0) {
>> +        if (QEMU_IS_ALIGNED(tmp, 12)) {
>>              tmp += 12;
>>          }
>>          if (tmp <= 12) {
>> @@ -154,7 +154,7 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
>>                  if (data & HOURS_PM) {
>>                      tmp += 12;
>>                  }
>> -                if (tmp % 12 == 0) {
>> +                if (QEMU_IS_ALIGNED(tmp, 12)) {
>>                      tmp -= 12;
>>                  }
>>                  now.tm_hour = tmp;