From 7f84657aac55a404481eba8ca658bbd3d6c5136c Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 21 Aug 2022 22:46:49 -0400 Subject: [PATCH] refactoring: magic constant --- firmware/controllers/lua/can_filter.h | 1 + firmware/controllers/lua/lua_can_rx.cpp | 2 +- firmware/controllers/lua/lua_hooks.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/lua/can_filter.h b/firmware/controllers/lua/can_filter.h index 69363524d7..7f7b110e24 100644 --- a/firmware/controllers/lua/can_filter.h +++ b/firmware/controllers/lua/can_filter.h @@ -4,6 +4,7 @@ #define FILTER_SPECIFIC 0x1FFFFFFF #define ANY_BUS -1 +#define NO_CALLBACK -1 struct CanFilter { int32_t Id; diff --git a/firmware/controllers/lua/lua_can_rx.cpp b/firmware/controllers/lua/lua_can_rx.cpp index 1978e7313f..22dd35e1ac 100644 --- a/firmware/controllers/lua/lua_can_rx.cpp +++ b/firmware/controllers/lua/lua_can_rx.cpp @@ -57,7 +57,7 @@ void processLuaCan(const size_t busIndex, const CANRxFrame& frame) { } static void handleCanFrame(LuaHandle& ls, CanFrameData* data) { - if (data->Callback == -1) { + if (data->Callback == NO_CALLBACK) { // No callback, use catch-all function lua_getglobal(ls, "onCanRx"); } else { diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index 2f63cefdfe..d11d5946ab 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -467,7 +467,7 @@ int lua_canRxAdd(lua_State* l) { // defaults if not passed int bus = ANY_BUS; - int callback = -1; + int callback = NO_CALLBACK; switch (lua_gettop(l)) { case 1: @@ -511,7 +511,7 @@ int lua_canRxAddMask(lua_State* l) { // defaults if not passed int bus = ANY_BUS; - int callback = -1; + int callback = NO_CALLBACK; switch (lua_gettop(l)) { case 2: