Skip to content

Commit 2e76508

Browse files
committed
Use correct pointer macro.
1 parent a2ac5c2 commit 2e76508

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/cmock_generator_plugin_return_thru_ptr.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def mock_precheck_return_thru_ptr(function)
7979
arg_name = arg[:name]
8080
next unless @utils.ptr_or_str?(arg[:type]) && !(arg[:const?])
8181

82-
dest_cast = arg[:volatile?] ? '(void*)(uintptr_t)' : '(void*)'
82+
dest_cast = arg[:volatile?] ? '(void*)(CMOCK_MEM_PTR_AS_INT)' : '(void*)'
8383
lines << " if (Mock.#{function[:name]}_IgnoreBool && cmock_call_instance != NULL &&\n"
8484
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Used)\n"
8585
lines << " {\n"
@@ -134,7 +134,7 @@ def mock_implementation(function)
134134
arg_name = arg[:name]
135135
next unless @utils.ptr_or_str?(arg[:type]) && !(arg[:const?])
136136

137-
dest_cast = arg[:volatile?] ? '(void*)(uintptr_t)' : '(void*)'
137+
dest_cast = arg[:volatile?] ? '(void*)(CMOCK_MEM_PTR_AS_INT)' : '(void*)'
138138
lines << " if (cmock_call_instance->ReturnThruPtr_#{arg_name}_Used)\n"
139139
lines << " {\n"
140140
lines << " UNITY_TEST_ASSERT_NOT_NULL(#{arg_name}, cmock_line, CMockStringPtrIsNULL);\n"

test/unit/cmock_generator_plugin_return_thru_ptr_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ def volatile_ptr_func_expect
252252
assert_equal(expected, returned)
253253
end
254254

255-
it "uses (void*)(uintptr_t) cast in mock_implementation for volatile pointer arg" do
255+
it "uses (void*)(CMOCK_MEM_PTR_AS_INT) cast in mock_implementation for volatile pointer arg" do
256256
volatile_ptr_func_expect()
257257

258258
expected =
259259
" if (cmock_call_instance->ReturnThruPtr_foo_handle_Used)\n" +
260260
" {\n" +
261261
" UNITY_TEST_ASSERT_NOT_NULL(foo_handle, cmock_line, CMockStringPtrIsNULL);\n" +
262-
" CMOCK_MEMCPY((void*)(uintptr_t)foo_handle, (const void*)cmock_call_instance->ReturnThruPtr_foo_handle_Val,\n" +
262+
" CMOCK_MEMCPY((void*)(CMOCK_MEM_PTR_AS_INT)foo_handle, (const void*)cmock_call_instance->ReturnThruPtr_foo_handle_Val,\n" +
263263
" cmock_call_instance->ReturnThruPtr_foo_handle_Size);\n" +
264264
" }\n"
265265

0 commit comments

Comments
 (0)