Skip to content

Commit 1b34218

Browse files
committed
fixup??? dir.c: make add_excludes aware of fscache during status
This is needed to suppress a new `-Wunreachable-code` report by clang. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 5cb3d2a commit 1b34218

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

dir.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,8 +1136,13 @@ static int add_patterns(const char *fname, const char *base, int baselen,
11361136
* on the file and defeats the purpose of the optimization here. Since
11371137
* symlinks are even more rare than .gitignore files, we force a fstat()
11381138
* after our open() to get stat-data for the target file.
1139+
*
1140+
* Since `clang`'s `-Wunreachable-code` mode is clever, it would figure
1141+
* out that on non-Windows platforms, this `lstat()` is unreachable.
1142+
* We do want to keep the conditional block for the sake of Windows,
1143+
* though, so let's use the `NOT_CONSTANT()` trick to suppress that error.
11391144
*/
1140-
if (is_fscache_enabled(fname)) {
1145+
if (NOT_CONSTANT(is_fscache_enabled(fname))) {
11411146
if (lstat(fname, &st) < 0) {
11421147
fd = -1;
11431148
} else {

0 commit comments

Comments
 (0)