qemu/hw/timer
Philippe Mathieu-Daudé e702fba831 hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning
pxa2xx_timer_tick4() takes an opaque pointer, then calls
pxa2xx_timer_update4(), so the static analyzer can not
verify that the 'n < 8':

  425 static void pxa2xx_timer_tick4(void *opaque)
  426 {
  427     PXA2xxTimer4 *t = (PXA2xxTimer4 *) opaque;
  428     PXA2xxTimerInfo *i = (PXA2xxTimerInfo *) t->tm.info;
  429
  430     pxa2xx_timer_tick(&t->tm);
  433     if (t->control & (1 << 6))
  434         pxa2xx_timer_update4(i, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), t->tm.num - 4);

  135 static void pxa2xx_timer_update4(void *opaque, uint64_t now_qemu, int n)
  136 {
  137     PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;
  140     static const int counters[8] = { 0, 0, 0, 0, 4, 4, 6, 6 };
  142
  143     if (s->tm4[n].control & (1 << 7))
  144         counter = n;
  145     else
  146         counter = counters[n];

Add an assert() to give the static analyzer a hint, this fixes a
warning reported by Clang static code analyzer:

    CC      hw/timer/pxa2xx_timer.o
  hw/timer/pxa2xx_timer.c:146:17: warning: Assigned value is garbage or undefined
          counter = counters[n];
                  ^ ~~~~~~~~~~~

Reported-by: Clang Static Analyzer
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200422133152.16770-10-philmd@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-05-04 14:43:24 +02:00
..
a9gtimer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
allwinner-a10-pit.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
altera_timer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
arm_mptimer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
arm_timer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
armv7m_systick.c armv7m_systick: delay timer_new to avoid memleaks 2020-02-07 14:04:28 +00:00
aspeed_timer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
bcm2835_systmr.c hw/timer/bcm2835: Add the BCM2835 SYS_timer 2019-10-25 13:09:27 +01:00
cadence_ttc.c hw/timer/cadence_ttc: move timer_new from init() into realize() to avoid memleaks 2020-03-05 16:09:16 +00:00
cmsdk-apb-dualtimer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
cmsdk-apb-timer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
digic-timer.c
etraxfs_timer.c hw/watchdog/etraxfs_timer.c: Switch to transaction-based ptimer API 2019-10-22 17:44:00 +01:00
exynos4210_mct.c timer/exynos4210_mct: Remove redundant statement in exynos4210_mct_write() 2020-05-04 11:17:27 +02:00
exynos4210_pwm.c
grlib_gptimer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
hpet.c hw/timer/hpet: Include "exec/address-spaces.h" 2020-03-09 15:59:31 +01:00
i8254_common.c hw/i386: Remove obsolete LoadStateHandler::load_state_old handlers 2019-11-05 23:33:12 +01:00
i8254.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
imx_epit.c
imx_gpt.c
Kconfig hw/timer/Kconfig: Intel 8254 PIT depends of ISA bus 2020-01-07 12:08:39 +01:00
lm32_timer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
Makefile.objs Fix typos and docs, trivial changes and RTC devices split 2019-10-25 14:17:08 +01:00
milkymist-sysctl.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
mips_gictimer.c
mss-timer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
nrf51_timer.c
omap_gptimer.c
omap_synctimer.c
puv3_ost.c
pxa2xx_timer.c hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning 2020-05-04 14:43:24 +02:00
sh_timer.c hw/timer/sh_timer: Switch to transaction-based ptimer API 2019-10-22 17:44:00 +01:00
slavio_timer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
stm32f2xx_timer.c hw/timer/stm32f2xx_timer: Remove dead assignment 2020-05-04 14:43:24 +02:00
trace-events Fix typos and docs, trivial changes and RTC devices split 2019-10-25 14:17:08 +01:00
xilinx_timer.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00