From 316f3dd6f878660da28f9e35b2e6b3c11857fe7f Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Tue, 10 Nov 2015 15:25:36 +1100 Subject: llvm-scan-build: fix potential division by zero Signed-off-by: Stewart Smith --- hw/p8-i2c.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'hw/p8-i2c.c') diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index 848d400..66510f1 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -1036,6 +1036,7 @@ static void p8_i2c_free_request(struct i2c_request *req) static inline uint32_t p8_i2c_get_bit_rate_divisor(uint32_t lb_freq, uint32_t bus_speed) { + assert(bus_speed > 0); return (((lb_freq / bus_speed) - 1) / 4); } @@ -1043,6 +1044,8 @@ static inline uint64_t p8_i2c_get_poll_interval(uint32_t bus_speed) { uint64_t usec; + assert(bus_speed > 0); + /* Polling Interval = 8 * (1/bus_speed) * (1/10) -> convert to uSec */ usec = ((8 * USEC_PER_SEC) / (10 * bus_speed)); return usecs_to_tb(usec); -- cgit v1.1