Skip to content

tools/nxstyle: Whitelist ROS 2 message type identifiers.#19001

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
arjav1528:tools-nxstyle-microros-whitelist
May 31, 2026
Merged

tools/nxstyle: Whitelist ROS 2 message type identifiers.#19001
xiaoxiang781216 merged 1 commit into
apache:masterfrom
arjav1528:tools-nxstyle-microros-whitelist

Conversation

@arjav1528
Copy link
Copy Markdown
Contributor

Summary

The ROS 2 C client API exposes message types through rosidl token-pasting macros. Each message type ends up with a generated symbol of the form <pkg>__msg__<Type> (e.g. std_msgs__msg__Int32), and the bare type token (Int32, Float64, ...) appears in user code as an argument to ROSIDL_GET_MSG_TYPE_SUPPORT(). Neither form can be renamed without breaking the public API.

Add the ROS 2 standard message package prefixes and the rosidl scalar type names to g_white_prefix so nxstyle does not flag the resulting mixed-case identifiers in apps that consume micro-ROS via apps/system/microros.

Whitelisted prefixes:

  • Packages: std_msgs, geometry_msgs, sensor_msgs, nav_msgs, builtin_interfaces, rcl_interfaces.
  • Scalars: Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64.

Follows the existing precedent for external ecosystems in the same list (cJSON, NativeSymbol, Ifx, lua_, TEEC_, ...).

Impact

  • tools/nxstyle only. No build, runtime, or hardware effect.
  • Pure relaxation of the style checker for a fixed, enumerated setof identifiers. No existing in-tree code becomes invalid; only previously-flagged ROS 2 token-pasted identifiers stop being flagged.

Dependencies

Companion to apache/nuttx-apps#3512 (system/microros: Add UDP and serial custom transports with publisher example). That PR's CI nxstyle step fails on apps/examples/microros_pub/microros_pub_main.c until this lands.

Testing

Local build of the patched tools/nxstyle and run against every C/H file touched by apache/nuttx-apps#3512:

$ gcc -O2 -o tools/nxstyle tools/nxstyle.c
$ for f in <8 touched .c/.h paths>; do ./tools/nxstyle "$f"; done
(no output -> all clean)

Before this patch (same nxstyle build minus the whitelist additions):

apps/examples/microros_pub/microros_pub_main.c:45:7: error: Mixed case identifier found
apps/examples/microros_pub/microros_pub_main.c:84:51: error: Mixed case identifier found

After: 0 errors, 0 warnings on the same 8 files.

No other in-tree files reference any of the added prefixes, so the
whitelist relaxation is scoped to the new ROS 2 surface.

The ROS 2 C client API generates symbols via rosidl token-pasting
macros. Each message type ends up with a name of the form
<pkg>__msg__<Type>, and the bare type token (Int32, Float64, ...)
appears in user code as an argument to ROSIDL_GET_MSG_TYPE_SUPPORT().
Neither form can be renamed without breaking the public API.

Add the ROS 2 standard message package prefixes (std_msgs,
geometry_msgs, sensor_msgs, nav_msgs, builtin_interfaces,
rcl_interfaces) and the rosidl scalar type names (Int8/16/32/64,
UInt8/16/32/64, Float32/64) to g_white_prefix so nxstyle does not
flag the resulting mixed-case identifiers in apps that consume
micro-ROS via apps/system/microros.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
@github-actions github-actions Bot added Area: Tooling Size: S The size of the change in this PR is small labels May 30, 2026
@linguini1
Copy link
Copy Markdown
Contributor

Should we allow modifying nxstyle for third party libraries?

@xiaoxiang781216 xiaoxiang781216 merged commit bc3a259 into apache:master May 31, 2026
41 checks passed
@acassis
Copy link
Copy Markdown
Contributor

acassis commented May 31, 2026

Should we allow modifying nxstyle for third party libraries?

Normally we don't it, because it makes the update to a new library version more difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Tooling Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants