mirror of
https://github.com/simh/simh.git
synced 2026-02-26 16:54:22 +00:00
SCP: Add a local rand() implementation to avoid Coverity issues
This commit is contained in:
17
scp.c
17
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.
|
||||
|
||||
6
scp.h
6
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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user