From 37f1e453b16f475cd29f239af422ebc656493784 Mon Sep 17 00:00:00 2001 From: ligd Date: Tue, 24 May 2022 15:03:54 +0800 Subject: [PATCH] uorb: use another writing method to avoid compiler bug int func(int b) { int a; while (1) { ...; if (b != 0) a = 1000 / b; ...; } } if b == 0, then system crash in Xtensa arch, clang compiler Signed-off-by: ligd --- system/uorb/listener.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/uorb/listener.c b/system/uorb/listener.c index 9c10afdb2..eb115967d 100644 --- a/system/uorb/listener.c +++ b/system/uorb/listener.c @@ -499,6 +499,7 @@ static void listener_monitor(FAR struct list_node *objlist, int nb_objects, { FAR struct pollfd *fds; FAR int *recv_msgs; + int interval = topic_rate ? 1000000 / topic_rate : 0; int nb_recv_msgs = 0; int i = 0; @@ -541,9 +542,10 @@ static void listener_monitor(FAR struct list_node *objlist, int nb_objects, listener_print(tmp->object.meta, fd); orb_unsubscribe(fd); } - else if (topic_rate != 0) + else if (interval != 0) { - orb_set_frequency(fd, topic_rate); + orb_set_interval(fd, interval); + if (topic_latency != 0) { orb_set_batch_interval(fd, topic_latency);