From 02954a37cdb98d3182fd78f6b8371be590985670 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Thu, 3 Oct 2024 10:54:35 +0200 Subject: [PATCH] [Minor] #388 Add braces to satisfy coding guidelines --- pi4j-core/src/main/java/com/pi4j/io/i2c/I2C.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2C.java b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2C.java index 77da9ebd..ce4b5ff2 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2C.java +++ b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2C.java @@ -133,26 +133,31 @@ default int writeRead(byte[] writeBuffer, int writeSize, int writeOffset, byte[] int readOffset) { // Check bounds for writeBuffer - if (writeOffset < 0) + if (writeOffset < 0) { throw new IndexOutOfBoundsException("Write offset cannot be negative!"); - if (writeOffset + writeSize > writeBuffer.length) + } + if (writeOffset + writeSize > writeBuffer.length) { throw new IndexOutOfBoundsException( String.format("Write operation out of bounds. Write buffer length is %d. Yet write offset + size is=%d", writeBuffer.length, writeOffset + writeSize)); + } // Check bounds for readBuffer - if (readOffset < 0) + if (readOffset < 0) { throw new IndexOutOfBoundsException("Read offset cannot be negative!"); - if (readOffset + readSize > readBuffer.length) + } + if (readOffset + readSize > readBuffer.length) { throw new IndexOutOfBoundsException( String.format("Read operation out of bounds. Read buffer length is %d. Yet read offset + size is=%d", readBuffer.length, readOffset + readSize)); + } return execute(() -> { int written = write(writeBuffer, writeOffset, writeSize); - if (written != writeSize) + if (written != writeSize) { throw new IllegalStateException( "Expected to write " + writeSize + " bytes but only wrote " + written + " bytes"); + } return read(readBuffer, readOffset, readSize); }); }