[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.1.10.0808181740500.3324@nehalem.linux-foundation.org>
Date: Mon, 18 Aug 2008 17:42:55 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Anthony Liguori <aliguori@...ibm.com>
cc: linux-kernel@...r.kernel.org,
Rusty Russell <rusty@...tcorp.com.au>,
Avi Kivity <avi@...ranet.com>,
virtualization@...ts.linux-foundation.org,
Chris Wright <chrisw@...s-sol.org>
Subject: Re: [PATCH] virtio_balloon: fix towards_target when deflating
balloon
On Mon, 18 Aug 2008, Anthony Liguori wrote: <
>
> This handles the case where v < vb->num_pages and ensures we get a
> small, negative, s64 as the result.
That's just horrible code.
Maybe the compiler notices that you're doing something stupid, but
basically, please don't do this.
> - return v - vb->num_pages;
> + if (v < vb->num_pages)
> + return -(s64)(vb->num_pages - v);
> + else
> + return v - vb->num_pages;
What's wrong with just doing
return (s64)v - vb->num_pages;
instead?
Casting 'v' to s64 guarantees that the subtraction will eb done in 64
bits, and the compiler can just generate the trivial non-conditional code.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists