Aaron Durbin (adurbin@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5371
-gerrit
commit 0c70e2ca93cf61777adc077971bbd6724d844f2a Author: Aaron Durbin adurbin@chromium.org Date: Wed Mar 5 14:54:13 2014 -0600
cbfstool: elfheaders: use proper parameters to calloc()
Though the result doesn't matter much, the callers of calloc() should order the parameters correctly. i.e. the first paramter is the number of elements in an array and the second is the size of each element.
Change-Id: Ic7c2910d623d96f380feb4e5f6fa432376f49e9b Signed-off-by: Aaron Durbin adurbin@chromium.org --- util/cbfstool/elfheaders.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/cbfstool/elfheaders.c b/util/cbfstool/elfheaders.c index 0b05255..3af82a6 100644 --- a/util/cbfstool/elfheaders.c +++ b/util/cbfstool/elfheaders.c @@ -271,7 +271,7 @@ phdr_read(const struct buffer *in, Elf64_Ehdr *ehdr, struct xdr *xdr, int bit64) * We do them all at once because there is more * than one loop over all the phdrs. */ - phdr = calloc(sizeof(*phdr), ehdr->e_phnum); + phdr = calloc(ehdr->e_phnum, sizeof(*phdr)); for (i = 0; i < ehdr->e_phnum; i++) elf_phdr(&b, &phdr[i], ehdr->e_phentsize, xdr, bit64);
@@ -295,7 +295,7 @@ shdr_read(const struct buffer *in, Elf64_Ehdr *ehdr, struct xdr *xdr, int bit64) return NULL;
/* gather up all the shdrs. */ - shdr = calloc(sizeof(*shdr), ehdr->e_shnum); + shdr = calloc(ehdr->e_shnum, sizeof(*shdr)); for (i = 0; i < ehdr->e_shnum; i++) elf_shdr(&b, &shdr[i], ehdr->e_shentsize, xdr, bit64);