Conversation
Fixed to use %zu which corresponds to size_t. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Use a formatter to standardize indentation. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
17742a3 to
c65709c
Compare
There was a problem hiding this comment.
Pull request overview
This PR performs a code formatting cleanup across the Arduino-on-Zephyr core files, standardizing brace style, indentation (switching from 2-space to tab indentation in many files), and related cosmetic changes. It also introduces a correctness fix for printf format specifiers and new support for configurations where digital_pin_gpios is empty.
Changes:
- Format specifier fix in
hello_arduinosample (%zd→%zuforsize_t) - Brace style and indentation reformatting across all core
.cppand.hfiles (opening braces on same line, tabs instead of 2-space indent) - New
#if DT_PROP_LEN > 0guards and fallback values (port_num = 1,max_ngpios = 0) to support configurations withoutdigital_pin_gpiosin the device tree, plus a new helper macroDIGITAL_PIN_GPIOS_FIND_NODE
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
samples/hello_arduino/src/app.cpp |
Fixes %zd → %zu for size_t format specifiers |
cores/arduino/zephyrSerial.h |
Reformats brace style and indentation |
cores/arduino/zephyrSerial.cpp |
Reformats brace style, indentation, and multi-line macros |
cores/arduino/zephyrPrint.h |
Reformats brace style and indentation |
cores/arduino/zephyrPrint.cpp |
Reformats brace style, indentation, and minor whitespace fix |
cores/arduino/zephyrCommon.cpp |
Reformats indentation; adds #if DT_PROP_LEN > 0 guard with max_ngpios=0/port_num=1 fallback |
cores/arduino/main.cpp |
Reformats indentation and adds braces to if body |
cores/arduino/apiCommon.cpp |
Reformats indentation of extern "C" declarations |
cores/arduino/Arduino.h |
Refactors DIGITAL_PIN_EXISTS into two macros, adds #if DT_PROP_LEN > 0 guard for enum, adds DIGITAL_PIN_GPIOS_FIND_NODE helper macro |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #else | ||
|
|
||
| const int port_num = 1; | ||
| const int max_ngpios = 0; |
There was a problem hiding this comment.
When digital_pin_gpios has zero entries, the new #else branch sets max_ngpios = 0, which causes struct gpio_port_callback to have a zero-length member array struct arduino_callback handlers[0]. Zero-length arrays are not valid standard C++ (they are a GCC extension). While this works in GCC-based Zephyr builds, it may generate warnings or cause issues with strict-compliance builds. Consider guarding the struct and its related functions with #if DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios) > 0 as well, or use a minimum size of 1 for max_ngpios in the fallback case.
| const int max_ngpios = 0; | |
| const int max_ngpios = 1; |
Fix minor typo in comments. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Added a condition that the length of digital_pin_gpios is 0 or more. ------------------------------------------------------------------- Pick: arduino@d20ef628 Co-Authored-by: Martino Facchin <m.facchin@arduino.cc> Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
…sues The DIGITAL_PIN_EXISTS macro (used e.g. by LED_BUILTIN) was not working properly because the inline comments in devicetree_generated.h were confusing the preprocessor: one internal macro tried to create an unsigned constant by pasting a '*/' comment end marker with the 'U' character. Splitting that macro into two parts, so that the DT_REG_ADDR macro is invoked with an expanded argument, fixes the issue. ------------------------------------------------------------------- Pick: arduino@84651c2c Signed-off-by: Luca Burelli <l.burelli@arduino.cc> Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add `DIGITAL_PIN_GPIOS_FIND_NODE` helper macro. ------------------------------------------------------------------- Pick: arduino@a60cd82a Co-Authored-by: Sebastian Romero <s.romero@arduino.cc> Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Silence a number of trivial compiler warnings in the Arduino core: - unused arguments - "constexpr const" ------------------------------------------------------------------ Pick: arduino@67251fb Signed-off-by: Luca Burelli <l.burelli@arduino.cc> Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
No description provided.