android_kernel_google_msm/include
Paul E. McKenney 7c0a02e992 jiffies: Avoid undefined behavior from signed overflow
commit 5a581b367b upstream.

According to the C standard 3.4.3p3, overflow of a signed integer results
in undefined behavior.  This commit therefore changes the definitions
of time_after(), time_after_eq(), time_after64(), and time_after_eq64()
to avoid this undefined behavior.  The trick is that the subtraction
is done using unsigned arithmetic, which according to 6.2.5p9 cannot
overflow because it is defined as modulo arithmetic.  This has the added
(though admittedly quite small) benefit of shortening four lines of code
by four characters each.

Note that the C standard considers the cast from unsigned to
signed to be implementation-defined, see 6.3.1.3p3.  However, on a
two's-complement system, an implementation that defines anything other
than a reinterpretation of the bits is free to come to me, and I will be
happy to act as a witness for its being committed to an insane asylum.
(Although I have nothing against saturating arithmetic or signals in some
cases, these things really should not be the default when compiling an
operating-system kernel.)

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Kevin Easton <kevin@guarana.org>
[ paulmck: Included time_after64() and time_after_eq64(), as suggested
  by Eric Dumazet, also fixed commit message.]
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Ruchi Kandoi <kandoiruchi@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-23 21:37:08 -07:00
..
acpi Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux 2012-05-05 10:06:06 -07:00
asm-generic mm: allow arch code to control the user page table ceiling 2013-05-07 19:51:55 -07:00
crypto crypto: scatterwalk - Use sg_chain_ptr on chain entries 2013-12-11 22:34:12 -08:00
drm drm/radeon: 0x9649 is SUMO2 not SUMO 2014-01-08 09:42:11 -08:00
keys
linux jiffies: Avoid undefined behavior from signed overflow 2014-03-23 21:37:08 -07:00
math-emu
media media: v4l2: added missing mutex.h include to v4l2-ctrls.h 2013-09-26 17:15:49 -07:00
misc
mtd
net inet: fix addr_len/msg->msg_namelen assignment in recv_error and rxpmtu functions 2013-12-08 07:29:42 -08:00
pcmcia
rdma infiniband: pass rdma_cm module to netlink_dump_start 2012-10-28 10:14:15 -07:00
rxrpc
scsi ore: Fix wrong math in allocation of per device BIO 2014-02-13 11:51:11 -08:00
sound ALSA: memalloc.h - fix wrong truncation of dma_addr_t 2013-12-20 07:34:19 -08:00
target target: Add link_magic for fabric allow_link destination target_items 2013-01-21 11:45:24 -08:00
trace tracing: Allow events to have NULL strings 2013-12-04 10:50:34 -08:00
video atmel_lcdfb: fix 16-bpp modes on older SOCs 2013-03-20 13:05:00 -07:00
xen xen/io/ring.h: new macro to detect whether there are too many requests on the ring 2014-03-11 16:10:07 -07:00
Kbuild