瀏覽代碼

can't shift by more or equal to length...

Philippe G 3 年之前
父節點
當前提交
f3c405579f
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      components/services/gpio_exp.c

+ 1 - 1
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