runtime/moninj: Don't try to pack more than 64 channels

Since the status words are only 8 bytes wide, left-shifting
by more than that is undefined behaviour (although it seems like
we got lucky and Clang dind't decide to optimise the whole
implementation away).

See GitHub #601.

Signed-off-by: David Nadlinger <code@klickverbot.at>
This commit is contained in:
David Nadlinger 2016-11-04 14:49:06 +00:00 committed by Sébastien Bourdeauducq
parent 4e03f7ab0a
commit d5974b3af5
1 changed files with 2 additions and 1 deletions

View File

@ -52,7 +52,8 @@ static void moninj_monitor(const ip_addr_t *addr, u16_t port)
reply.ttl_levels = 0; reply.ttl_levels = 0;
reply.ttl_oes = 0; reply.ttl_oes = 0;
reply.ttl_overrides = 0; reply.ttl_overrides = 0;
for(i=0;i<CONFIG_RTIO_REGULAR_TTL_COUNT;i++) { /* send at most 64 channels, the protocol doesn't support more */
for(i=0;i<min(CONFIG_RTIO_REGULAR_TTL_COUNT, 64);i++) {
rtio_moninj_mon_chan_sel_write(i); rtio_moninj_mon_chan_sel_write(i);
rtio_moninj_mon_probe_sel_write(0); rtio_moninj_mon_probe_sel_write(0);
rtio_moninj_mon_value_update_write(1); rtio_moninj_mon_value_update_write(1);