clang-tidy: google-readability-casting (NFC)

This commit is contained in:
Peter Johnson
2020-12-28 11:04:20 -08:00
parent 32fa97d68d
commit c97c6dc065
17 changed files with 104 additions and 80 deletions

View File

@@ -234,9 +234,10 @@ jobject CreatePWMConfigDataResult(JNIEnv* env, int32_t maxPwm,
int32_t deadbandMinPwm, int32_t minPwm) {
static jmethodID constructor =
env->GetMethodID(pwmConfigDataResultCls, "<init>", "(IIIII)V");
return env->NewObject(pwmConfigDataResultCls, constructor, (jint)maxPwm,
(jint)deadbandMaxPwm, (jint)centerPwm,
(jint)deadbandMinPwm, (jint)minPwm);
return env->NewObject(
pwmConfigDataResultCls, constructor, static_cast<jint>(maxPwm),
static_cast<jint>(deadbandMaxPwm), static_cast<jint>(centerPwm),
static_cast<jint>(deadbandMinPwm), static_cast<jint>(minPwm));
}
void SetCanStatusObject(JNIEnv* env, jobject canStatus,
@@ -245,9 +246,11 @@ void SetCanStatusObject(JNIEnv* env, jobject canStatus,
uint32_t transmitErrorCount) {
static jmethodID func =
env->GetMethodID(canStatusCls, "setStatus", "(DIIII)V");
env->CallVoidMethod(canStatus, func, (jdouble)percentBusUtilization,
(jint)busOffCount, (jint)txFullCount,
(jint)receiveErrorCount, (jint)transmitErrorCount);
env->CallVoidMethod(
canStatus, func, static_cast<jdouble>(percentBusUtilization),
static_cast<jint>(busOffCount), static_cast<jint>(txFullCount),
static_cast<jint>(receiveErrorCount),
static_cast<jint>(transmitErrorCount));
}
void SetMatchInfoObject(JNIEnv* env, jobject matchStatus,
@@ -261,8 +264,9 @@ void SetMatchInfoObject(JNIEnv* env, jobject matchStatus,
MakeJString(env, wpi::StringRef{reinterpret_cast<const char*>(
matchInfo.gameSpecificMessage),
matchInfo.gameSpecificMessageSize}),
(jint)matchInfo.matchNumber, (jint)matchInfo.replayNumber,
(jint)matchInfo.matchType);
static_cast<jint>(matchInfo.matchNumber),
static_cast<jint>(matchInfo.replayNumber),
static_cast<jint>(matchInfo.matchType));
}
void SetAccumulatorResultObject(JNIEnv* env, jobject accumulatorResult,
@@ -270,15 +274,16 @@ void SetAccumulatorResultObject(JNIEnv* env, jobject accumulatorResult,
static jmethodID func =
env->GetMethodID(accumulatorResultCls, "set", "(JJ)V");
env->CallVoidMethod(accumulatorResult, func, (jlong)value, (jlong)count);
env->CallVoidMethod(accumulatorResult, func, static_cast<jlong>(value),
static_cast<jlong>(count));
}
jbyteArray SetCANDataObject(JNIEnv* env, jobject canData, int32_t length,
uint64_t timestamp) {
static jmethodID func = env->GetMethodID(canDataCls, "setData", "(IJ)[B");
jbyteArray retVal = static_cast<jbyteArray>(
env->CallObjectMethod(canData, func, (jint)length, (jlong)timestamp));
jbyteArray retVal = static_cast<jbyteArray>(env->CallObjectMethod(
canData, func, static_cast<jint>(length), static_cast<jlong>(timestamp)));
return retVal;
}
@@ -306,8 +311,8 @@ jobject CreateHALValue(JNIEnv* env, const HAL_Value& value) {
default:
break;
}
return env->CallStaticObjectMethod(halValueCls, fromNative, (jint)value.type,
value1, value2);
return env->CallStaticObjectMethod(
halValueCls, fromNative, static_cast<jint>(value.type), value1, value2);
}
JavaVM* GetJVM() {

View File

@@ -60,7 +60,7 @@ void BufferCallbackStore::performCallback(const char* name, uint8_t* buffer,
static_cast<size_t>(length)});
env->CallVoidMethod(m_call, sim::GetBufferCallback(), MakeJString(env, name),
toCallbackArr, (jint)length);
toCallbackArr, static_cast<jint>(length));
jbyte* fromCallbackArr = reinterpret_cast<jbyte*>(
env->GetPrimitiveArrayCritical(toCallbackArr, nullptr));

