Skip to content

Conversation

teburd
Copy link
Contributor

@teburd teburd commented Jul 28, 2025

If we stick with clang-format we don't need to nitpick over little spacing issues for new contributions, we can simply ask people to run the formatting tool. Much simpler.

Noticed these files weren't formatted with the tool in #83423 and the result is nits over spacing which are not the kind of review comments I want to see, use the tool to ensure spacing/formatting nits are unnecessary.

@zephyrbot zephyrbot added the area: llext Linkable Loadable Extensions label Jul 28, 2025
@zephyrbot zephyrbot requested review from lyakh and pillo79 July 28, 2025 12:09
@teburd teburd added the Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc. label Jul 28, 2025
@teburd teburd requested a review from laurenmurphyx64 July 28, 2025 12:10
shdr->sh_info,
&rel);
uintptr_t op_loc =
llext_get_reloc_instruction_location(ldr, ext, shdr->sh_info, &rel);
Copy link
Contributor

Choose a reason for hiding this comment

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

on the one hand automation is good, and having rules helps avoid mostly needless discussions... OTOH... do most of us find this a good change? There was another similar split of x = a - b in lines 330-331 in the same file above...

Copy link
Contributor Author

@teburd teburd Jul 30, 2025

Choose a reason for hiding this comment

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

So we can get the formatter to adjust where the line break occurs with some options, I think given this style we want to penalize breaking no the assignment and after the first break.

We have the formatter undoing stuff like this else where

size_t top_ofs = MAX(region->sh_offset + region->sh_size,
shdr->sh_offset + shdr->sh_size);
size_t top_ofs =
MAX(region->sh_offset + region->sh_size, shdr->sh_offset + shdr->sh_size);
Copy link
Contributor

Choose a reason for hiding this comment

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

...and another one

exp_tab->sym_cnt = ldr->sects[LLEXT_MEM_EXPORT].sh_size
/ sizeof(struct llext_symbol);
exp_tab->sym_cnt =
ldr->sects[LLEXT_MEM_EXPORT].sh_size / sizeof(struct llext_symbol);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe there's a parameter to tell it to not split lines after an assignment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The project has a clang format config file, I’ll see if there’s an option for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a fix for this awhile ago, need to see which option adjusts it https://reviews.llvm.org/D32477

Copy link
Contributor

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

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

clang-format is a great tool to enforce a minimum standard and most of the changes here are great, but personally I'm against requiring absolute compliance: I have highlighted several places where word wraps were chosen to maximize immediate pattern recognition; with the "cleanup" these are now more difficult to spot.

So soft -1 (to the rule), but ofc I’m willing to go with whatever is ultimately decided.

Comment on lines +485 to +486
LOG_DBG("relocation section %s (%d) acting on section %d has %zd relocations", name,
i, shdr->sh_info, (size_t)rel_cnt);
Copy link
Contributor

Choose a reason for hiding this comment

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

printf lines with only the format on the first line, arguments on next ones

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me see if there's a clang-format option for this as well

Comment on lines +196 to 197
if (!ldr->sects[LLEXT_MEM_SHSTRTAB].sh_type || !ldr->sects[LLEXT_MEM_STRTAB].sh_type ||
!ldr->sects[LLEXT_MEM_SYMTAB].sh_type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

less readable comparison

Comment on lines +428 to +429
if (x->sh_type == SHT_NULL || x->sh_size == 0 || y->sh_type == SHT_NULL ||
y->sh_size == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

again, optimized but less readable

Comment on lines +35 to +36
SHELL_HELP("Load an elf file directly from filesystem.", "<ext_name> " \
"<ext_llext_file_name>")
Copy link
Contributor

Choose a reason for hiding this comment

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

split a string in the middle... resulting in a longer line

Comment on lines +478 to +479
i, REGION_BOT(x, sh_offset), REGION_TOP(x, sh_offset), j,
REGION_BOT(y, sh_offset), REGION_TOP(y, sh_offset));
Copy link
Contributor

Choose a reason for hiding this comment

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

logical ordering now gone

@teburd
Copy link
Contributor Author

teburd commented Jul 30, 2025

Ultimately most of the format changes here are quite nice to me. It's a thoughtless excercise to run clang-format and avoids formatting nits which I really never like seeing (I want to see quality structural review comments).

But if the tool can't be made with its many options to get us like 95% success with a few whiffs (the tool can always be disabled for small sections like logically aligned printfs) then its just not good enough still which is disappointing. I'll tinker with the rules a bit more today to try and address the comments from @pillo79 and @lyakh (I appreciate you two looking this over!).

teburd added 2 commits July 30, 2025 09:25
These options tell clang-format penalize the formatter for trying to
break a long line up on particular elements like assignment, opening
brackets, and such. Adjusting these means long lines are broken at more
natural places that match existing code.

Signed-off-by: Tom Burdick <[email protected]>
If we stick with clang-format we don't need to nitpick over little
spacing issues for new contributions, we can simply ask people to run
the formatting tool. Much simpler.

Signed-off-by: Tom Burdick <[email protected]>
@teburd teburd force-pushed the llext_clang_format branch from 7ea5a19 to 5eb8787 Compare July 30, 2025 14:27
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Coding Guidelines Coding guidelines and style area: llext Linkable Loadable Extensions Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants