Skip to content

Formatting pass with current clang-format - #68

Draft
aacuevas wants to merge 1 commit into
mainfrom
issue-67
Draft

aacuevas wants to merge 1 commit into
mainfrom
issue-67

Conversation

@aacuevas

Copy link
Copy Markdown
Collaborator

This PR is intended to be a review of the current .clang-format settings, to check that it is what we want or needs tweaking.
We should look at the files, maybe not only at the diff but also whole, and check if there is anything in the format we would like to change.

This might be an iterative process, so we can do multiple passes of this here and then squash the commits into a single formatting pass one.

@aacuevas
aacuevas requested a review from jonnew September 22, 2026 19:09
@aacuevas

Copy link
Copy Markdown
Collaborator Author

I will start with one setting that I believe should be changed: When breaking lines, operators should be at the end of the line, and not the start of the next one, as it are now. IMO, this gives a clear indication that "this line has not ended yet, it continues".

Some examples where the current setting that feel jarring to me:

liboni/api/liboni/oni.c

Lines 1134 to 1137 in 69910a2

ctx->block_read_size
= (ctx->max_read_frame_size + align - 1) & ~(align - 1);
ctx->block_write_size
= (ctx->max_write_frame_size + align - 1) & ~(align - 1);

srcPtr = ctx->inBuffer + ctx->inBlockSize * (size_t)lastIndex
+ ctx->lastReadOffset;

srcPtr
= ctx->inBuffer + ctx->inBlockSize * (size_t)ctx->nextReadIndex;

(this last one, with only the lvalue in the line, stands specially out)

I would consider increasing the maximum column width from 80 to 100. While 80 has been the standard since the 90's, many projects seems to be increasing the limit nowadays. 100 seems to be the sweet spot to look nice on widescreens without having lines too long. Alternatively, or in addition, we should play a bit with the penalties.

Besides that, the format seems nice to me. We could maybe discuss if opening brackets should be in a new line for some more kinds of statement, or is it good as it is.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant