SCP: Add a local rand() implementation to avoid Coverity issues
This commit is contained in:
parent
726a07b547
commit
5960bca32a
3 changed files with 24 additions and 1 deletions
17
scp.c
17
scp.c
|
@ -14526,6 +14526,23 @@ delete_Stack (postfix);
|
||||||
return cptr;
|
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
|
* Compiled in unit tests for the various device oriented library
|
||||||
* modules: sim_card, sim_disk, sim_tape, sim_ether, sim_tmxr, etc.
|
* 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
|
#ifndef strcasecmp
|
||||||
#define strcasecmp(str1, str2) sim_strcasecmp ((str1), (str2))
|
#define strcasecmp(str1, str2) sim_strcasecmp ((str1), (str2))
|
||||||
#endif
|
#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_opt (int32 opt, CONST char *cptr, t_stat *st);
|
||||||
CONST char *get_sim_sw (CONST char *cptr);
|
CONST char *get_sim_sw (CONST char *cptr);
|
||||||
const char *put_switches (char *buf, size_t bufsize, uint32 sw);
|
const char *put_switches (char *buf, size_t bufsize, uint32 sw);
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
sim_finit - initialize package
|
sim_finit - initialize package
|
||||||
sim_fopen - open file
|
sim_fopen - open file
|
||||||
sim_fread - endian independent read (formerly fxread)
|
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_fseek - conditionally extended (>32b) seek (
|
||||||
sim_fseeko - extended seek (>32b if available)
|
sim_fseeko - extended seek (>32b if available)
|
||||||
sim_fsize - get file size
|
sim_fsize - get file size
|
||||||
|
|
Loading…
Add table
Reference in a new issue