Patchwork [RFC,4/9] rtc-test: fix set_alarm_time

login
register
mail settings
Submitter Paolo Bonzini
Date Jan. 18, 2012, 10:33 a.m.
Message ID <1326882794-31816-5-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/136582/
State New
Headers show

Comments

Paolo Bonzini - Jan. 18, 2012, 10:33 a.m.
GCC (correctly) reports uninitialized variables.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/rtc-test.c |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)

Patch

diff --git a/tests/rtc-test.c b/tests/rtc-test.c
index 7f0b590..1645b34 100644
--- a/tests/rtc-test.c
+++ b/tests/rtc-test.c
@@ -195,26 +195,12 @@  static void dec_check_time(void)
 
 static void set_alarm_time(struct tm *tm)
 {
-    int sec, min, hour;
-    int hour_offset;
-
-    sec = tm->tm_sec - 1;
+    int sec;
 
+    sec = tm->tm_sec;
 
     if ((cmos_read(RTC_REG_B) & REG_B_DM) == 0) {
         sec = dec2bcd(sec);
-        min = dec2bcd(min);
-        hour = dec2bcd(hour);
-        hour_offset = 80;
-    } else {
-        hour_offset = 0x80;
-    }
-
-    if ((cmos_read(RTC_REG_B) & REG_B_24H) != 0) {
-        if (hour >= 12) {
-            hour -= 12;
-            hour += hour_offset;
-        }
     }
 
     cmos_write(RTC_SECONDS_ALARM, sec);
@@ -236,11 +222,11 @@  static void alarm_time(void)
 
     g_assert(!get_irq(RTC_ISA_IRQ));
 
-    now.tm_sec += 1;
+    now.tm_sec = (now.tm_sec + 2) % 60;
     set_alarm_time(&now);
     cmos_write(RTC_REG_B, cmos_read(RTC_REG_B) | REG_B_AIE);
 
-    for (i = 0; i < 1 + wiggle; i++) {
+    for (i = 0; i < 2 + wiggle; i++) {
         if (get_irq(RTC_ISA_IRQ)) {
             break;
         }