about 3 months ago I renamed the SAFEALIGN macros (and added aliases
for backward compatibility) from
according to request in ticket
But, now I think I used wrong new names for these macros, because the
SAFEALIGN_BUF2VAR_<type> is not meant to only copy value from buffer to
variable, it can be used the other way around as well (it is basically
just memcpy with bytes counting). So the original SAFEALIGN_COPY_<> was
IMO much better name for the macro.
The second macro SAFEALIGN_VAR2BUF_<type> is used to SET the buffer at
given address with specified value. This can be used if the
value we copy to buffer is just expression (like 3 + 5), #DEFINEd
constant or literal (so we can not get its address with &, so
SAFEALIGN_COPY_<type> can not be used). The original name of this macro
which was better than the new one. I wrongly interpreted the macros when
creating the new names and realized it now when I wanted to use them.
The reason why the name change was requested is most likely because
might look like it should be used when setting uint32_t variable to
a specific value taken from buffer. The parameter 'value' is
expression of type uint32_t and not address to some uint32_t value
in buffer. Another reason why people might have been confused with the
old names was that it was not clear that with SAFEALIGN_SET the 'value'
is not a pointer to value but the value itself. I think this was the
reason why the ticket was created.
So, I would prefer to change the names once again (the new ones are not
used anywhere so far) to the original ones with one little difference.
The SAFEALIGN_SET_<type> will be SAFEALIGN_SETMEM_<type>. It makes more
clear that we want to change memory at given address (and not set some
variable of type <type>).
With additional comments showing the expected types of all arguments,
this should be clear enough and hopefully nobody will be confused in
Patch is attached.