Replaced C-style casts found by GCC in HAL, wpilibc, and JNI (#211)

This commit is contained in:
Tyler Veness
2016-08-24 21:39:16 -07:00
committed by Peter Johnson
parent 2ec6132fcb
commit 93b486b6ba
16 changed files with 45 additions and 34 deletions

View File

@@ -71,7 +71,7 @@ THandle DigitalHandleResource<THandle, TStruct, size>::Allocate(
return HAL_kInvalidHandle;
}
m_structures[index] = std::make_shared<TStruct>();
return (THandle)hal::createHandle(index, enumValue);
return static_cast<THandle>(hal::createHandle(index, enumValue));
}
template <typename THandle, typename TStruct, int16_t size>

View File

@@ -51,7 +51,7 @@ static inline int16_t getHandleIndex(HAL_Handle handle) {
}
static inline HAL_HandleEnum getHandleType(HAL_Handle handle) {
// mask first 8 bits and cast to enum
return (HAL_HandleEnum)((handle >> 24) & 0xff);
return static_cast<HAL_HandleEnum>((handle >> 24) & 0xff);
}
static inline bool isHandleType(HAL_Handle handle, HAL_HandleEnum handleType) {
return handleType == getHandleType(handle);

View File

@@ -75,7 +75,7 @@ THandle IndexedHandleResource<THandle, TStruct, size, enumValue>::Allocate(
return HAL_kInvalidHandle;
}
m_structures[index] = std::make_shared<TStruct>();
return (THandle)hal::createHandle(index, enumValue);
return static_cast<THandle>(hal::createHandle(index, enumValue));
}
template <typename THandle, typename TStruct, int16_t size,

View File

@@ -73,7 +73,7 @@ LimitedClassedHandleResource<THandle, TStruct, size, enumValue>::Allocate(
// and allocate it.
std::lock_guard<priority_mutex> sync(m_handleMutexes[i]);
m_structures[i] = toSet;
return (THandle)createHandle(i, enumValue);
return static_cast<THandle>(createHandle(i, enumValue));
}
}
return HAL_kInvalidHandle;

View File

@@ -69,7 +69,7 @@ THandle LimitedHandleResource<THandle, TStruct, size, enumValue>::Allocate() {
// and allocate it.
std::lock_guard<priority_mutex> sync(m_handleMutexes[i]);
m_structures[i] = std::make_shared<TStruct>();
return (THandle)createHandle(i, enumValue);
return static_cast<THandle>(createHandle(i, enumValue));
}
}
return HAL_kInvalidHandle;

View File

@@ -57,13 +57,13 @@ THandle UnlimitedHandleResource<THandle, TStruct, enumValue>::Allocate(
for (i = 0; i < m_structures.size(); i++) {
if (m_structures[i] == nullptr) {
m_structures[i] = structure;
return (THandle)createHandle(i, enumValue);
return static_cast<THandle>(createHandle(i, enumValue));
}
}
if (i >= INT16_MAX) return HAL_kInvalidHandle;
m_structures.push_back(structure);
return (THandle)createHandle(static_cast<int16_t>(i), enumValue);
return static_cast<THandle>(createHandle(static_cast<int16_t>(i), enumValue));
}
template <typename THandle, typename TStruct, HAL_HandleEnum enumValue>