Commit Graph

27 Commits

Author SHA1 Message Date
Chris Friedt 5a0b1b1628 clang-format: add entry for SYS_SEM_LOCK()
SYS_SEM_LOCK() is a for-loop-like macro similar inspired by
K_SPINLOCK().

Add an entry to .clang-format so that autoformatting works as
expected.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-10-03 17:07:05 +01:00
Ryan McClelland e602590931 drivers: i3c: add iterate through i3c/i2c devices macros
Add i3c_bus_for_each_i3cdev and i3c_bus_for_each_i2cdev to more easily
iterate through each i3c or i2c device on the bus.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-09-25 04:04:13 -04:00
Pieter De Gendt 0d95e2e9e8 clang-format: add more whitespace sensitive macros
An issue with some macros is that a space is added to conditional
expansions. Prevent some of these macros to get formatted.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-09-23 18:09:53 -04:00
Mirko Covizzi b75c59115f clang-format: add SpaceBeforeInheritanceColon False
For clang-format to adhere to checkpatch, this flag needs to be set.

Signed-off-by: Mirko Covizzi <mirko.covizzi@nordicsemi.no>
2024-08-09 08:37:54 -04:00
Kristoffer Rist Skøien f36828b5d8 clang-format: IndentGotoLabels false
For clang-format to adhere to checkpatch, this flag needs to be set

Signed-off-by: Kristoffer Rist Skøien <kristoffer.skoien@nordicsemi.no>
2024-08-06 17:17:07 -04:00
Gerhard Jörges 1fe1c961f9 clang-format: add FOREACH macros
add missing FOREACH macros to stop clang-format from moving the opening
curly brace into a new line.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2024-08-02 22:09:22 -05:00
Chris Friedt aa2b83d4ab clang-format: add array-for-each to correct formatting issues
The ARRAY_FOR_EACH() and ARRAY_FOR_EACH_PTR() macros were not
formatting correctly in vs code (and I would guess other
editors).

Add an entry to .clang-format so that the opening brace is on
the same line as the macro.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-05-28 18:56:24 +02:00
Alberto Escolar Piedras c9faea2c2b Revert "clang-format: add entry for SYS_SEM_LOCK()"
This reverts commit 36bbd3057e.

This PR:
https://github.com/zephyrproject-rtos/zephyr/pull/71718
introduced a regression breaking CI:
https://github.com/zephyrproject-rtos/zephyr/issues/71814
Let's just revert it until a better fix is done.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-04-23 11:51:44 -04:00
Chris Friedt 36bbd3057e clang-format: add entry for SYS_SEM_LOCK()
SYS_SEM_LOCK() is a for-loop-like macro similar inspired by
K_SPINLOCK().

Add an entry to .clang-format so that autoformatting works as
expected.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-04-23 07:01:25 -04:00
Rodrigo Peixoto 2312897055 Build System: clang-format: add K_SPINLOCK to FOR_EACH
The K_SPINLOCK is been indented wrongly by clang-format. It fixes that
adding the K_SPINLOCK to the FOR_EACH section rule tells the formatter
to follow the rule to indent the code.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2023-12-26 19:36:01 +00:00
Yuval Peress 9c624fa9e6 clang-format: flag *_SECTION_FOREACH as for loop
Improve clang-format handling for iterable sections.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-26 11:04:54 -05:00
Emil Gydesen 6c91e4dab0 clang-format: UseTab use ForContinuationAndIndentation
Modify UseTab to use ForContinuationAndIndentation instead
of always. This will only use tabs for indentation, and then
spaces for alignment, which is the most commonly used approach
in Zephyr.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-05 11:06:54 -04:00
Carlo Caione de90dfccbc syscall: Introduce __syscall_always_inline
Sometimes we want to force the inlining of a __syscall. Introduce a new
__syscall_always_inline symbol to do that.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-04-20 14:56:09 -04:00
Emil Gydesen 8af066bb4f clang-format: Add CHECKIF to IfMacros
Add the CHECKIF macro to the IfMacros list so that
it gets formatted correctly

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-02-27 10:47:11 -08:00
Yuval Peress 0f40ddd957 tools: Fix clang-format values
According to the clang-format documentation some values in our
.clang-format are incorrect. See:

