On Wed, Mar 08, 2017 at 02:01:47PM -0700, Simon Glass wrote: > On 4 March 2017 at 06:26, Nicolas Iooss <nicolas.iooss_linux@xxxxxxx> wrote: > > This bug has been found by using clang Static Analyzer: it reported that > > the value stored to fdt was never read. > > > > Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@xxxxxxx> > > --- > > tests/sw_tree1.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > Reviewed-by: Simon Glass <sjg@xxxxxxxxxxxx> > > I suggest changing the code in main() so it starts with a 0 size. Then > the test would catch this problem. Ah, yes, I was going to suggest this when I reviewed the series, but then I forgot. > > > > > diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c > > index 6d4c53102967..4887dc3e1172 100644 > > --- a/tests/sw_tree1.c > > +++ b/tests/sw_tree1.c > > @@ -42,14 +42,14 @@ static void realloc_fdt(void **fdt, size_t *size, bool created) > > switch (alloc_mode) { > > case FIXED: > > if (!(*fdt)) > > - fdt = xmalloc(*size); > > + *fdt = xmalloc(*size); > > else > > FAIL("Ran out of space"); > > return; > > > > case RESIZE: > > if (!(*fdt)) { > > - fdt = xmalloc(SPACE); > > + *fdt = xmalloc(SPACE); > > } else if (*size < SPACE) { > > *size += 1; > > fdt_resize(*fdt, *fdt, *size); > > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature