mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Fixes a few bugs in the initial handle implementation (#94)
Failure to check for invalid type on handle creation, and handle type check was broken.
This commit is contained in:
committed by
Peter Johnson
parent
f0d9e19b5c
commit
c85b72b952
@@ -13,6 +13,7 @@
|
||||
namespace hal {
|
||||
HalHandle createHandle(int16_t index, HalHandleEnum handleType) {
|
||||
if (index < 0) return HAL_HANDLE_NEGATIVE_INDEX;
|
||||
if (handleType <= 0 || handleType > 127) return HAL_HANDLE_INVALID_TYPE;
|
||||
// set last 8 bits, then shift to first 8 bits
|
||||
HalHandle handle = handleType;
|
||||
handle = handle << 24;
|
||||
|
||||
@@ -31,7 +31,7 @@ static inline HalHandleEnum getHandleType(HalHandle handle) {
|
||||
return (HalHandleEnum)((handle >> 24) & 0xff);
|
||||
}
|
||||
static inline bool isHandleType(HalHandle handle, HalHandleEnum handleType) {
|
||||
return handleType == getHandleType(handleType);
|
||||
return handleType == getHandleType(handle);
|
||||
}
|
||||
static inline int16_t getHandleTypedIndex(HalHandle handle,
|
||||
HalHandleEnum enumType) {
|
||||
|
||||
Reference in New Issue
Block a user