Skip to content

Commit 7dffc10

Browse files
authored
ClangFormat: Use latest version (#159)
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`.
1 parent 29e3bcb commit 7dffc10

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.github/workflows/cmake.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ jobs:
1616
- name: Checkout
1717
uses: actions/checkout@v4
1818
- name: Format code
19-
# 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.
20-
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
19+
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
2120
- name: Check diff
2221
run: git diff --exit-code
2322

src/nfd_portal.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,7 @@ void AppendSaveFileQueryDictEntryFilters(DBusMessageIter& sub_iter,
495495
if (defaultName) {
496496
const nfdnchar_t* p = defaultName;
497497
while (*p) ++p;
498-
while (*--p != '.')
499-
;
498+
while (*--p != '.');
500499
++p;
501500
if (*p) extn = p;
502501
}
@@ -1106,8 +1105,7 @@ bool TryGetValidExtension(const char* extn,
11061105
++extn;
11071106
if (*extn != '.') return false;
11081107
trimmed_extn = extn;
1109-
for (++extn; *extn != '\0'; ++extn)
1110-
;
1108+
for (++extn; *extn != '\0'; ++extn);
11111109
++extn;
11121110
trimmed_extn_end = extn;
11131111
return true;

test/test_sdl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ void show_paths(const nfdpathset_t* paths, SDL_Window* window) {
4545
NFD_PathSet_FreePathU8(path);
4646
}
4747

48+
// We should never return NFD_OKAY with zero paths, but GCC doesn't know this and will emit a
49+
// warning that we're trying to malloc with size zero if we write the following line.
50+
if (!num_paths) num_chars = 1;
51+
4852
char* message = malloc(num_chars);
4953
message[0] = '\0';
5054

0 commit comments

Comments
 (0)