1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-29 13:42:11 +00:00

Prevent ALIGN_DOWN() from overflowing.

This commit is contained in:
Pablo Curiel 2021-02-13 19:53:30 -04:00
parent 1d0cc9c45b
commit c3555431d4

View file

@ -53,8 +53,8 @@
#define BIT_LONG(n) (1UL << (n)) #define BIT_LONG(n) (1UL << (n))
#define ALIGN_UP(x, y) ((((y) - 1) + (x)) & ~((y) - 1)) #define ALIGN_UP(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
#define ALIGN_DOWN(x, y) (((x) - ((y) - 1)) & ~((y) - 1)) #define ALIGN_DOWN(x, y) ((x) > (y) ? (((x) - ((y) - 1)) & ~((y) - 1)) : 0)
#define IS_ALIGNED(x, y) (((x) & ((y) - 1)) == 0) #define IS_ALIGNED(x, y) (((x) & ((y) - 1)) == 0)
#define IS_POWER_OF_TWO(x) (((x) & ((x) - 1)) == 0) #define IS_POWER_OF_TWO(x) (((x) & ((x) - 1)) == 0)