Skip to content

Commit

Permalink
ClangFormat: Use latest version (#159)
Browse files Browse the repository at this point in the history
ClangFormat 13 is no longer available on GitHub Actions, so we switch to the newest one, which seems to be ClangFormat 16.

We also fix an over-eager GCC warning in `test_sdl.c`.
  • Loading branch information
btzy authored Mar 2, 2025
1 parent 29e3bcb commit 7dffc10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Format code
# ClangFormat 14 has a bug, which seems to be fixed in ClangFormat 15. Until GitHub-hosted runners support ClangFormat 15, we will stay at ClangFormat 13.
run: find src/ test/ -iname '*.c' -or -iname '*.cpp' -or -iname '*.m' -or -iname '*.mm' -or -iname '*.h' -or -iname '*.hpp' | xargs clang-format-13 -i -style=file
run: find src/ test/ -iname '*.c' -or -iname '*.cpp' -or -iname '*.m' -or -iname '*.mm' -or -iname '*.h' -or -iname '*.hpp' | xargs clang-format -i -style=file
- name: Check diff
run: git diff --exit-code

Expand Down
6 changes: 2 additions & 4 deletions src/nfd_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,7 @@ void AppendSaveFileQueryDictEntryFilters(DBusMessageIter& sub_iter,
if (defaultName) {
const nfdnchar_t* p = defaultName;
while (*p) ++p;
while (*--p != '.')
;
while (*--p != '.');
++p;
if (*p) extn = p;
}
Expand Down Expand Up @@ -1106,8 +1105,7 @@ bool TryGetValidExtension(const char* extn,
++extn;
if (*extn != '.') return false;
trimmed_extn = extn;
for (++extn; *extn != '\0'; ++extn)
;
for (++extn; *extn != '\0'; ++extn);
++extn;
trimmed_extn_end = extn;
return true;
Expand Down
4 changes: 4 additions & 0 deletions test/test_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ void show_paths(const nfdpathset_t* paths, SDL_Window* window) {
NFD_PathSet_FreePathU8(path);
}

// We should never return NFD_OKAY with zero paths, but GCC doesn't know this and will emit a
// warning that we're trying to malloc with size zero if we write the following line.
if (!num_paths) num_chars = 1;

char* message = malloc(num_chars);
message[0] = '\0';

Expand Down

0 comments on commit 7dffc10

Please sign in to comment.