Return-Path: Date: Wed, 26 Dec 2012 14:13:50 -0800 (PST) Message-Id: <20121226.141350.999199516661256197.davem@davemloft.net> From: David Miller In-Reply-To: <1356525130-2688-1-git-send-email-akinobu.mita@gmail.com> References: <1356525130-2688-1-git-send-email-akinobu.mita@gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [B.A.T.M.A.N.] [PATCH] batman-adv: fix random jitter calculation 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: akinobu.mita@gmail.com Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, linux-kernel@vger.kernel.org, siwu@hrz.tu-chemnitz.de, lindner_marek@yahoo.de From: Akinobu Mita Date: Wed, 26 Dec 2012 21:32:10 +0900 > batadv_iv_ogm_emit_send_time() attempts to calculates a random integer > in the range of 'orig_interval +- BATADV_JITTER' by the below lines. > > msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER; > msecs += (random32() % 2 * BATADV_JITTER); > > But it actually gets 'orig_interval' or 'orig_interval - BATADV_JITTER' > because '%' and '*' have same precedence and associativity is > left-to-right. > > This adds the parentheses at the appropriate position so that it matches > original intension. > > Signed-off-by: Akinobu Mita > Acked-by: Antonio Quartulli Applied, thanks.