From: Tyson Smith <tyson.w.smith@xxxxxxxxx> --- include/random.h | 6 ++++-- interesting-numbers.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/random.h b/include/random.h index e30dd9f..4e95996 100644 --- a/include/random.h +++ b/include/random.h @@ -7,8 +7,10 @@ #define ONE_IN(x) ((rand() % x) == 0) // limit of RAND_MAX-1 #if RAND_MAX == 0x7FFFFFFF -#define RAND_32() ((rand() << 1) | (rand() & 1)) -#define RAND_64() (((0ULL | rand()) << 33) | ((0ULL | rand()) << 2) | (rand() & 0x3)) +#define RAND_32() (((unsigned int)rand() << 1) | (rand() & 1)) +#define RAND_64() (((unsigned long long)rand() << 33) | \ + ((unsigned long long)rand() << 2) | \ + (rand() & 0x3)) #else #error "Unexpected RAND_MAX value. Please add support." #endif diff --git a/interesting-numbers.c b/interesting-numbers.c index 66728dd..2fecf3a 100644 --- a/interesting-numbers.c +++ b/interesting-numbers.c @@ -46,7 +46,7 @@ static unsigned int get_interesting_32bit_value(void) switch (rand() % 10) { case 0: return 0x80000000 >> (rand() & 0x1f); // 2^n (1 -> 0x10000) case 1: return rand(); // 0 -> RAND_MAX (likely 0x7fffffff) - case 2: return 0xff << (rand() % 25); + case 2: return 0xffUL << (rand() % 25); case 3: return 0xffff0000; case 4: return 0xffffe000; case 5: return 0xffffff00 | RAND_BYTE(); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe trinity" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html