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:
Thad House
2016-06-01 20:12:50 -07:00
committed by Peter Johnson
parent f0d9e19b5c
commit c85b72b952
2 changed files with 2 additions and 1 deletions

View File

@@ -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;

View File

@@ -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) {