From: Peter Maydell Date: Wed, 9 Nov 2011 21:59:50 +0000 (+0000) Subject: hw/pc.c: Fix use-while-uninitialized of fd_type[] X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~5015^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=980bda8ba2322f665934913fbe6c4c202d61a9f9;p=sdk%2Femulator%2Fqemu.git hw/pc.c: Fix use-while-uninitialized of fd_type[] Fix a use-while-uninitialized of the fd_type[] array (introduced in commit 34d4260e1, noticed by Coverity). This is more theoretical than practical, since it's quite hard to get here with floppy==NULL (the qdev_try_create() of the isa-fdc device has to fail). Signed-off-by: Peter Maydell Signed-off-by: Kevin Wolf --- diff --git a/hw/pc.c b/hw/pc.c index 3015671..33778fe 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -335,7 +335,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, ISADevice *s) { int val, nb, nb_heads, max_track, last_sect, i; - FDriveType fd_type[2]; + FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE }; BlockDriverState *fd[MAX_FD]; static pc_cmos_init_late_arg arg; @@ -385,8 +385,6 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, bdrv_get_floppy_geometry_hint(fd[i], &nb_heads, &max_track, &last_sect, FDRIVE_DRV_NONE, &fd_type[i]); - } else { - fd_type[i] = FDRIVE_DRV_NONE; } } }