View File

@@ -55,8 +55,9 @@ void CallbackStore::performCallback(const char* name, const HAL_Value* value) {
}
env->CallVoidMethod(m_call, sim::GetNotifyCallback(), MakeJString(env, name),
(jint)value->type, (jlong)value->data.v_long,
(jdouble)value->data.v_double);
static_cast<jint>(value->type),
static_cast<jlong>(value->data.v_long),
static_cast<jdouble>(value->data.v_double));
if (env->ExceptionCheck()) {
env->ExceptionDescribe();

View File

@@ -61,7 +61,8 @@ void ConstBufferCallbackStore::performCallback(const char* name,
static_cast<size_t>(length)});
env->CallVoidMethod(m_call, sim::GetConstBufferCallback(),
MakeJString(env, name), toCallbackArr, (jint)length);
MakeJString(env, name), toCallbackArr,
static_cast<jint>(length));
if (env->ExceptionCheck()) {
env->ExceptionDescribe();

View File

@@ -55,7 +55,7 @@ jobject DeviceInfo::MakeJava(JNIEnv* env) const {
static jmethodID func =
env->GetMethodID(simDeviceInfoCls, "<init>", "(Ljava/lang/String;I)V");
return env->NewObject(simDeviceInfoCls, func, MakeJString(env, name),
(jint)handle);
static_cast<jint>(handle));
}
static std::pair<jlong, jdouble> ToValue12(const HAL_Value& value) {
@@ -88,8 +88,8 @@ jobject ValueInfo::MakeJava(JNIEnv* env) const {
env->GetMethodID(simValueInfoCls, "<init>", "(Ljava/lang/String;IIIJD)V");
auto [value1, value2] = ToValue12(value);
return env->NewObject(simValueInfoCls, func, MakeJString(env, name),
(jint)handle, (jint)direction, (jint)value.type, value1,
value2);
static_cast<jint>(handle), static_cast<jint>(direction),
static_cast<jint>(value.type), value1, value2);
}
namespace {
@@ -147,7 +147,7 @@ void DeviceCallbackStore::performCallback(const char* name,
}
env->CallVoidMethod(m_call, simDeviceCallbackCallback, MakeJString(env, name),
(jint)handle);
static_cast<jint>(handle));
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
@@ -183,13 +183,14 @@ void ValueCallbackStore::performCallback(const char* name,
auto [value1, value2] = ToValue12(value);
if (m_dirCallback) {
env->CallVoidMethod(m_call, simValueCallbackCallback,
MakeJString(env, name), (jint)handle, (jint)direction,
(jint)value.type, value1, value2);
MakeJString(env, name), static_cast<jint>(handle),
static_cast<jint>(direction),
static_cast<jint>(value.type), value1, value2);
} else {
env->CallVoidMethod(m_call, simValueCallbackCallback,
MakeJString(env, name), (jint)handle,
(jboolean)(direction == HAL_SimValueOutput),
(jint)value.type, value1, value2);
MakeJString(env, name), static_cast<jint>(handle),
static_cast<jboolean>(direction == HAL_SimValueOutput),
static_cast<jint>(value.type), value1, value2);
}
if (env->ExceptionCheck()) {

View File

@@ -61,7 +61,7 @@ int32_t SpiReadAutoReceiveBufferCallbackStore::performCallback(
jint ret = env->CallIntMethod(m_call, sim::GetBufferCallback(),
MakeJString(env, name), toCallbackArr,
(jint)numToRead);
static_cast<jint>(numToRead));
jint* fromCallbackArr = reinterpret_cast<jint*>(
env->GetPrimitiveArrayCritical(toCallbackArr, nullptr));