Skip to content

Commit

Permalink
Use correct argument type for _BitScanReverse and _BitScanReverse64. (x…
Browse files Browse the repository at this point in the history
…iph#638)

_BitScanReverse and _BitScanReverse64 are documented to take an `unsigned long *` as the first argument (see <https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64?view=msvc-170>), however libFLAC used `uint32_t` which happens to be `unsigned int`.

This silences Clang warning `incompatible pointer types passing 'uint32_t *' (aka 'unsigned int *') to parameter of type 'unsigned long *' [-Wincompatible-pointer-types]`.

Fixes xiph#637
See also xiph#638 for comments
  • Loading branch information
manxorist authored Jul 27, 2023
1 parent 6c126e9 commit 31ccd3d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libFLAC/include/private/bitmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static inline uint32_t FLAC__clz_uint32(FLAC__uint32 v)
return __builtin_clz(v);
#elif defined(_MSC_VER)
{
uint32_t idx;
unsigned long idx;
_BitScanReverse(&idx, v);
return idx ^ 31U;
}
Expand All @@ -106,7 +106,7 @@ static inline uint32_t FLAC__clz_uint64(FLAC__uint64 v)
return __builtin_clzll(v);
#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64))
{
uint32_t idx;
unsigned long idx;
_BitScanReverse64(&idx, v);
return idx ^ 63U;
}
Expand Down Expand Up @@ -160,7 +160,7 @@ static inline uint32_t FLAC__bitmath_ilog2(FLAC__uint32 v)
return _bit_scan_reverse(v);
#elif defined(_MSC_VER)
{
uint32_t idx;
unsigned long idx;
_BitScanReverse(&idx, v);
return idx;
}
Expand All @@ -177,7 +177,7 @@ static inline uint32_t FLAC__bitmath_ilog2_wide(FLAC__uint64 v)
/* Sorry, only supported in x64/Itanium.. and both have fast FPU which makes integer-only encoder pointless */
#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64))
{
uint32_t idx;
unsigned long idx;
_BitScanReverse64(&idx, v);
return idx;
}
Expand Down

0 comments on commit 31ccd3d

Please sign in to comment.