MISRAC2012-Rule-21.9
In this section:
Synopsis
(Required) The library functions bsearch and qsort of stdlib.h shall not be used
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Uses of the library functions bsearch and qsort in stdlib.h were found.
Coding standards
- MISRA C:2012 Rule-21.9
(Required) The library functions bsearch and qsort of <stdlib.h> shall not be used
Code examples
The following code example fails the check and will give a warning:
#include <stdlib.h>
int values[] = { 40, 10, 100, 90, 20, 25 };
int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main ()
{
qsort (values, 6, sizeof(int), compare);
return 0;
}
The following code example passes the check and will not give a warning about this issue:
#include <stdlib.h>
int values[] = { 40, 10, 100, 90, 20, 25 };
int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main ()
{
return 0;
}