@@ -51,11 +51,11 @@ def mock_function_declarations(function)
5151 elsif function [ :return ] [ :void? ]
5252 lines << "#define #{ function [ :name ] } _ExpectAndReturn(#{ function [ :args_call ] } , cmock_retval) TEST_FAIL_MESSAGE(\" #{ function [ :name ] } requires _Expect (not AndReturn)\" );\n " if @error_stubs
5353 lines << "#define #{ function [ :name ] } _Expect(#{ function [ :args_call ] } ) #{ function [ :name ] } _CMockExpect(__LINE__, #{ function [ :args_call ] } )\n "
54- lines << "void #{ function [ :name ] } _CMockExpect(UNITY_LINE_TYPE cmock_line, #{ function [ :args_string ] } );\n "
54+ lines << "void #{ function [ :name ] } _CMockExpect(UNITY_LINE_TYPE cmock_line, #{ helper_args_string ( function ) } );\n "
5555 else
5656 lines << "#define #{ function [ :name ] } _Expect(#{ function [ :args_call ] } ) TEST_FAIL_MESSAGE(\" #{ function [ :name ] } requires _ExpectAndReturn\" );\n " if @error_stubs
5757 lines << "#define #{ function [ :name ] } _ExpectAndReturn(#{ function [ :args_call ] } , cmock_retval) #{ function [ :name ] } _CMockExpectAndReturn(__LINE__, #{ function [ :args_call ] } , cmock_retval)\n "
58- lines << "void #{ function [ :name ] } _CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, #{ function [ :args_string ] } , #{ function [ :return ] [ :str ] } );\n "
58+ lines << "void #{ function [ :name ] } _CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, #{ helper_args_string ( function ) } , #{ function [ :return ] [ :str ] } );\n "
5959 end
6060 lines
6161 end
@@ -86,12 +86,12 @@ def mock_interfaces(function)
8686 if function [ :args_string ] == 'void'
8787 "void #{ func_name } _CMockExpect(UNITY_LINE_TYPE cmock_line)\n {\n "
8888 else
89- "void #{ func_name } _CMockExpect(UNITY_LINE_TYPE cmock_line, #{ function [ :args_string ] } )\n {\n "
89+ "void #{ func_name } _CMockExpect(UNITY_LINE_TYPE cmock_line, #{ helper_args_string ( function ) } )\n {\n "
9090 end
9191 elsif function [ :args_string ] == 'void'
9292 "void #{ func_name } _CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, #{ function [ :return ] [ :str ] } )\n {\n "
9393 else
94- "void #{ func_name } _CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, #{ function [ :args_string ] } , #{ function [ :return ] [ :str ] } )\n {\n "
94+ "void #{ func_name } _CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, #{ helper_args_string ( function ) } , #{ function [ :return ] [ :str ] } )\n {\n "
9595 end
9696 lines << " TEST_MESSAGE(\" CMock: #{ func_name } _#{ function [ :return ] [ :void? ] ? 'Expect' : 'ExpectAndReturn' } called\" );\n " if @debug_output
9797 lines << @utils . code_add_base_expectation ( func_name )
@@ -107,4 +107,17 @@ def mock_verify(function)
107107 " UNITY_TEST_FAIL(cmock_line, CMockStringCalledLess);\n " \
108108 " }\n "
109109 end
110+
111+ private
112+
113+ # Build args string for generated _CMockExpect/_CMockExpectAndReturn helper signatures.
114+ # Converts flat array parameters (e.g. POINT_T a[N]) to pointer notation (POINT_T* a)
115+ # to avoid GCC -Wstringop-overflow, which treats static array sizes in function
116+ # parameters as bounds hints and errors when callers pass smaller objects.
117+ def helper_args_string ( function )
118+ return function [ :args_string ] if function [ :args_string ] == 'void'
119+ return function [ :args_string ] unless function [ :args ] &.any? { |m | m . is_a? ( Hash ) && m [ :array_dims ] }
120+
121+ function [ :args ] . map { |m | CMockGeneratorUtils . arg_declaration ( m ) } . join ( ', ' )
122+ end
110123end
0 commit comments