malsyned / pfstest

Professional Firmware Services Unit Test Framework
Other
1 stars 0 forks source link

Handle const qualifier in values, matchers, mocks #6

Closed malsyned closed 6 years ago

malsyned commented 6 years ago

I haven't checked out what issues might exist in supporting const qualified types. Ones I can think of right now include:

malsyned commented 6 years ago

This turned out to be a lot easier than I expected. There is only one place in the code where a boxed value is written to after creation, in assign_arg_do_copy(). If all value objects are treated as const by default, and assign_arg_do_copy() removes the const qualifier, everything works fine.

As far as I can tell, removing the const qualifier from a pointer that actually points to non-const data, then writing to it, is a well-defined operation in C.