xcore / sw_avb

AVB Software stack
http://github.xcore.com/sw_avb
Other
116 stars 54 forks source link

Fix alias pointer passing bug. #29

Closed ghost closed 10 years ago

ghost commented 11 years ago

In xC if a function argument is restricted pointer and the function accesses a global then you cannot pass a non-local alias pointer (e.g. an alias pointer to a global). This is because the pointer then may alias the global accessed in the function (which it shouldn't since it is a restricted pointer.

This is happening in the code where a pointer to a global is taken:

 avb_1722_1_acmp_inflight_command *inflight =
    &acmp_listener_inflight_commands[i];

and then this is passed into a function that accesses a global:

 acmp_send_command(... &inflight->command ...);

This commit fixes this by explictly marking the parameter to acmp_send_command as aliased. The 13.0.0 compiler has a bug which means it does not spot this error yet but this fix is to safeguard the code when the compiler is fixed.

ajwlucas commented 10 years ago

Fixed in sc_avb:

https://github.com/xcore/sc_avb/commit/ffd0ce5905fb23da57b111bf91208b6375080eea