From: Bernhard Beschow Date: Sun, 19 Oct 2025 21:02:57 +0000 (+0200) Subject: hw/rtc/mc146818rtc: Use ARRAY_SIZE macro X-Git-Tag: v10.2.0-rc1~53^2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3006fa8d26fe8b8d9b344c9e983513cd59477cb7;p=thirdparty%2Fqemu.git hw/rtc/mc146818rtc: Use ARRAY_SIZE macro Avoids the error-prone repetition of the array size. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20251019210303.104718-5-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index 61e9c0bf99..5a89062b4c 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -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]; }