[PATCH 1/1] .clang-format: add U-Boot specific for each macros
Simon Glass
sjg at chromium.org
Tue Apr 28 16:04:26 CEST 2026
Hi Heinrich,
On 2026-04-24T12:55:14, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
> .clang-format: add U-Boot specific for each macros
>
> Formatting via clang-format is controlled by .clang-format.
> For each statements should be formatted with a brace at the line end:
>
> for_for_each() {
> }
>
> This requires clang-format to know that the symbol is not a function
> but a for each macro. We use some for each macros which don't exist in
> Linux. Add these to file .clang-format.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
>
> .clang-format | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
Reviewed-by: Simon Glass <sjg at chromium.org>
See below
> diff --git a/.clang-format b/.clang-format
> @@ -748,6 +748,19 @@ ForEachMacros:
> + # U-Boot specific
> + - 'alist_for_each'
> + - 'alist_for_each_filter'
> + - 'for_each_bl_params_node'
> + - 'ofnode_for_each_prop'
> + - 'ofnode_for_each_subnode'
> + - 'ofnode_for_each_compatible_node'
> + - 'dev_for_each_subnode'
> + - 'dev_for_each_property'
> + - 'fdt_for_each_node_by_compatible'
> + - 'for_each_console_dev'
> + - 'mtd_for_each_device'
> + - 'for_each_tpm_device'
Please can you sort these alphabetically? The comment at line 67
documents that the upstream list is generated with 'LC_ALL=C sort -u',
so following the same convention keeps the file easy to update and
scan.
Also, the list is missing quite a few U-Boot specific macros. Running
the same recipe against U-Boot's tree turns up at least:
_for_each_zynqmp_part
for_each_bin_hdr_v0
for_each_ext_hdr_v0
for_each_opt_hdr_v1
for_each_zynqmp_image
for_each_zynqmp_part
for_each_zynqmp_part_in_image
…plus several more under drivers/ - e.g. for_each_w1_device,
for_each_slave, for_each_supported_width...
The recipe at the top of the section already says 'include/ tools/',
so could you widen it to the whole tree and regenerate, or at least
extend the comment to document how the U-Boot list was produced? What
do you think?
Regards,
Simon
More information about the U-Boot
mailing list