From: Michel Pollet Date: Thu, 9 Apr 2015 20:28:51 +0000 (+0100) Subject: lin: Checked a divide by zero condition X-Git-Tag: v1.3~51 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=3c2839b50928e0abe64db218b5b077b799624fd1;p=sx%2Fsimavr.git 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 --- 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*/;