Skip to content

Commit 5675312

Browse files
committed
Fix a gcc 11 warning in src/thread.h
When building under gcc 11, there is a warning about an incompatible pointer type, since [`__atomic_exchange`](https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html) does not take `volatile` pointers: ``` In file included from ../src/common.h:81, from ../src/transports/winhttp.c:8: ../src/thread-utils.h: In function ‘git___swap’: ../src/thread-utils.h:168:9: warning: argument 3 of ‘__atomic_exchange’ discards ‘volatile’ qualifier [-Wincompatible-pointer-types] 168 | __atomic_exchange(ptr, &newval, &foundval, __ATOMIC_SEQ_CST); | ^~~~~~~~~~~~~~~~~ ``` This change drops the `volatile` qualifier so that the pointer type matches what `__atomic_exchange` expects.
1 parent 043f312 commit 5675312

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ GIT_INLINE(volatile void *) git_atomic__swap(
180180
#if defined(GIT_WIN32)
181181
return InterlockedExchangePointer(ptr, newval);
182182
#elif defined(GIT_BUILTIN_ATOMIC)
183-
void * volatile foundval = NULL;
183+
void * foundval = NULL;
184184
__atomic_exchange(ptr, &newval, &foundval, __ATOMIC_SEQ_CST);
185185
return foundval;
186186
#elif defined(GIT_BUILTIN_SYNC)

0 commit comments

Comments
 (0)