]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/rtc/mc146818rtc: Use ARRAY_SIZE macro
authorBernhard Beschow <shentey@gmail.com>
Sun, 19 Oct 2025 21:02:57 +0000 (23:02 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 21 Oct 2025 18:16:47 +0000 (20:16 +0200)
Avoids the error-prone repetition of the array size.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251019210303.104718-5-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/rtc/mc146818rtc.c

index 61e9c0bf99f23deaae765a13f0eecc34fdaa57b7..5a89062b4c5980c4b5722410619f148140f04db1 100644 (file)
@@ -726,13 +726,14 @@ static uint64_t cmos_ioport_read(void *opaque, hwaddr addr,
 
 void mc146818rtc_set_cmos_data(MC146818RtcState *s, int addr, int val)
 {
-    if (addr >= 0 && addr <= 127)
+    if (addr >= 0 && addr < ARRAY_SIZE(s->cmos_data)) {
         s->cmos_data[addr] = val;
+    }
 }
 
 int mc146818rtc_get_cmos_data(MC146818RtcState *s, int addr)
 {
-    assert(addr >= 0 && addr <= 127);
+    assert(addr >= 0 && addr < ARRAY_SIZE(s->cmos_data));
     return s->cmos_data[addr];
 }