changeset 213:a2c106aa4c74

8131152: A copy GPIOPortConfig instance is not equal to original one Summary: Added null verification Reviewed-by: snazarki Contributed-by: alexey.savin@oracle.com
author snazarki
date Tue, 14 Jul 2015 15:46:19 +0300
parents 2c0af8cb3202
children 9cc5a10cf711
files src/se/linux/native/com/oracle/dio/rs485_enabler.cpp src/share/classes/jdk/dio/counter/PulseCounterConfig.java
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/se/linux/native/com/oracle/dio/rs485_enabler.cpp	Mon Jul 13 21:30:27 2015 +0300
+++ b/src/se/linux/native/com/oracle/dio/rs485_enabler.cpp	Tue Jul 14 15:46:19 2015 +0300
@@ -51,8 +51,10 @@
     memset(&rs485conf, 0x0, sizeof(struct serial_rs485));
     /* Enable RS485 mode */
     rs485conf.flags |= SER_RS485_ENABLED;
-    /* Set logical level for RTS pin equal to 1 when sending */
-    rs485conf.flags |= SER_RS485_RTS_ON_SEND;
+    if (rts_on_send) {
+        /* Set logical level for RTS pin equal to 1 when sending */
+        rs485conf.flags |= SER_RS485_RTS_ON_SEND;
+    }
     /* need some field test to detect whether this value is necessary */
     rs485conf.delay_rts_before_send = 0x00000001;
     if (ioctl (handle, TIOCSRS485, &rs485conf) < 0) {
--- a/src/share/classes/jdk/dio/counter/PulseCounterConfig.java	Mon Jul 13 21:30:27 2015 +0300
+++ b/src/share/classes/jdk/dio/counter/PulseCounterConfig.java	Tue Jul 14 15:46:19 2015 +0300
@@ -209,7 +209,9 @@
          * {@code null} and is not configured for input.
          */
         public Builder setSourceConfig(GPIOPinConfig source) {
-            checkSourceConfig(source);
+            if (null != source) {
+                checkSourceConfig(source);
+            }
             instance.sourceConfig = source;
             return this;
         }
@@ -502,7 +504,8 @@
     }
 
     private static void checkSourceConfig(GPIOPinConfig sourceConfig) {
-        if  ((sourceConfig.getDirection() !=  GPIOPinConfig.DIR_INPUT_ONLY && sourceConfig.getDirection() !=  GPIOPinConfig.DIR_BOTH_INIT_INPUT)) {
+        if  (sourceConfig.getDirection() != GPIOPinConfig.DIR_INPUT_ONLY &&
+            sourceConfig.getDirection() != GPIOPinConfig.DIR_BOTH_INIT_INPUT) {
             throw new IllegalArgumentException(ExceptionMessage.format(ExceptionMessage.COUNTER_CONFIG_CANNOT_BE_USED));
         }
     }
@@ -514,7 +517,7 @@
         // rising and falling edges
         if (null != sourceConfig) {
             int trigger = sourceConfig.getTrigger();
-            if (((trigger >> 1) != type &&
+            if (((trigger >>> 1) != type &&
                 // When the pulse source is a GPIO pin  then this pulse edge type can only be used if the pin is configured with the
                 // GPIOPinConfig#TRIGGER_BOTH_EDGES trigger mode
                 (type > TYPE_RISING_EDGE_ONLY && trigger != GPIOPinConfig.TRIGGER_BOTH_EDGES))) {