![]() |
|
MISRA C:2012 Rule-21.9: (Required) |
|
||||
![]() | |||||||
Amplification:
The identifiers bsearch and qsort shall not be used and no macro with one of these names shall be expanded.
Example Code:
#pragma PRQA_MESSAGES_OFF 0316,1292,2983,3206
#include <stdlib.h>
#include "misra.h"
#include "m3cmex.h"
static size_t rule_2109a(char (*p)[6]);
static int rule_2109b(const void * pv1, const void * pv2); /* 5209 */
extern int16_t rule_2109( void )
{
char buf[1000][6] = {0};
char (*p)[6];
size_t n;
n = rule_2109a(buf);
qsort(buf, n, 6, rule_2109b); /* 5135 */
p = (char (*)[6])bsearch("ABCDE", buf, n, 6, rule_2109b); /* 5135 */
return 1;
}
static size_t rule_2109a(char (*p)[6])
{
/* Duumy function to initialize array */
return 123;
}
static int rule_2109b(const void * pv1, const void * pv2) /* 5209 */
{
/* Duumy function to compare array elements */
return 0;
}
QAC messages that encompass this guideline:
| 5135 | Use of function: bsearch or qsort. |
|
||
(c) The Motor Industry Research Association, 2012
|
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |