testsuite: fix memory access
Depending on optimization level, the TC_RESULT_STR[] array could actually be placed in memory instead of being expanded at compile time, resulting in memory access errors from user mode. Just replace TC_RESULT_TO_STR() with an inline function containing a switch statement instead. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
afda764ee6
commit
a682dedd50
1 changed files with 13 additions and 7 deletions
|
@ -58,13 +58,19 @@
|
||||||
#define TC_FAIL 1
|
#define TC_FAIL 1
|
||||||
#define TC_SKIP 2
|
#define TC_SKIP 2
|
||||||
|
|
||||||
static __unused const char *TC_RESULT_STR[] = {
|
static inline const char *TC_RESULT_TO_STR(int result)
|
||||||
[TC_PASS] = "PASS",
|
{
|
||||||
[TC_FAIL] = "FAIL",
|
switch (result) {
|
||||||
[TC_SKIP] = "SKIP",
|
case TC_PASS:
|
||||||
};
|
return "PASS";
|
||||||
|
case TC_FAIL:
|
||||||
#define TC_RESULT_TO_STR(result) TC_RESULT_STR[result]
|
return "FAIL";
|
||||||
|
case TC_SKIP:
|
||||||
|
return "SKIP";
|
||||||
|
default:
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define TC_ERROR(fmt, ...) \
|
#define TC_ERROR(fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue