From 3c2839b50928e0abe64db218b5b077b799624fd1 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Thu, 9 Apr 2015 21:28:51 +0100 Subject: [PATCH] lin: Checked a divide by zero condition As it turn out, static analizer doesn't know lbt is >= 8. Added a comment there all same for anyon else reading this. Signed-off-by: Michel Pollet --- simavr/sim/avr_lin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simavr/sim/avr_lin.c b/simavr/sim/avr_lin.c index d719ee4..1be7141 100644 --- a/simavr/sim/avr_lin.c +++ b/simavr/sim/avr_lin.c @@ -55,9 +55,10 @@ avr_lin_baud_write( } avr_core_watch_write(avr, addr, v); // actually set the value - uint32_t lbt = avr_regbit_get(avr, p->lbt); + uint32_t lbt = avr_regbit_get(avr, p->lbt); // Min value CANNOT be zero uint32_t lbrr = (avr->data[p->r_linbrrh] << 8) | avr->data[p->r_linbrrl]; AVR_LOG(avr, LOG_TRACE, "LIN: UART LBT/LBRR to %04x/%04x\n", lbt, lbrr); + // there is no division by zero case here, lbt is >= 8 uint32_t baud = avr->frequency / (lbt * (lbrr + 1)); uint32_t word_size = 1 /*start*/+ 8 /*data bits*/+ 1 /*parity*/+ 1 /*stop*/; -- 2.39.5