Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .clang_format #1542

Open
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@Wunkolo
Copy link
Contributor

commented Mar 19, 2019

This is to automate the styling of C code to aid contributors in making pull requests that conform to the existing style and so any future C style decisions can be made to a single file and automatically applied to the whole project.
I configured the .clang_format to suite most of the code found through-out the already-existing C code and based on the code review of my previous PRs.
More options can be found here
With this any edits to the c code can be automatically formatted by calling clang-format or find . -regex '.*\.\(c\|h\)' -exec clang-format -style=file -i {} \;

@CounterPillow
Copy link
Member

left a comment

Overall these changes look like a great step forward in terms of Overviewer's overall code quality by making it easier to keep the code readable no matter the number of hands that touch it. I've left two comments requesting some clarifications on some things that stood out to me.

Feel free to tune in as well, @agrif.

Show resolved Hide resolved overviewer_core/src/composite.c Outdated
Priority: 1
IndentCaseLabels: false
MaxEmptyLinesToKeep: '1'
PointerAlignment: Left

This comment has been minimized.

Copy link
@CounterPillow

CounterPillow Mar 20, 2019

Member

A lot of code in Overviewer appears to use right-aligned pointers. My C knowledge isn't the best, but I think

int *foo, bar;

makes foo an int pointer and bar an int, whereas

int* foo, bar;

makes both of them int pointers, correct?

In that case, wouldn't right-aligned pointers be the lesser trap?

Feel free to change my opinion on this, I'm mostly just noticing a lot of foo *bar to foo* bar transformations in this PR which have me a little worried over whether this was 100% intentional.

This comment has been minimized.

Copy link
@agrif

agrif Mar 20, 2019

Member

Nope, both of those declare foo as a pointer and bar as an int. Yeah, it's pretty bad.

I used to use right-pointers because morally, I think pointerness should be part of the type. But C's syntax is such that right-pointers will get you in to trouble, like the confusion above, so nowadays I try to stick to left-pointers. I think that's a good choice for overviewer.

This comment has been minimized.

Copy link
@agrif

agrif Mar 20, 2019

Member

So: I think I swapped left and right here... 😄

I meant, the int *foo style is probably more appropriate. I don't know enough about .clang-format to know if that's what's selected here.

This comment has been minimized.

Copy link
@Wunkolo

Wunkolo Mar 20, 2019

Author Contributor

I'm gonna be a vote for left-pointers as defining a mix of ints and int-pointers on the same line is kind of a weird basis for having it all be on the right through-out the codebase. Would rather keep all type and type modifiers next to the type, with the name on its own(static volatile void* pointy).

@CounterPillow CounterPillow requested review from CounterPillow and removed request for CounterPillow Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.