From f3c405579fffc2f5c64449f0ff4f1906986640b3 Mon Sep 17 00:00:00 2001 From: Philippe G Date: Mon, 27 Dec 2021 22:01:55 -0800 Subject: [PATCH] can't shift by more or equal to length... --- components/services/gpio_exp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/services/gpio_exp.c b/components/services/gpio_exp.c index cb264f8b..a2ac0582 100644 --- a/components/services/gpio_exp.c +++ b/components/services/gpio_exp.c @@ -463,7 +463,7 @@ void service_handler(void *arg) { xSemaphoreGive(expander->mutex); ESP_LOGD(TAG, "Handling GPIO %d reads 0x%04x and has 0x%04x pending", expander->first, expander->shadow, pending); - for (int gpio = 31, clz; pending; pending <<= (clz + 1)) { + for (int gpio = 31, clz = 0; pending && clz < 31; pending <<= (clz + 1)) { clz = __builtin_clz(pending); gpio -= clz; if (expander->isr[gpio].timer) xTimerReset(expander->isr[gpio].timer, 1); // todo 0