commit | ffab718375f979cb05fd11caf16af84eb8882c23 | [log] [tgz] |
---|---|---|
author | Wyatt Hepler <hepler@google.com> | Wed May 08 17:50:31 2024 +0000 |
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed May 08 17:50:31 2024 +0000 |
tree | 2ca8c88962d5927627bcc74b2cf8a73bd54c7961 | |
parent | a3d96bad3957c08cc304ef79b86de58e7d7aa585 [diff] |
pw_assert: Ensure condition does not contain stray % Use printf-style format checking on the condition to ensure it doesn't contain any printf-style specifiers. Asserting on a condition containing modulus (%) should not Some backends include the condition in a format string, so it should not introduce additional arguments. Including the condition with the format string is an important code size optimization for tokenized backends. Backends are currently inconsistent about allowing % in conditions or not. For consistency, prevent % in conditions in the pw_assert facade. This is done by calling an empty printf-annotated function with the condition. A carefully placed comment describing the error is included in the compiler's error output. When pw_assert is refactored (https://pwbug.dev/235149326), this restriction will no longer be necessary. Bug: b/337268540 Change-Id: I2327df7470a5fe213497ede9167293adcf352a75 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/208140 Reviewed-by: Eric Rahm <erahm@google.com> Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com> Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.
For more information please see our website: https://pigweed.dev/.