[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] hw/ide/ahci: silence a compiler warning
From: |
Alex Bennée |
Subject: |
[PATCH] hw/ide/ahci: silence a compiler warning |
Date: |
Tue, 6 Oct 2020 16:42:56 +0100 |
When built with -Og -ggdb with gcc 8.3 the compiler gets confused
reporting:
../../hw/ide/ahci.c: In function ‘ahci_populate_sglist’:
../../hw/ide/ahci.c:965:58: error: ‘tbl_entry_size’ may be used uninitialized
in this function [-Werror=maybe-uninitialized]
As prdtl being > 0 is a prerequisite for running the code which
guarantees we execute the loop at least once although not necessarily
resetting off_pos/off_idx which should short-circuit the test anyway.
To save grey hair initialise the value to zero and move the variable
to the local block so future changes can't accidentally use it.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
hw/ide/ahci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 680304a24c..f5c20c7d55 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -925,7 +925,6 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList
*sglist,
uint64_t sum = 0;
int off_idx = -1;
int64_t off_pos = -1;
- int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
@@ -952,6 +951,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList
*sglist,
/* Get entries in the PRDT, init a qemu sglist accordingly */
if (prdtl > 0) {
AHCI_SG *tbl = (AHCI_SG *)prdt;
+ int tbl_entry_size = 0;
sum = 0;
for (i = 0; i < prdtl; i++) {
tbl_entry_size = prdt_tbl_entry_size(&tbl[i]);
--
2.20.1
- [PATCH] hw/ide/ahci: silence a compiler warning,
Alex Bennée <=