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

@@ -123,6 +123,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGAVersion";
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
*statusPtr = 0;
jshort returnValue = getFPGAVersion( statusPtr );
HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr;
HALUTIL_LOG(logDEBUG) << "FPGAVersion = " << returnValue;
@@ -139,6 +140,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGARevision";
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
*statusPtr = 0;
jint returnValue = getFPGARevision( statusPtr );
HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr;
HALUTIL_LOG(logDEBUG) << "FPGARevision = " << returnValue;
@@ -155,6 +157,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
//HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGATime";
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
*statusPtr = 0;
jlong returnValue = getFPGATime( statusPtr );
//HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr;
//HALUTIL_LOG(logDEBUG) << "FPGATime = " << returnValue;
@@ -172,6 +175,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
//HALUTIL_LOG(logDEBUG) << "Calling HALUtil getFPGATime";
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
*statusPtr = 0;
jboolean returnValue = getFPGAButton( statusPtr );
//HALUTIL_LOG(logDEBUG) << "Status = " << *statusPtr;
//HALUTIL_LOG(logDEBUG) << "FPGATime = " << returnValue;