Commit 15643f8e authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Use rand() instead of random(), it's more standard

Remove the random() stubs from the codebase

PUBLISHED_FROM=0f56ec7dffa0af1f5061a17d8801239d6f0e32a5
parent b987df19
...@@ -4113,15 +4113,15 @@ static uint32_t mg_ws_random_mask(void) { ...@@ -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 * 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 * 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 * 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 #ifdef MG_DISABLE_WS_RANDOM_MASK
mask = 0xefbeadde; /* generated with a random number generator, I swear */ mask = 0xefbeadde; /* generated with a random number generator, I swear */
#else #else
if (sizeof(long) >= 4) { if (sizeof(long) >= 4) {
mask = (uint32_t) random(); mask = (uint32_t) rand();
} else if (sizeof(long) == 2) { } else if (sizeof(long) == 2) {
mask = (uint32_t) random() << 16 | (uint32_t) random(); mask = (uint32_t) rand() << 16 | (uint32_t) rand();
} }
#endif #endif
return mask; return mask;
...@@ -9568,10 +9568,6 @@ int gettimeofday(struct timeval *tp, void *tzp) { ...@@ -9568,10 +9568,6 @@ int gettimeofday(struct timeval *tp, void *tzp) {
return 0; return 0;
} }
long int random(void) {
return 42; /* FIXME */
}
void fprint_str(FILE *fp, const char *str) { void fprint_str(FILE *fp, const char *str) {
while (*str != '\0') { while (*str != '\0') {
if (*str == '\n') MAP_UARTCharPut(CONSOLE_UART, '\r'); if (*str == '\n') MAP_UARTCharPut(CONSOLE_UART, '\r');
...@@ -9631,10 +9627,6 @@ int gettimeofday(struct timeval *tp, void *tzp) { ...@@ -9631,10 +9627,6 @@ int gettimeofday(struct timeval *tp, void *tzp) {
return 0; return 0;
} }
long int random(void) {
return 42; /* FIXME */
}
#endif /* CS_PLATFORM == CS_P_MSP432 */ #endif /* CS_PLATFORM == CS_P_MSP432 */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "./src/../../common/platforms/simplelink/sl_fs_slfs.h" #line 1 "./src/../../common/platforms/simplelink/sl_fs_slfs.h"
......
...@@ -151,7 +151,6 @@ ...@@ -151,7 +151,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <time.h> #include <time.h>
#define random() rand()
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma comment(lib, "ws2_32.lib") /* Linking with winsock library */ #pragma comment(lib, "ws2_32.lib") /* Linking with winsock library */
#endif #endif
...@@ -187,7 +186,6 @@ ...@@ -187,7 +186,6 @@
#else #else
#define fseeko(x, y, z) fseek((x), (y), (z)) #define fseeko(x, y, z) fseek((x), (y), (z))
#endif #endif
#define random() rand()
typedef int socklen_t; typedef int socklen_t;
#if _MSC_VER >= 1700 #if _MSC_VER >= 1700
#include <stdint.h> #include <stdint.h>
...@@ -460,8 +458,6 @@ int asprintf(char **strp, const char *fmt, ...); ...@@ -460,8 +458,6 @@ int asprintf(char **strp, const char *fmt, ...);
#endif #endif
long int random(void);
/* TI's libc does not have stat & friends, add them. */ /* TI's libc does not have stat & friends, add them. */
#ifdef __TI_COMPILER_VERSION__ #ifdef __TI_COMPILER_VERSION__
...@@ -582,8 +578,6 @@ struct SlTimeval_t; ...@@ -582,8 +578,6 @@ struct SlTimeval_t;
int gettimeofday(struct timeval *t, void *tz); int gettimeofday(struct timeval *t, void *tz);
#endif #endif
long int random(void);
/* TI's libc does not have stat & friends, add them. */ /* TI's libc does not have stat & friends, add them. */
#ifdef __TI_COMPILER_VERSION__ #ifdef __TI_COMPILER_VERSION__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment