mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-04-12 19:30:42 +02:00
util: silence two clang-tidy false positives
Both about the same complaint, somehow it is of the impression that
masks->mask can be an uninitialized value. The only place where we
allocate those is in _infmask_ensure_size() and they're set to zero
there.
libinput/src/util-bits.h:166:22: warning: The left operand of '&' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
166 | return !!(mask.mask & bit(bit));
| ^
libinput/src/util-bits.h:444:2: note: Calling 'infmask_set_bit'
444 | infmask_set_bit(&m, mask);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
libinput/src/util-bits.h:394:15: note: Calling 'infmask_bit_is_set'
394 | bool isset = infmask_bit_is_set(mask, bit);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libinput/src/util-bits.h:382:13: note: Field 'mask' is non-null
382 | if (!mask->mask || bit / bitmask_size() >= mask->nmasks)
| ^
libinput/src/util-bits.h:382:6: note: Left side of '||' is false
382 | if (!mask->mask || bit / bitmask_size() >= mask->nmasks)
| ^
libinput/src/util-bits.h:382:2: note: Taking false branch
382 | if (!mask->mask || bit / bitmask_size() >= mask->nmasks)
| ^
libinput/src/util-bits.h:385:9: note: Uninitialized value stored to 'mask.mask'
385 | return bitmask_bit_is_set(mask->mask[bit / bitmask_size()], // NOLINT(core.UndefinedBinaryOperatorResult)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
386 | bit % bitmask_size());
| ~~~~~~~~~~~~~~~~~~~~~
libinput/src/util-bits.h:385:9: note: Calling 'bitmask_bit_is_set'
385 | return bitmask_bit_is_set(mask->mask[bit / bitmask_size()], // NOLINT(core.UndefinedBinaryOperatorResult)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
386 | bit % bitmask_size());
| ~~~~~~~~~~~~~~~~~~~~~
libinput/src/util-bits.h:166:22: note: The left operand of '&' is a garbage value
166 | return !!(mask.mask & bit(bit));
| ~~~~~~~~~ ^
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1292>
This commit is contained in:
parent
b831068fbb
commit
aa9d5bf630
1 changed files with 5 additions and 3 deletions
|
|
@ -161,7 +161,7 @@ _nonnull_(1) static inline bool bitmask_clear(bitmask_t *mask, bitmask_t bits)
|
|||
static inline bool
|
||||
bitmask_bit_is_set(bitmask_t mask, unsigned int bit)
|
||||
{
|
||||
return !!(mask.mask & bit(bit));
|
||||
return !!(mask.mask & bit(bit)); // NOLINT: core.UndefinedBinaryOperatorResult
|
||||
}
|
||||
|
||||
_nonnull_(1) static inline bool bitmask_set_bit(bitmask_t *mask, unsigned int bit)
|
||||
|
|
@ -371,8 +371,10 @@ _nonnull_(1) static inline bool infmask_bit_is_set(const infmask_t *mask,
|
|||
if (!mask->mask || bit / bitmask_size() >= mask->nmasks)
|
||||
return false;
|
||||
|
||||
return bitmask_bit_is_set(mask->mask[bit / bitmask_size()],
|
||||
bit % bitmask_size());
|
||||
return bitmask_bit_is_set(
|
||||
mask->mask[bit / bitmask_size()], // NOLINT:
|
||||
// core.UndefinedBinaryOperatorResult
|
||||
bit % bitmask_size());
|
||||
}
|
||||
|
||||
_nonnull_(1) static inline bool infmask_set_bit(infmask_t *mask, unsigned int bit)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue