Skip to content

Commit 5265663

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 e081895 commit 5265663

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
@@ -1150,8 +1150,13 @@ static int add_patterns(const char *fname, const char *base, int baselen,
11501150
* on the file and defeats the purpose of the optimization here. Since
11511151
* symlinks are even more rare than .gitignore files, we force a fstat()
11521152
* after our open() to get stat-data for the target file.
1153+
*
1154+
* Since `clang`'s `-Wunreachable-code` mode is clever, it would figure
1155+
* out that on non-Windows platforms, this `lstat()` is unreachable.
1156+
* We do want to keep the conditional block for the sake of Windows,
1157+
* though, so let's use the `NOT_CONSTANT()` trick to suppress that error.
11531158
*/
1154-
if (is_fscache_enabled(fname)) {
1159+
if (NOT_CONSTANT(is_fscache_enabled(fname))) {
11551160
if (lstat(fname, &st) < 0) {
11561161
fd = -1;
11571162
} else {

0 commit comments

Comments
 (0)