From 0b9423520e3839f7e3b87a2011e2fb89a43377b8 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 16 Apr 2021 11:41:06 -0400 Subject: [PATCH] Fix #59, replace direct ref to ArgPtr with macro The UT_Hook_GetArgValueByName macro provided by UT assert is the preferred way to get an argument in the current version. Reading the pointer directly is not advised as it depends on how the stub was actually implemented, whereas the macro should produce consistent results. --- unit-test/coveragetest/coveragetest_sample_lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unit-test/coveragetest/coveragetest_sample_lib.c b/unit-test/coveragetest/coveragetest_sample_lib.c index 08d0a28..cf3ec55 100644 --- a/unit-test/coveragetest/coveragetest_sample_lib.c +++ b/unit-test/coveragetest/coveragetest_sample_lib.c @@ -69,6 +69,7 @@ static int32 UT_printf_hook(void *UserObj, int32 StubRetcode, uint32 CallCount, va_list va) { SAMPLE_LIB_Function_TestState_t *State = UserObj; + const char *string = UT_Hook_GetArgValueByName(Context, "string", const char *); /* * The OS_printf() stub passes format string as the argument @@ -76,7 +77,7 @@ static int32 UT_printf_hook(void *UserObj, int32 StubRetcode, uint32 CallCount, * detail would not be needed, but this serves as an example * of how it can be done. */ - if (Context->ArgCount > 0 && strcmp(Context->ArgPtr[0], "SAMPLE_LIB_Function called, buffer=\'%s\'\n") == 0) + if (Context->ArgCount > 0 && strcmp(string, "SAMPLE_LIB_Function called, buffer=\'%s\'\n") == 0) { State->format_string_valid = true;