fix(core): correct `ticks_diff` arguments' order
What changed, and why it matters
This commit fixes the order of arguments in a mock type stub for a timing function. It only changes a Python interface declaration used for testing/type-checking, not the actual device firmware code. The real security risk is minimal, but if the stub had misled developers, it could theoretically contribute to subtle timing bugs in firmware.
No immediate action required. Treat as a minor code-quality fix. If using `ticks_diff` in firmware code, verify call sites already pass `(new, old)` as per MicroPython convention, but this commit itself does not indicate a live vulnerability.
Security signals we found
Argument-order correction in a timing helper stub
Potential for developer confusion around signed tick differences
No change to actual firmware implementation or runtime logic
Evidence from the diff
The change is in core/mocks/utime.pyi, a MicroPython stub file. It swaps the parameter names of ticks_diff(old, new) to ticks_diff(new, old) to match MicroPython’s actual API convention (ticks_diff(new, old) returns positive when new is after old). This is a type/mock correction; the compiled firmware implementation is not touched. Any downstream code relying on the stub for static analysis or IDE hints is now aligned with runtime behavior.
Changed components
core/mocks/utime.pyiInspect captured patch +1 / −1
diff --git a/core/mocks/utime.pyi b/core/mocks/utime.pyi
index c2ff9bb82..3bbcae688 100644
--- a/core/mocks/utime.pyi
+++ b/core/mocks/utime.pyi
@@ -5,5 +5,5 @@ def ticks_ms() -> int: ...
def ticks_us() -> int: ...
def ticks_cpu() -> int: ...
def ticks_add(ticks_in: int, delta_in: int) -> int: ...
-def ticks_diff(old: int, new: int) -> int: ...
+def ticks_diff(new: int, old: int) -> int: ...
def gmtime2000(timestamp: int) -> tuple: ...
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.