- https://clang.llvm.org/docs/ClangFormatStyleOptions.html#allowshortblocksonasingleline
- https://clang.llvm.org/docs/ClangFormatStyleOptions.html#sortincludes

Signed-off-by: Yuval Peress <peress@google.com>
2023-01-19 09:18:05 -08:00
Gerard Marull-Paretas 407041a10f clang-format: enable SpaceBeforeParens option
The option required clang-format >= 13, we now require >= 15, so it can
be enabled.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-12-22 15:51:01 +00:00
Keith Short 42f746c8d0 clang-format: Enable InsertBraces option
Zephyr's coding guidelines require braces on every code block body.
Enable InsertBraces option so clang-format automatically adds these
braces.

Signed-off-by: Keith Short <keithshort@google.com>
2022-12-20 22:51:57 +01:00
Rafael Lee e6ef1f3434 clang-format: remove space before colon
To fit the bitfield check in scripts/checkpatch.pl
from: uint8_t : 3;
to:   uint8_t: 3;

Signed-off-by: Rafael Lee <rafaellee.img@gmail.com>
2022-11-16 12:14:58 +00:00
Anas Nashif c417cbc050 clang-format: disable regrouping and sorting of includes
Disable regrouping and sorting of includes which can cause issues due to
order requirements in some subsystems.

Fixes #48520

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-16 11:17:02 +01:00
Johann Fischer dddb5dd6b0 clang-format: do not merge blocks/functions into single line
Align clang-format a bit closer to established coding style
of the project. Similar to commit 51f9f7ca30
("clang-format: do not put enums in single line")'

Never merge blocks/case/functions/if/loops into a single line.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-07-15 19:18:28 -04:00
Anas Nashif 51f9f7ca30 clang-format: do not put enums in single line
clang-format puts short enums in one single line, making them
unreadable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-01 12:01:05 -04:00
Henrik Brix Andersen 3f0e8dda3d clang-format: restore column limit value of 100
Restore line length limit of 100 characters as introduced in
6432a56ae9.

Fixes: bac0dbe8f2

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-06-27 17:18:04 -04:00
Gerard Marull-Paretas bac0dbe8f2 clang-format: simplify by inheriting from LLVM
The amount of options available on clang-format has become quite
extensive over-time, making a dumped file difficult to read or maintain.
In this patch the .clang-format has been re-written by inheriting from
LLVM (default) since most of the options can be re-used to match the
Zephyr/Linux coding style conventions.

Note: The 14 release has interesting options for Zephyr, in
particular, these new settings would be beneficial:

IfMacros:
  - CHECKIF
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
  AfterForeachMacros: true
  AfterIfMacros: true

.clang-format should be periodically updated as new clang-format
releases reach Linux distros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:37:30 -04:00
Gerard Marull-Paretas dbb5e2380d clang-format: update ForEachMacros
Update the list of for each macros using the suggested command in the
configuration file.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:37:30 -04:00
Piotr Pryga 6432a56ae9 clang-format: Change lines length limit from 80 to 100
Change line length limit from former 80 characters to current 100.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 08:13:32 -05:00
Peter Bigot 1ec9d2a9df clang-format: Update with latest FOR_EACH macro list
Correct the shell fragment to use the spelling Zephyr uses, and re-run
it to update the list.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-02 11:23:13 -04:00
Håkon Alseth a88dc36f60 clang-format: add support for clang-format
Add .clang-format style from linux kernel to allow easier
style formatting for developers that do not use uncrustify.
You can call "clang-format -style=file -i my_src.c" within the repo
to in-place fix the style.

Signed-off-by: Håkon Alseth <haal@nordicsemi.no>
2018-11-19 09:31:44 -05:00