mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Always initialize status to 0 when calling HAL from JNI.
The HAL functions often call NI functions that may expect status to be initialized on entry. Java does not guarantee direct pointer allocation memory to be initialized, although that may have been occurring by accident. Change-Id: I5e3a553f3a7be8de3716ccfc13e6ca1cb4f2a552
This commit is contained in:
@@ -22,6 +22,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTemperatur
|
||||
{
|
||||
jint *status_ptr = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
*status_ptr = 0;
|
||||
return getPDPTemperature(status_ptr, module);
|
||||
}
|
||||
|
||||
@@ -35,6 +36,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPVoltage
|
||||
{
|
||||
jint *status_ptr = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
*status_ptr = 0;
|
||||
return getPDPVoltage(status_ptr, module);
|
||||
}
|
||||
|
||||
@@ -48,6 +50,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPChannelCur
|
||||
{
|
||||
jint *status_ptr = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
*status_ptr = 0;
|
||||
return getPDPChannelCurrent(channel, status_ptr, module);
|
||||
}
|
||||
|
||||
@@ -61,6 +64,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalCurre
|
||||
{
|
||||
jint *status_ptr = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
*status_ptr = 0;
|
||||
return getPDPTotalCurrent(status_ptr, module);
|
||||
}
|
||||
|
||||
@@ -74,6 +78,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalPower
|
||||
{
|
||||
jint *status_ptr = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
*status_ptr = 0;
|
||||
return getPDPTotalPower(status_ptr, module);
|
||||
}
|
||||
|
||||
@@ -87,6 +92,7 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalEnerg
|
||||
{
|
||||
jint *status_ptr = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
*status_ptr = 0;
|
||||
return getPDPTotalEnergy(status_ptr, module);
|
||||
}
|
||||
|
||||
@@ -101,6 +107,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_resetPDPTotalEnergy
|
||||
{
|
||||
jint *status_ptr = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
*status_ptr = 0;
|
||||
resetPDPTotalEnergy(status_ptr, module);
|
||||
}
|
||||
|
||||
@@ -114,5 +121,6 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_clearPDPStickyFault
|
||||
{
|
||||
jint *status_ptr = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
*status_ptr = 0;
|
||||
clearPDPStickyFaults(status_ptr, module);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user