Message ID | 20180115100842.20699-1-mario.six@gdsys.cc |
---|---|
State | Accepted |
Delegated to: | Jagannadha Sutradharudu Teki |
Headers | show |
Series | [U-Boot,RESEND,v2,1/8] spi: Fix style violation and improve code | expand |
On Mon, Jan 15, 2018 at 3:38 PM, Mario Six <mario.six@gdsys.cc> wrote: > This patch fixes a printf specifier style violation, reduces the scope > of a variable, and turns a void pointer that is used with pointer > arithmetic into a u8 pointer. > > Signed-off-by: Mario Six <mario.six@gdsys.cc> > --- Reviewed-by: Jagan Teki <jagan@openedev.com> Applied to u-boot-spi/master
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 7d81fbd7f8..dea8dcda5b 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -12,7 +12,7 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen) { if (wordlen == 0 || wordlen > 32) { - printf("spi: invalid wordlen %d\n", wordlen); + printf("spi: invalid wordlen %u\n", wordlen); return -1; } @@ -24,11 +24,12 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen) void *spi_do_alloc_slave(int offset, int size, unsigned int bus, unsigned int cs) { - struct spi_slave *slave; - void *ptr; + u8 *ptr; ptr = malloc(size); if (ptr) { + struct spi_slave *slave; + memset(ptr, '\0', size); slave = (struct spi_slave *)(ptr + offset); slave->bus = bus;
This patch fixes a printf specifier style violation, reduces the scope of a variable, and turns a void pointer that is used with pointer arithmetic into a u8 pointer. Signed-off-by: Mario Six <mario.six@gdsys.cc> --- v1 -> v2: None --- drivers/spi/spi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.11.0