TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
ASML C Coding Standard
Search

Rule:  7.26.2.aChecked automatically with code checker

Synopsis:Don't use the functions rand. Instead use the re-entrant counterpart rand_r.
Language:C
Severity Level:5
Category:Library


Description:

Justification

Non-reentrant functions can cause problems when multiple threads are used or memory is shared between tasks (such as on VxWorks).

Example

#include <stdlib.h>

int rand(void); /* WRONG */
int rand_r(unsigned *seed); /* RIGHT */

Note

Function rand_r is not available on VxWorks in kernel space.