From 15643f8e6797ab3d1c7a3712b5ee5cfed6cc3482 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov <rojer@cesanta.com> Date: Fri, 22 Jul 2016 12:49:07 +0200 Subject: [PATCH] Use rand() instead of random(), it's more standard Remove the random() stubs from the codebase PUBLISHED_FROM=0f56ec7dffa0af1f5061a17d8801239d6f0e32a5 --- mongoose.c | 14 +++----------- mongoose.h | 6 ------ 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/mongoose.c b/mongoose.c index b7e5b3286..6169793ab 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4113,15 +4113,15 @@ static uint32_t mg_ws_random_mask(void) { * is untrusted code that wouldn't have access to a lower level net API * anyway (e.g. web browsers). Hence this feature is low prio for most * mongoose use cases and thus can be disabled, e.g. when porting to a platform - * that lacks random(). + * that lacks rand(). */ #ifdef MG_DISABLE_WS_RANDOM_MASK mask = 0xefbeadde; /* generated with a random number generator, I swear */ #else if (sizeof(long) >= 4) { - mask = (uint32_t) random(); + mask = (uint32_t) rand(); } else if (sizeof(long) == 2) { - mask = (uint32_t) random() << 16 | (uint32_t) random(); + mask = (uint32_t) rand() << 16 | (uint32_t) rand(); } #endif return mask; @@ -9568,10 +9568,6 @@ int gettimeofday(struct timeval *tp, void *tzp) { return 0; } -long int random(void) { - return 42; /* FIXME */ -} - void fprint_str(FILE *fp, const char *str) { while (*str != '\0') { if (*str == '\n') MAP_UARTCharPut(CONSOLE_UART, '\r'); @@ -9631,10 +9627,6 @@ int gettimeofday(struct timeval *tp, void *tzp) { return 0; } -long int random(void) { - return 42; /* FIXME */ -} - #endif /* CS_PLATFORM == CS_P_MSP432 */ #ifdef MG_MODULE_LINES #line 1 "./src/../../common/platforms/simplelink/sl_fs_slfs.h" diff --git a/mongoose.h b/mongoose.h index 592914dbe..12711a62e 100644 --- a/mongoose.h +++ b/mongoose.h @@ -151,7 +151,6 @@ #include <sys/stat.h> #include <time.h> -#define random() rand() #ifdef _MSC_VER #pragma comment(lib, "ws2_32.lib") /* Linking with winsock library */ #endif @@ -187,7 +186,6 @@ #else #define fseeko(x, y, z) fseek((x), (y), (z)) #endif -#define random() rand() typedef int socklen_t; #if _MSC_VER >= 1700 #include <stdint.h> @@ -460,8 +458,6 @@ int asprintf(char **strp, const char *fmt, ...); #endif -long int random(void); - /* TI's libc does not have stat & friends, add them. */ #ifdef __TI_COMPILER_VERSION__ @@ -582,8 +578,6 @@ struct SlTimeval_t; int gettimeofday(struct timeval *t, void *tz); #endif -long int random(void); - /* TI's libc does not have stat & friends, add them. */ #ifdef __TI_COMPILER_VERSION__ -- GitLab