diff options
author | lhchavez <lhchavez@lhchavez.com> | 2021-11-14 02:27:10 -0800 |
---|---|---|
committer | lhchavez <lhchavez@lhchavez.com> | 2021-11-14 02:31:48 -0800 |
commit | 5675312e5aeb0c8b438df3ba9da7542673b2e0e7 (patch) | |
tree | e00c0a577787620a49649ecaf1a86c07038a6df1 | |
parent | 043f3123e3c63b634d9bfd7276e70d86b8accadc (diff) | |
download | libgit2-5675312e5aeb0c8b438df3ba9da7542673b2e0e7.tar.gz |
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.
-rw-r--r-- | src/thread.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/thread.h b/src/thread.h index 82eb7fcab..4bbac9fd8 100644 --- a/src/thread.h +++ b/src/thread.h @@ -180,7 +180,7 @@ GIT_INLINE(volatile void *) git_atomic__swap( #if defined(GIT_WIN32) return InterlockedExchangePointer(ptr, newval); #elif defined(GIT_BUILTIN_ATOMIC) - void * volatile foundval = NULL; + void * foundval = NULL; __atomic_exchange(ptr, &newval, &foundval, __ATOMIC_SEQ_CST); return foundval; #elif defined(GIT_BUILTIN_SYNC) |