changeset 98:eca473967edd

8072410: SPIDevice doesn't check buffer for NULL Summary: Restored buffer check at public functions calls. Reviewed-by: alkonsta
author snazarki
date Wed, 04 Feb 2015 13:28:50 +0400
parents 2059c5d90daf
children 7e28d40db785
files src/share/classes/com/oracle/dio/spibus/impl/SPISlaveImpl.java
diffstat 1 files changed, 4 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/oracle/dio/spibus/impl/SPISlaveImpl.java	Tue Feb 03 19:20:24 2015 +0300
+++ b/src/share/classes/com/oracle/dio/spibus/impl/SPISlaveImpl.java	Wed Feb 04 13:28:50 2015 +0400
@@ -222,47 +222,17 @@
         if (0 > skip) {
             throw new IllegalArgumentException();
         }
+        checkBuffer(dst);
         return transfer(null, skip, dst);
     }
 
-    /**
-     * Writes a sequence of bytes to this slave device from the given buffer.
-     * <p />
-     * {@inheritDoc}
-     *
-     * @param src
-     *            The buffer from which bytes are to be retrieved
-     * @return The number of bytes written, possibly zero
-     * @throws NullPointerException
-     *             If {@code src} is {@code null}.
-     * @throws UnavailableDeviceException
-     *             if this peripheral is not currently available - such as it is locked by another application.
-     * @throws ClosedDeviceException
-     *             if the peripheral has been closed.
-     * @throws IOException
-     *             If some other I/O error occurs
-     */
     @Override
     public int write(ByteBuffer src) throws IOException,
             UnavailableDeviceException, ClosedDeviceException {
+        checkBuffer(src);
         return transfer(src, 0, null);
     }
 
-    /**
-     * Writes one data word of up to 32 bits to this slave device.
-     *
-     * @param txData
-     *            the data word to be written
-     * @throws IOException
-     *             if an I/O error occurred
-     * @throws InvalidWordLengthException
-     *             if the number of bytes to send belies word length; that is this slave's word length is bigger than 32
-     *             bits.
-     * @throws UnavailableDeviceException
-     *             if this peripheral is not currently available - such as it is locked by another application.
-     * @throws ClosedDeviceException
-     *             if the peripheral has been closed.
-     */
     @Override
     public void write(int txData) throws IOException,
             UnavailableDeviceException, ClosedDeviceException {
@@ -283,25 +253,11 @@
         if (0 > skip) {
             throw new IllegalArgumentException();
         }
+        checkBuffer(src);
+        checkBuffer(dst);
         return transfer(src, skip, dst);
     }
 
-    /**
-     * Exchanges (transmits and receives) one data word of up to 32 bits with this slave device.
-     *
-     * @param txData
-     *            the word to send.
-     * @return the word received.
-     * @throws IOException
-     *             if some other I/O error occurs.
-     * @throws InvalidWordLengthException
-     *             if the numbers of bytes to send or to receive bely word length; that is this slave's word length is
-     *             bigger than 32 bits.
-     * @throws UnavailableDeviceException
-     *             if this peripheral is not currently available - such as it is locked by another application.
-     * @throws ClosedDeviceException
-     *             if the peripheral has been closed.
-     */
     @Override
     public int writeAndRead(int txData) throws IOException, UnavailableDeviceException, ClosedDeviceException{
         ByteBuffer tx = int2byteArray(txData);
@@ -366,12 +322,6 @@
 
         synchronized(this) {
             checkPowerState();
-            if (null != src) {
-                checkBuffer(src);
-            }
-            if (null != dst) {
-                checkBuffer(dst);
-            }
         }
 
         int xfered = 0;