From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Markus Pargmann Date: Tue, 2 Dec 2014 12:16:22 +0100 Message-Id: <1417519009-20699-5-git-send-email-mpa@pengutronix.de> In-Reply-To: <1417519009-20699-1-git-send-email-mpa@pengutronix.de> References: <1417519009-20699-1-git-send-email-mpa@pengutronix.de> Subject: [B.A.T.M.A.N.] [PATCH 04/31] batman-adv: iv_ogm, divide and round for ring buffer avg Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marek Lindner , Simon Wunderlich , Antonio Quartulli Cc: b.a.t.m.a.n@lists.open-mesh.org Instead of the normal division which looses precision, use a division with rounding. Signed-off-by: Markus Pargmann --- bat_iv_ogm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 1458ecfa66b8..10eada270015 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -82,7 +82,7 @@ static uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[]) if (count == 0) return 0; - return (uint8_t)(sum / count); + return (uint8_t)DIV_ROUND_CLOSEST(sum, count); } /** -- 2.1.3