Skip to content

style: coding convention #98

Description

@AndreCostaaa

I would like to have a way to auto format the code when developing so3.

Looking at some exemples, it seems like the convention is kinda of laxed. Take a look at devices/elf.c for instance.

For instance, this function adds the opening brace after the function signature

so3/so3/fs/elf.c

Lines 35 to 37 in 3eff6a3

uint8_t*elf_load_buffer(constchar*filename)
{
intfd;

While other functions in the same file add the opening brace at the end of the function signature

so3/so3/fs/elf.c

Lines 69 to 70 in 3eff6a3

voidelf_clean_image(elf_img_info_t*elf_img_info) {
inti;

It's not just elf.c, it seems like a recurring thing happening all over the place
I've seen #79 (by @Karilla) and while I fully support the idea of adding a .clang-format file, the purposed one doesn't follow the exact coding convention of so3.

We can make it better but instead of starting from scratch, i would like to know. Has there ever been a tool to auto format so3 or has it always been done by hand ? @daniel-rossier

So here's where I would like to get to with this issue:

  • Generate a .clang-format file that best fits the current coding convention style.

  • Optionally we could add a ci job to make sure the convention is followed.

  • This would be a great way to provide meaningful feedback to the developer and to stop wasting time with code reviews that don't follow the code convention

Ideally we can get a .clang-format that follows the exact convention used but I don't think that's possible and as such, a decision needs to be made on what to do afterwards:

  1. Generate one big commit with the style changes for every file
  2. Format files when changes are (eventually) done to it

For reference these are the .clang-format files used by zephyr and linux

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions