Clang format config for Weston

Harish Krupo harish.krupo.kps at
Thu Mar 14 11:20:26 UTC 2019

Hi Pekka,

Pekka Paalanen <ppaalanen at> writes:

> On Thu, 14 Mar 2019 16:01:08 +0530
> Harish Krupo <harish.krupo.kps at> wrote:
>> Hi,
>> I have written a clang format file based on this example [1], to
>> match the coding style here [2]. Does the below config look okay or
>> should something be changed?
>> If people are interested, I can open a MR for this. This could also be
>> used in the CI to warn/abort if a patch isn't according to the coding
>> style.
>> The config:
>> BasedOnStyle: LLVM
>> IndentWidth: 8
>> TabWidth: 8
>> UseTab: Always
>> BreakBeforeBraces: Linux
>> AllowShortIfStatementsOnASingleLine: false
>> IndentCaseLabels: false
>> AlwaysBreakAfterReturnType: TopLevel
>> [1]
>> [2]
> Hi Harish,
> I guess that depends on how different that is from the existing code
> base style. Seeing the warning list generated for the existing code
> would tell a lot, I doubt it would be empty.

Okay, I see what you mean. Running clang format on
libweston/gl-renderer.c does generate a few false positives. Some of
them could be corrected by setting other config options.

> Is the LLVM style something guaranteed to not change?

I am not sure about this :(

> Using it in CI might be an attractive idea, but I wonder if it would
> result in many false warnings. Some aspects of coding style are always
> somewhat vague and need to adapt to the code at hand to look nice to a
> human rather than follow some rigorous rules. If it leaves such things
> as is and checks only those that should follow rigorous rules, that
> would be nice.

All the config options that Clang-format uses to format code is given in
[1]. It leaves the rest to the user. We would have to define all (at
least most) of those options for weston if we want to use this with the
CI. Consequence of doing this would make the BasedOnStyle: LLVM option

Thank you
Harish Krupo


More information about the wayland-devel mailing list