Changeset 94795812 in mainline for kernel/generic/include/macros.h


Ignore:
Timestamp:
2012-11-05T21:52:35Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2d53cfc, 33c2952, efdfebc
Parents:
0941e9ae
Message:

Check for dangerous unsigned integer overflows in check_area_conflicts().

  • Rename overflows_add() to overflows_into_positive().
  • Introduce overflows() for simple sum overflow tests.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/macros.h

    r0941e9ae r94795812  
    130130            | ((((uint64_t) (up)) & UINT32_C(0xffffffff)) << 32))
    131131
    132 /* Test for result wrap-around into positive numbers. */
    133 #define overflows_add(a, b) \
    134         (((a) + (b) < (a)) && ((a) + (b)))
     132/* Test for sum overflow. */
     133#define overflows(a, b) \
     134        ((a) + (b) < (a))
     135
     136/* Test for sum overflow into positive numbers. */
     137#define overflows_into_positive(a, b)   \
     138        (overflows((a), (b)) && ((a) + (b) > 0))
    135139
    136140/** Pseudorandom generator
Note: See TracChangeset for help on using the changeset viewer.