From ec3aece97cdbe4dc17b46bd7ca5cb89136cfcff0 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Mon, 17 Jul 2017 10:50:18 -0400 Subject: [PATCH] drivers: spi: avoid undefined behavior Void pointer arithmetic is undefined behavior (UB). It's OK for struct spi_buf to contain a void *, because those values are only ever stored, read, and compared. However, pointer arithmetic is done on the tx_buf and rx_buf fields in struct spi_context, so those need to be u8_t * to avoid UB. Signed-off-by: Marti Bolivar --- drivers/spi/spi_context.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi_context.h b/drivers/spi/spi_context.h index e0d14123621..63c8a14fdd7 100644 --- a/drivers/spi/spi_context.h +++ b/drivers/spi/spi_context.h @@ -34,9 +34,9 @@ struct spi_context { struct spi_buf *current_rx; size_t rx_count; - void *tx_buf; + u8_t *tx_buf; size_t tx_len; - void *rx_buf; + u8_t *rx_buf; size_t rx_len; };