Skip to content

Commit 6984b9a

Browse files
committed
Remove unnecessary NVRAM overflow checks, it's not that low-level
1 parent 3f62102 commit 6984b9a

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

tests/test_api.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,6 @@ async def test_znp_nvram_writes(znp, event_loop):
618618

619619
znp._uart.send.reset_mock()
620620

621-
# Writing too big of a value should fail
622-
with pytest.raises(ValueError):
623-
await znp.nvram_write(nvids.NwkNvIds.STARTUP_OPTION, t.uint16_t(0xAABB))
624-
625621
# The SYS_OSAL_NV_WRITE response status should be checked
626622
event_loop.call_soon(
627623
znp.frame_received,

zigpy_znp/api.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -347,23 +347,6 @@ async def nvram_write(
347347
if not isinstance(value, bytes):
348348
value = value.serialize()
349349

350-
# Find the next NVID in the table to check that our write doesn't overflow
351-
# It's not foolproof, but it will catch simple mistakes
352-
all_enum_values = list(type(nv_id))
353-
all_enum_values.sort(key=lambda i: i.value)
354-
index = all_enum_values.index(nv_id)
355-
356-
if index == len(all_enum_values) - 1:
357-
LOGGER.warning(
358-
"NVID is at end of table, cannot check for overflow"
359-
) # pragma: no cover
360-
else:
361-
next_nvid = all_enum_values[index + 1]
362-
end_address = nv_id + offset + len(value)
363-
364-
if end_address > next_nvid:
365-
raise ValueError("OSALNVWrite request overflows into %s", next_nvid)
366-
367350
return await self.request(
368351
SysCommands.OSALNVWrite.Req(
369352
Id=nv_id, Offset=offset, Value=t.ShortBytes(value)

0 commit comments

Comments
 (0)