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:
Peter Johnson
2015-09-29 23:45:55 -07:00
parent c0c91c414a
commit 049be6870c
18 changed files with 181 additions and 1 deletions

View File

@@ -615,6 +615,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCo
(JNIEnv * env, jclass, jobject status)
{
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
*statusPtr = 0;
return HALGetSystemActive((int32_t*)statusPtr);
}
@@ -627,6 +628,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCo
(JNIEnv * env, jclass, jobject status)
{
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
*statusPtr = 0;
return HALGetBrownedOut((int32_t*)statusPtr);
}