Skip to content

Cleanup common#26

Open
soburi wants to merge 7 commits intonextfrom
cleanup_common
Open

Cleanup common#26
soburi wants to merge 7 commits intonextfrom
cleanup_common

Conversation

@soburi
Copy link
Copy Markdown
Owner

@soburi soburi commented Mar 1, 2026

No description provided.

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>
Copilot AI review requested due to automatic review settings March 1, 2026 01:02
@soburi soburi force-pushed the cleanup_common branch 4 times, most recently from 17742a3 to c65709c Compare March 1, 2026 01:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_arduino sample (%zd%zu for size_t)
  • Brace style and indentation reformatting across all core .cpp and .h files (opening braces on same line, tabs instead of 2-space indent)
  • New #if DT_PROP_LEN > 0 guards and fallback values (port_num = 1, max_ngpios = 0) to support configurations without digital_pin_gpios in the device tree, plus a new helper macro DIGITAL_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;
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
const int max_ngpios = 0;
const int max_ngpios = 1;

Copilot uses AI. Check for mistakes.
soburi and others added 5 commits March 1, 2026 16:22
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants