Re: [PATCH 5/5] tun: vringfd xmit support.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 18, 2008 at 4:46 AM, pradeep singh rautela
<rautelap@xxxxxxxxx> wrote:
>
> On Fri, Apr 18, 2008 at 10:13 AM, Rusty Russell <rusty@xxxxxxxxxxxxxxx> wrote:
>  >  +               /* How many pages will this take? */
>  >  +               npages = 1 + (base + len - 1)/PAGE_SIZE - base/PAGE_SIZE;
>
>  Hi Rusty,
>  A trivial suggestion, how about
>           npages = 1+(len -1)/PAGE_SIZE ?

That's not the same. In particular, his version accounts for the
fractional page at the beginning, while yours doesn't.

While it's tempting to use algebra to simplify things, it's not safe
to do so when the expression involves division over the integers. The
only care-free integer math in a computer is subtraction and ++.
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/virtualization

[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux