eshankelkar@galorithm.com has uploaded this change for review.

View Change

sfdp.c : Initializing hbuf to avoid warnings generated by scan-build

scan-build uses the clang analyzer which is giving warnings
about garbage/undefined values in hbuf assigned to member of hdrs[0]
if hbuf is not initialized.

Though the path of the control flow shown by it in its html output
cannot occur in reality(since it assumes that (nph+1)*8 is <= 0 i.e
nph<=-1 but later assumes 0 <= nph ) hence its a false positive.
Still initializing all bytes of hbuf to 0 leads to the two warnings
for sfdp.c (one for hbuf, one for tbuf) to go away.

Signed-off by : Eshan Kelkar <eshankelkar@galorithm.com>

Change-Id: I6815e246b4fd225d1837cae6e7d2aa0236b48b1b
---
M sfdp.c
1 file changed, 27 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/91/71791/1
diff --git a/sfdp.c b/sfdp.c
index 5eddb21..b5010d6 100644
--- a/sfdp.c
+++ b/sfdp.c
@@ -296,6 +296,12 @@

/* Fetch all parameter headers, even if we don't use them all (yet). */
hbuf = malloc((nph + 1) * 8);
+ uint8_t k;
+ for (i=0; i<=nph; i++){
+ for (k=0 ; k<=7 ; k++)
+ hbuf[i*8+k]=(uint8_t)0;
+ }
+
hdrs = malloc((nph + 1) * sizeof(*hdrs));
if (hbuf == NULL || hdrs == NULL ) {
msg_gerr("Out of memory!\n");

To view, visit change 71791. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I6815e246b4fd225d1837cae6e7d2aa0236b48b1b
Gerrit-Change-Number: 71791
Gerrit-PatchSet: 1
Gerrit-Owner: eshankelkar@galorithm.com
Gerrit-MessageType: newchange