lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZPm9VBi+nLrSaUl6@ninjato>
Date:   Thu, 7 Sep 2023 14:08:52 +0200
From:   Wolfram Sang <wsa+renesas@...g-engineering.com>
To:     Biju Das <biju.das.jz@...renesas.com>
Cc:     "linux-renesas-soc@...r.kernel.org" 
        <linux-renesas-soc@...r.kernel.org>,
        Chris Brandt <Chris.Brandt@...esas.com>,
        Andi Shyti <andi.shyti@...nel.org>,
        "linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/5] i2c: riic: avoid potential division by zero


> > -	total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz);
> > +	total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz ?: 1);
> 
> Not sure clamping function min_t/min(t->bus_freq_hz, 1)
> Or ternary condition is good in this case for avoiding potential division by 0?

Both work. I chose the ternary because I believe it involves less
computation and a tad tighter syntax.


Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