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

Rule:  7.21.aChecked automatically with code checker

Synopsis:Don't use the functions strerror and strtok, instead use their re-entrant counterparts strerror_r and strtok_r.
Language:C
Severity Level:4
Category:Library


Description:

Justification

Non-reentrant functions can cause problems when multiple threads are used or memory is shared between tasks.

Example

token = strtok(string, delimiters); /* WRONG */
token = strtok(NULL, delimiters); /* WRONG */

char *save_ptr;
token = strtok_r(string, delimiters, &save_ptr); /* RIGHT */
token = strtok_r(NULL, delimiters, &save_ptr); /* RIGHT */