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 <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2022-05-24 15:03:54 +08:00 committed by Alan Carvalho de Assis
parent 8558e63772
commit 37f1e453b1

View File

@ -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);