Skip to content

Commit

Permalink
Add the InsertBraces command for clang-format to ensure that all cond…
Browse files Browse the repository at this point in the history
…itionals always have braces (coturn#1408)

- Why? Because code where conditionals lack braces is much harder to read, and prone to indentation confusion.
- How? Just added an extra flag to .clang-format and re-ran clang-format on all the files.

I also moved .clang-format up to the top level of the repo so that it can be applied to the fuzz targets as well.
  • Loading branch information
jonesmz authored Jan 28, 2024
1 parent 1683054 commit da332ed
Show file tree
Hide file tree
Showing 45 changed files with 2,701 additions and 1,517 deletions.
3 changes: 2 additions & 1 deletion src/.clang-format → .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Expand Down Expand Up @@ -133,5 +133,6 @@ StatementMacros:
TabWidth: 8
UseCRLF: false
UseTab: Never
InsertBraces: true
...

14 changes: 10 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ jobs:
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
sudo apt update
sudo apt install -y clang-format-15
sudo apt install -y \
libevent-dev \
libssl-dev \
libpq-dev libmariadb-dev libsqlite3-dev \
libhiredis-dev \
libmongoc-dev \
libmicrohttpd-dev \
clang-format
- uses: actions/checkout@v4
- name: configure
run: ./configure
- name: lint
run: clang-format --version && make lint
run: |
if which clang-format-15 2>&1 >/dev/null
then
sudo cp $(which clang-format-15) $(which clang-format)
fi
clang-format --version
make lint
3 changes: 1 addition & 2 deletions fuzzing/FuzzStun.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ extern int LLVMFuzzerTestOneInput(const uint8_t *Data,
uint8_t realm[33];
uint8_t upwd[33];
strcpy((char *)upwd, "VOkJxbRl1RmTxUk/WvJxBt");
stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, (uint8_t *)Data,
Size, uname, realm, upwd, shatype);
stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, (uint8_t *)Data, Size, uname, realm, upwd, shatype);
return 0;
}
Loading

0 comments on commit da332ed

Please sign in to comment.