changeset 215:1a709d70a4cf

8132021: SPICompositeMessage.trasfer[] returns invalid result Summary: Fixed array sizes Reviewed-by: alkonsta
author snazarki
date Tue, 21 Jul 2015 14:49:56 +0300
parents 9cc5a10cf711
children a65439c34396
files src/share/classes/com/oracle/dio/spibus/impl/SPICompositeMessageImpl.java
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/oracle/dio/spibus/impl/SPICompositeMessageImpl.java	Tue Jul 14 18:20:07 2015 +0300
+++ b/src/share/classes/com/oracle/dio/spibus/impl/SPICompositeMessageImpl.java	Tue Jul 21 14:49:56 2015 +0300
@@ -116,14 +116,16 @@
 
     @Override
     public SPICompositeMessage appendRead(int rxSkip, ByteBuffer rxBuf) throws IOException, ClosedDeviceException {
-        device.checkBuffer(rxBuf);
+        //null check
+        rxBuf.limit();
         return append(null, rxSkip, rxBuf);
     }
 
     @Override
     public SPICompositeMessage appendWrite( ByteBuffer txBuf) throws IOException,
             ClosedDeviceException {
-        device.checkBuffer(txBuf);
+        //null check
+        txBuf.limit();
         return append(txBuf, 0, null);
     }
 
@@ -134,8 +136,9 @@
 
     @Override
     public SPICompositeMessage appendWriteAndRead(ByteBuffer src, int skip, ByteBuffer dst) throws IOException, ClosedDeviceException{
-        device.checkBuffer(src);
-        device.checkBuffer(dst);
+        //null check
+        src.limit();
+        dst.limit();
         return append(src,skip,dst);
     }
 
@@ -167,12 +170,12 @@
             /* Forbid adding more messages to this combined message */
             isAlreadyTransferedOnce = true;
             if (0 == messageList.size()) {
-                return null;
+                return new int[0];
             }
             int transaction = device.beginTransaction();
             try {
                 final int size = messageList.size();
-                int[] bytesRead = new int[size];
+                int[] bytesRead = new int[rxMsgs];
                 for (int i = 0, j = 0; i < size; i++) {
                     Message message = messageList.get(i);
                     int res = device.transfer(message.tx, message.skip, message.rx, transaction);