diff --git a/scp.c b/scp.c index 711776fa..6edbceed 100644 --- a/scp.c +++ b/scp.c @@ -14526,6 +14526,23 @@ delete_Stack (postfix); return cptr; } +/* + * To avoid Coverity complaints about the use of rand() we define the function locally + */ + +static uint32 sim_rand_seed; + +void sim_srand (unsigned int seed) +{ +sim_rand_seed = (uint32)seed; +} + +int sim_rand () +{ +sim_rand_seed = sim_rand_seed * 214013 + 2531011; +return (sim_rand_seed >> 16) & RAND_MAX; +} + /* * Compiled in unit tests for the various device oriented library * modules: sim_card, sim_disk, sim_tape, sim_ether, sim_tmxr, etc. diff --git a/scp.h b/scp.h index 0a2a7eda..4fb4511e 100644 --- a/scp.h +++ b/scp.h @@ -231,6 +231,12 @@ size_t sim_strlcpy (char *dst, const char *src, size_t size); #ifndef strcasecmp #define strcasecmp(str1, str2) sim_strcasecmp ((str1), (str2)) #endif +void sim_srand (unsigned int seed); +int sim_rand (void); +#ifdef RAND_MAX +#undef RAND_MAX +#endif +#define RAND_MAX 32767 CONST char *get_sim_opt (int32 opt, CONST char *cptr, t_stat *st); CONST char *get_sim_sw (CONST char *cptr); const char *put_switches (char *buf, size_t bufsize, uint32 sw); diff --git a/sim_fio.c b/sim_fio.c index dfecb798..44eecafd 100644 --- a/sim_fio.c +++ b/sim_fio.c @@ -41,7 +41,7 @@ sim_finit - initialize package sim_fopen - open file sim_fread - endian independent read (formerly fxread) - sim_write - endian independent write (formerly fxwrite) + sim_fwrite - endian independent write (formerly fxwrite) sim_fseek - conditionally extended (>32b) seek ( sim_fseeko - extended seek (>32b if available) sim_fsize - get file size