spa: avoid type narrowing warning #11336
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Building the spa module for i386 caused gcc to emit
-Wint-to-pointer-cast "cast to pointer from integer of different size"
because spa.spa_did was uint64_t but pthread_join (via thread_join in
spa_deactivate) takes a pointer (32-bit on i386). Define spa_did to be
pointer-size instead. For now spa_did is in fact never non-zero and the
thread_join could instead be ifdef'd out, but changing the size of
spa_did may be more useful for the future.
Signed-off-by: Ryan Libby [email protected]
Motivation and Context
Part of a small set of changes for building with gcc on FreeBSD.
This addresses an issue with the amd64 gcc build on FreeBSD. When gcc builds the spa module for i386 it emits the following warning due to the size difference between uint64_t and pthread_t:
Description
The solution here is to define spa_did as uintptr_t, which will match pointer size, avoiding the warning. In fact, for now, spa_did is never assigned non-zero because the code is ifdef'd out. Even in the ifdef'd code, it is never assigned a pthread_t, but only a kernel thread id. Perhaps this may change in the future. Regardless, neither a kernel thread id nor a pthread_t should be larger than uintptr_t.
How Has This Been Tested?
Compile tested in the downstream FreeBSD build with gcc and clang.
Types of changes
Checklist:
Signed-off-by
.