diff --git a/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp b/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp index 536111efae..4b0f02c3d0 100644 --- a/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp +++ b/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp @@ -2036,8 +2036,8 @@ struct LogMessage { void CallJava(JNIEnv* env, jobject func, jmethodID mid) { JLocal file{env, MakeJString(env, m_file)}; JLocal msg{env, MakeJString(env, m_msg)}; - env->CallVoidMethod(func, mid, (jint)m_level, file.obj(), (jint)m_line, - msg.obj()); + env->CallVoidMethod(func, mid, static_cast(m_level), file.obj(), + static_cast(m_line), msg.obj()); } static const char* GetName() { return "CSLogger"; } diff --git a/hal/src/main/native/cpp/jni/HALUtil.cpp b/hal/src/main/native/cpp/jni/HALUtil.cpp index 3b6796a057..fc37e9dd56 100644 --- a/hal/src/main/native/cpp/jni/HALUtil.cpp +++ b/hal/src/main/native/cpp/jni/HALUtil.cpp @@ -234,9 +234,10 @@ jobject CreatePWMConfigDataResult(JNIEnv* env, int32_t maxPwm, int32_t deadbandMinPwm, int32_t minPwm) { static jmethodID constructor = env->GetMethodID(pwmConfigDataResultCls, "", "(IIIII)V"); - return env->NewObject(pwmConfigDataResultCls, constructor, (jint)maxPwm, - (jint)deadbandMaxPwm, (jint)centerPwm, - (jint)deadbandMinPwm, (jint)minPwm); + return env->NewObject( + pwmConfigDataResultCls, constructor, static_cast(maxPwm), + static_cast(deadbandMaxPwm), static_cast(centerPwm), + static_cast(deadbandMinPwm), static_cast(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(percentBusUtilization), + static_cast(busOffCount), static_cast(txFullCount), + static_cast(receiveErrorCount), + static_cast(transmitErrorCount)); } void SetMatchInfoObject(JNIEnv* env, jobject matchStatus, @@ -261,8 +264,9 @@ void SetMatchInfoObject(JNIEnv* env, jobject matchStatus, MakeJString(env, wpi::StringRef{reinterpret_cast( matchInfo.gameSpecificMessage), matchInfo.gameSpecificMessageSize}), - (jint)matchInfo.matchNumber, (jint)matchInfo.replayNumber, - (jint)matchInfo.matchType); + static_cast(matchInfo.matchNumber), + static_cast(matchInfo.replayNumber), + static_cast(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(value), + static_cast(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( - env->CallObjectMethod(canData, func, (jint)length, (jlong)timestamp)); + jbyteArray retVal = static_cast(env->CallObjectMethod( + canData, func, static_cast(length), static_cast(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(value.type), value1, value2); } JavaVM* GetJVM() { diff --git a/hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.cpp b/hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.cpp index 261a7cab0b..8f4c141d2b 100644 --- a/hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.cpp +++ b/hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.cpp @@ -60,7 +60,7 @@ void BufferCallbackStore::performCallback(const char* name, uint8_t* buffer, static_cast(length)}); env->CallVoidMethod(m_call, sim::GetBufferCallback(), MakeJString(env, name), - toCallbackArr, (jint)length); + toCallbackArr, static_cast(length)); jbyte* fromCallbackArr = reinterpret_cast( env->GetPrimitiveArrayCritical(toCallbackArr, nullptr)); diff --git a/hal/src/main/native/cpp/jni/simulation/CallbackStore.cpp b/hal/src/main/native/cpp/jni/simulation/CallbackStore.cpp index 3d3e1c03a1..24426957d5 100644 --- a/hal/src/main/native/cpp/jni/simulation/CallbackStore.cpp +++ b/hal/src/main/native/cpp/jni/simulation/CallbackStore.cpp @@ -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(value->type), + static_cast(value->data.v_long), + static_cast(value->data.v_double)); if (env->ExceptionCheck()) { env->ExceptionDescribe(); diff --git a/hal/src/main/native/cpp/jni/simulation/ConstBufferCallbackStore.cpp b/hal/src/main/native/cpp/jni/simulation/ConstBufferCallbackStore.cpp index ce4c535671..1172c649e8 100644 --- a/hal/src/main/native/cpp/jni/simulation/ConstBufferCallbackStore.cpp +++ b/hal/src/main/native/cpp/jni/simulation/ConstBufferCallbackStore.cpp @@ -61,7 +61,8 @@ void ConstBufferCallbackStore::performCallback(const char* name, static_cast(length)}); env->CallVoidMethod(m_call, sim::GetConstBufferCallback(), - MakeJString(env, name), toCallbackArr, (jint)length); + MakeJString(env, name), toCallbackArr, + static_cast(length)); if (env->ExceptionCheck()) { env->ExceptionDescribe(); diff --git a/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp index b986548ce6..a6add4b1a5 100644 --- a/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp +++ b/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp @@ -55,7 +55,7 @@ jobject DeviceInfo::MakeJava(JNIEnv* env) const { static jmethodID func = env->GetMethodID(simDeviceInfoCls, "", "(Ljava/lang/String;I)V"); return env->NewObject(simDeviceInfoCls, func, MakeJString(env, name), - (jint)handle); + static_cast(handle)); } static std::pair ToValue12(const HAL_Value& value) { @@ -88,8 +88,8 @@ jobject ValueInfo::MakeJava(JNIEnv* env) const { env->GetMethodID(simValueInfoCls, "", "(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(handle), static_cast(direction), + static_cast(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(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(handle), + static_cast(direction), + static_cast(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(handle), + static_cast(direction == HAL_SimValueOutput), + static_cast(value.type), value1, value2); } if (env->ExceptionCheck()) { diff --git a/hal/src/main/native/cpp/jni/simulation/SpiReadAutoReceiveBufferCallbackStore.cpp b/hal/src/main/native/cpp/jni/simulation/SpiReadAutoReceiveBufferCallbackStore.cpp index 558d1c5c28..67121345cd 100644 --- a/hal/src/main/native/cpp/jni/simulation/SpiReadAutoReceiveBufferCallbackStore.cpp +++ b/hal/src/main/native/cpp/jni/simulation/SpiReadAutoReceiveBufferCallbackStore.cpp @@ -61,7 +61,7 @@ int32_t SpiReadAutoReceiveBufferCallbackStore::performCallback( jint ret = env->CallIntMethod(m_call, sim::GetBufferCallback(), MakeJString(env, name), toCallbackArr, - (jint)numToRead); + static_cast(numToRead)); jint* fromCallbackArr = reinterpret_cast( env->GetPrimitiveArrayCritical(toCallbackArr, nullptr)); diff --git a/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp b/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp index 03bb8c000b..f28adeca4e 100644 --- a/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp +++ b/ntcore/src/main/native/cpp/jni/NetworkTablesJNI.cpp @@ -192,10 +192,10 @@ static jobject MakeJObject(JNIEnv* env, const nt::Value& value) { switch (value.type()) { case NT_BOOLEAN: return env->NewObject(booleanCls, booleanConstructor, - (jboolean)(value.GetBoolean() ? 1 : 0)); + static_cast(value.GetBoolean() ? 1 : 0)); case NT_DOUBLE: return env->NewObject(doubleCls, doubleConstructor, - (jdouble)value.GetDouble()); + static_cast(value.GetDouble())); case NT_STRING: return MakeJString(env, value.GetString()); case NT_RAW: @@ -217,11 +217,13 @@ static jobject MakeJValue(JNIEnv* env, const nt::Value* value) { static jmethodID constructor = env->GetMethodID(valueCls, "", "(ILjava/lang/Object;J)V"); if (!value) { - return env->NewObject(valueCls, constructor, (jint)NT_UNASSIGNED, nullptr, - (jlong)0); + return env->NewObject(valueCls, constructor, + static_cast(NT_UNASSIGNED), nullptr, + static_cast(0)); } - return env->NewObject(valueCls, constructor, (jint)value->type(), - MakeJObject(env, *value), (jlong)value->time()); + return env->NewObject(valueCls, constructor, static_cast(value->type()), + MakeJObject(env, *value), + static_cast(value->time())); } static jobject MakeJObject(JNIEnv* env, const nt::ConnectionInfo& info) { @@ -231,8 +233,9 @@ static jobject MakeJObject(JNIEnv* env, const nt::ConnectionInfo& info) { JLocal remote_id{env, MakeJString(env, info.remote_id)}; JLocal remote_ip{env, MakeJString(env, info.remote_ip)}; return env->NewObject(connectionInfoCls, constructor, remote_id.obj(), - remote_ip.obj(), (jint)info.remote_port, - (jlong)info.last_update, (jint)info.protocol_version); + remote_ip.obj(), static_cast(info.remote_port), + static_cast(info.last_update), + static_cast(info.protocol_version)); } static jobject MakeJObject(JNIEnv* env, jobject inst, @@ -243,8 +246,9 @@ static jobject MakeJObject(JNIEnv* env, jobject inst, "networktables/ConnectionInfo;)V"); JLocal conn{env, MakeJObject(env, notification.conn)}; return env->NewObject(connectionNotificationCls, constructor, inst, - (jint)notification.listener, - (jboolean)notification.connected, conn.obj()); + static_cast(notification.listener), + static_cast(notification.connected), + conn.obj()); } static jobject MakeJObject(JNIEnv* env, jobject inst, @@ -254,9 +258,10 @@ static jobject MakeJObject(JNIEnv* env, jobject inst, "(Ledu/wpi/first/networktables/" "NetworkTableInstance;ILjava/lang/String;IIJ)V"); JLocal name{env, MakeJString(env, info.name)}; - return env->NewObject(entryInfoCls, constructor, inst, (jint)info.entry, - name.obj(), (jint)info.type, (jint)info.flags, - (jlong)info.last_change); + return env->NewObject( + entryInfoCls, constructor, inst, static_cast(info.entry), + name.obj(), static_cast(info.type), static_cast(info.flags), + static_cast(info.last_change)); } static jobject MakeJObject(JNIEnv* env, jobject inst, @@ -268,8 +273,9 @@ static jobject MakeJObject(JNIEnv* env, jobject inst, JLocal name{env, MakeJString(env, notification.name)}; JLocal value{env, MakeJValue(env, notification.value.get())}; return env->NewObject(entryNotificationCls, constructor, inst, - (jint)notification.listener, (jint)notification.entry, - name.obj(), value.obj(), (jint)notification.flags); + static_cast(notification.listener), + static_cast(notification.entry), name.obj(), + value.obj(), static_cast(notification.flags)); } static jobject MakeJObject(JNIEnv* env, jobject inst, @@ -280,9 +286,10 @@ static jobject MakeJObject(JNIEnv* env, jobject inst, "String;ILjava/lang/String;)V"); JLocal filename{env, MakeJString(env, msg.filename)}; JLocal message{env, MakeJString(env, msg.message)}; - return env->NewObject(logMessageCls, constructor, inst, (jint)msg.logger, - (jint)msg.level, filename.obj(), (jint)msg.line, - message.obj()); + return env->NewObject(logMessageCls, constructor, inst, + static_cast(msg.logger), + static_cast(msg.level), filename.obj(), + static_cast(msg.line), message.obj()); } static jobject MakeJObject(JNIEnv* env, jobject inst, @@ -295,9 +302,9 @@ static jobject MakeJObject(JNIEnv* env, jobject inst, JLocal name{env, MakeJString(env, answer.name)}; JLocal params{env, MakeJByteArray(env, answer.params)}; JLocal conn{env, MakeJObject(env, answer.conn)}; - return env->NewObject(rpcAnswerCls, constructor, inst, (jint)answer.entry, - (jint)answer.call, name.obj(), params.obj(), - conn.obj()); + return env->NewObject( + rpcAnswerCls, constructor, inst, static_cast(answer.entry), + static_cast(answer.call), name.obj(), params.obj(), conn.obj()); } static jobjectArray MakeJObject(JNIEnv* env, jobject inst, diff --git a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_Joystick.cpp b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_Joystick.cpp index 17b081bed9..e4cc2387ac 100644 --- a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_Joystick.cpp +++ b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_Joystick.cpp @@ -95,7 +95,8 @@ void HALSimWSProviderJoystick::OnNetValueChanged(const wpi::json& json) { if ((it = json.find(">axes")) != json.end()) { HAL_JoystickAxes axes{}; axes.count = - std::min(it.value().size(), (wpi::json::size_type)HAL_kMaxJoystickAxes); + std::min(it.value().size(), + static_cast(HAL_kMaxJoystickAxes)); for (int i = 0; i < axes.count; i++) { axes.axes[i] = it.value()[i]; } @@ -105,7 +106,8 @@ void HALSimWSProviderJoystick::OnNetValueChanged(const wpi::json& json) { if ((it = json.find(">buttons")) != json.end()) { HAL_JoystickButtons buttons{}; - buttons.count = std::min(it.value().size(), (wpi::json::size_type)32); + buttons.count = + std::min(it.value().size(), static_cast(32)); for (int i = 0; i < buttons.count; i++) { if (it.value()[i]) { buttons.buttons |= 1 << (i - 1); @@ -118,7 +120,8 @@ void HALSimWSProviderJoystick::OnNetValueChanged(const wpi::json& json) { if ((it = json.find(">povs")) != json.end()) { HAL_JoystickPOVs povs{}; povs.count = - std::min(it.value().size(), (wpi::json::size_type)HAL_kMaxJoystickPOVs); + std::min(it.value().size(), + static_cast(HAL_kMaxJoystickPOVs)); for (int i = 0; i < povs.count; i++) { povs.povs[i] = it.value()[i]; } diff --git a/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp b/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp index 1a3d79837d..a482cf5535 100644 --- a/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp +++ b/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp @@ -28,7 +28,7 @@ void BuiltInAccelerometer::SetRange(Range range) { } HAL_SetAccelerometerActive(false); - HAL_SetAccelerometerRange((HAL_AccelerometerRange)range); + HAL_SetAccelerometerRange(static_cast(range)); HAL_SetAccelerometerActive(true); } diff --git a/wpilibc/src/main/native/cpp/Counter.cpp b/wpilibc/src/main/native/cpp/Counter.cpp index c12b43be4b..e1d9d2920e 100644 --- a/wpilibc/src/main/native/cpp/Counter.cpp +++ b/wpilibc/src/main/native/cpp/Counter.cpp @@ -20,7 +20,8 @@ using namespace frc; Counter::Counter(Mode mode) { int32_t status = 0; - m_counter = HAL_InitializeCounter((HAL_Counter_Mode)mode, &m_index, &status); + m_counter = HAL_InitializeCounter(static_cast(mode), + &m_index, &status); wpi_setHALError(status); SetMaxPeriod(0.5); @@ -129,10 +130,10 @@ void Counter::SetUpSource(std::shared_ptr source) { CloneError(*m_upSource); } else { int32_t status = 0; - HAL_SetCounterUpSource( - m_counter, source->GetPortHandleForRouting(), - (HAL_AnalogTriggerType)source->GetAnalogTriggerTypeForRouting(), - &status); + HAL_SetCounterUpSource(m_counter, source->GetPortHandleForRouting(), + static_cast( + source->GetAnalogTriggerTypeForRouting()), + &status); wpi_setHALError(status); } } @@ -208,10 +209,10 @@ void Counter::SetDownSource(std::shared_ptr source) { CloneError(*m_downSource); } else { int32_t status = 0; - HAL_SetCounterDownSource( - m_counter, source->GetPortHandleForRouting(), - (HAL_AnalogTriggerType)source->GetAnalogTriggerTypeForRouting(), - &status); + HAL_SetCounterDownSource(m_counter, source->GetPortHandleForRouting(), + static_cast( + source->GetAnalogTriggerTypeForRouting()), + &status); wpi_setHALError(status); } } diff --git a/wpilibc/src/main/native/cpp/DigitalInput.cpp b/wpilibc/src/main/native/cpp/DigitalInput.cpp index 51a8495462..1751053950 100644 --- a/wpilibc/src/main/native/cpp/DigitalInput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalInput.cpp @@ -62,7 +62,7 @@ HAL_Handle DigitalInput::GetPortHandleForRouting() const { } AnalogTriggerType DigitalInput::GetAnalogTriggerTypeForRouting() const { - return (AnalogTriggerType)0; + return static_cast(0); } bool DigitalInput::IsAnalogTrigger() const { diff --git a/wpilibc/src/main/native/cpp/DigitalOutput.cpp b/wpilibc/src/main/native/cpp/DigitalOutput.cpp index 3601c7ecf7..c8d3c13a8e 100644 --- a/wpilibc/src/main/native/cpp/DigitalOutput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalOutput.cpp @@ -77,7 +77,7 @@ HAL_Handle DigitalOutput::GetPortHandleForRouting() const { } AnalogTriggerType DigitalOutput::GetAnalogTriggerTypeForRouting() const { - return (AnalogTriggerType)0; + return static_cast(0); } bool DigitalOutput::IsAnalogTrigger() const { diff --git a/wpilibc/src/main/native/cpp/Encoder.cpp b/wpilibc/src/main/native/cpp/Encoder.cpp index 107d755362..57e58590af 100644 --- a/wpilibc/src/main/native/cpp/Encoder.cpp +++ b/wpilibc/src/main/native/cpp/Encoder.cpp @@ -237,10 +237,11 @@ void Encoder::SetIndexSource(int channel, Encoder::IndexingType type) { void Encoder::SetIndexSource(const DigitalSource& source, Encoder::IndexingType type) { int32_t status = 0; - HAL_SetEncoderIndexSource( - m_encoder, source.GetPortHandleForRouting(), - (HAL_AnalogTriggerType)source.GetAnalogTriggerTypeForRouting(), - (HAL_EncoderIndexingType)type, &status); + HAL_SetEncoderIndexSource(m_encoder, source.GetPortHandleForRouting(), + static_cast( + source.GetAnalogTriggerTypeForRouting()), + static_cast(type), + &status); wpi_setHALError(status); } @@ -277,10 +278,13 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) { int32_t status = 0; m_encoder = HAL_InitializeEncoder( m_aSource->GetPortHandleForRouting(), - (HAL_AnalogTriggerType)m_aSource->GetAnalogTriggerTypeForRouting(), + static_cast( + m_aSource->GetAnalogTriggerTypeForRouting()), m_bSource->GetPortHandleForRouting(), - (HAL_AnalogTriggerType)m_bSource->GetAnalogTriggerTypeForRouting(), - reverseDirection, (HAL_EncoderEncodingType)encodingType, &status); + static_cast( + m_bSource->GetAnalogTriggerTypeForRouting()), + reverseDirection, static_cast(encodingType), + &status); wpi_setHALError(status); HAL_Report(HALUsageReporting::kResourceType_Encoder, GetFPGAIndex() + 1, diff --git a/wpilibc/src/main/native/cpp/SPI.cpp b/wpilibc/src/main/native/cpp/SPI.cpp index 28437cea77..12ebb172d1 100644 --- a/wpilibc/src/main/native/cpp/SPI.cpp +++ b/wpilibc/src/main/native/cpp/SPI.cpp @@ -283,10 +283,10 @@ void SPI::StartAutoRate(double period) { void SPI::StartAutoTrigger(DigitalSource& source, bool rising, bool falling) { int32_t status = 0; - HAL_StartSPIAutoTrigger( - m_port, source.GetPortHandleForRouting(), - (HAL_AnalogTriggerType)source.GetAnalogTriggerTypeForRouting(), rising, - falling, &status); + HAL_StartSPIAutoTrigger(m_port, source.GetPortHandleForRouting(), + static_cast( + source.GetAnalogTriggerTypeForRouting()), + rising, falling, &status); wpi_setHALError(status); } diff --git a/wpiutil/src/main/native/cpp/TCPAcceptor.cpp b/wpiutil/src/main/native/cpp/TCPAcceptor.cpp index adbff00dcf..de4bfcf1d7 100644 --- a/wpiutil/src/main/native/cpp/TCPAcceptor.cpp +++ b/wpiutil/src/main/native/cpp/TCPAcceptor.cpp @@ -190,7 +190,7 @@ std::unique_ptr TCPAcceptor::accept() { socklen_t len = sizeof(address); #endif std::memset(&address, 0, sizeof(address)); - int sd = ::accept(m_lsd, (struct sockaddr*)&address, &len); + int sd = ::accept(m_lsd, reinterpret_cast(&address), &len); if (sd < 0) { if (!m_shutdown) { WPI_ERROR(m_logger, "accept() on port " diff --git a/wpiutil/src/main/native/cpp/TCPConnector.cpp b/wpiutil/src/main/native/cpp/TCPConnector.cpp index f0b807bbed..20fdbc9369 100644 --- a/wpiutil/src/main/native/cpp/TCPConnector.cpp +++ b/wpiutil/src/main/native/cpp/TCPConnector.cpp @@ -108,7 +108,8 @@ std::unique_ptr TCPConnector::connect(const char* server, WPI_ERROR(logger, "could not create socket"); return nullptr; } - if (::connect(sd, (struct sockaddr*)&address, sizeof(address)) != 0) { + if (::connect(sd, reinterpret_cast(&address), + sizeof(address)) != 0) { WPI_ERROR(logger, "connect() to " << server << " port " << port << " failed: " << SocketStrerror()); #ifdef _WIN32 @@ -152,8 +153,8 @@ std::unique_ptr TCPConnector::connect(const char* server, #endif // Connect with time limit - if ((result = ::connect(sd, (struct sockaddr*)&address, sizeof(address))) < - 0) { + if ((result = ::connect(sd, reinterpret_cast(&address), + sizeof(address))) < 0) { int my_errno = SocketErrno(); #ifdef _WIN32 if (my_errno == WSAEWOULDBLOCK || my_errno == WSAEINPROGRESS) {