From fde529fac409ca9309ab1bf0c14cd1720598901e Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:46:16 +0100 Subject: [PATCH] Berry fix walrus operator (#22685) --- CHANGELOG.md | 1 + lib/libesp32/berry/src/be_code.c | 2 ++ .../src/embedded/zigbee_zcl_attribute.be | 14 +++++--------- .../src/solidify/solidified_zigbee_zcl_attribute.h | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccacfb9d1..393a881b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Berry Zigbee fix wrong attributes (#22684) +- Berry fix walrus operator ### Removed diff --git a/lib/libesp32/berry/src/be_code.c b/lib/libesp32/berry/src/be_code.c index 9f7cf1300..0c53ca658 100644 --- a/lib/libesp32/berry/src/be_code.c +++ b/lib/libesp32/berry/src/be_code.c @@ -716,6 +716,8 @@ int be_code_setvar(bfuncinfo *finfo, bexpdesc *e1, bexpdesc *e2, bbool keep_reg) free_expreg(finfo, e2); /* free source (checks only ETREG) */ *e2 = *e1; /* now e2 is e1 ETLOCAL */ } + } else { + *e2 = *e1; /* ETLOCAL wins over ETREG */ } break; case ETGLOBAL: /* store to grobal R(A) -> G(Bx) by global index */ diff --git a/lib/libesp32/berry_tasmota/src/embedded/zigbee_zcl_attribute.be b/lib/libesp32/berry_tasmota/src/embedded/zigbee_zcl_attribute.be index 993575733..f960f8e74 100644 --- a/lib/libesp32/berry_tasmota/src/embedded/zigbee_zcl_attribute.be +++ b/lib/libesp32/berry_tasmota/src/embedded/zigbee_zcl_attribute.be @@ -205,13 +205,11 @@ class zcl_attribute_list : zcl_attribute_list_ntv var v # shortaddr - v = self.shortaddr - if v != nil + if (v := self.shortaddr) != nil items.push(f'"Device":"0x{v:04X}"') end # groupaddr - v = self.groupaddr - if v != nil + if (v := self.groupaddr) != nil items.push(f'"Group":"0x{v:04X}"') end @@ -225,15 +223,13 @@ class zcl_attribute_list : zcl_attribute_list_ntv end # Endpoint - v = self.src_ep - if v != nil + if (v := self.src_ep) != nil items.push(f'"Endpoint":{v}') end # LQI - v := self.lqi - if v != nil - items.push(f'"LinkQuality":{v:i}') + if (v := self.lqi) != nil + items.push(f'"LinkQuality":{v}') end var s = "{" + items.concat(",") + "}" diff --git a/lib/libesp32/berry_tasmota/src/solidify/solidified_zigbee_zcl_attribute.h b/lib/libesp32/berry_tasmota/src/solidify/solidified_zigbee_zcl_attribute.h index 6fc655a43..841ad2c36 100644 --- a/lib/libesp32/berry_tasmota/src/solidify/solidified_zigbee_zcl_attribute.h +++ b/lib/libesp32/berry_tasmota/src/solidify/solidified_zigbee_zcl_attribute.h @@ -553,7 +553,7 @@ static const bvalue be_ktab_class_zcl_attribute_list[27] = { /* K19 */ be_nested_str_weak(tostring), /* K20 */ be_const_int(1), /* K21 */ be_nested_str_weak(_X22Endpoint_X22_X3A_X25s), - /* K22 */ be_nested_str_weak(_X22LinkQuality_X22_X3A_X25i), + /* K22 */ be_nested_str_weak(_X22LinkQuality_X22_X3A_X25s), /* K23 */ be_nested_str_weak(_X7B), /* K24 */ be_nested_str_weak(concat), /* K25 */ be_nested_str_weak(_X2C),