ThrowTheSwitch / CMock

CMock - Mock/stub generator for C
http://throwtheswitch.org
MIT License
653 stars 269 forks source link

Ensure alignment of CMock_Guts_Buffer #401

Closed nordic-krch closed 2 years ago

nordic-krch commented 2 years ago

Another attempt to fix something that was previously fixed by 73255670 but got reversed due to breaking something else.

The issue is that CMock_Guts_Buffer was unsigned char thus it may have been unaligned (byte aligned). Portions from this buffer where casted to a structure. On certain architectures alignment must be maintained when accessing 32bit or 64 bit data and that was not maintained with byte aligned array.

Instead of using attribute that may be complier specific, changing type of array to long long.

Previous fix #172. Fixes #66.

See #210 and revert commit: https://github.com/ThrowTheSwitch/CMock/commit/99c2223a1daa3877d306e585c80f16f2ba0842b7

mvandervoord commented 2 years ago

@nordic-krch -- Thank you for your thoughtful approach. This looks like a good solution to both problems! I appreciate that you took the time to research why the changes happened. That makes this go much better!