Skip to content

Commit

Permalink
Merge pull request #1358 from pjonsson/remove-parens
Browse files Browse the repository at this point in the history
Remove unnecessary parentheses
  • Loading branch information
nfi authored Oct 30, 2023
2 parents a2c9c76 + 0654ee0 commit b4dd278
Show file tree
Hide file tree
Showing 29 changed files with 52 additions and 62 deletions.
10 changes: 0 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,9 @@ tasks.withType(JavaCompile).configureEach {
// Uncomment the next two lines and the disable line to generate a patch.
//options.errorprone.errorproneArgs = ['-XepPatchChecks:MissingOverride',
// '-XepPatchLocation:' + buildscript.sourceFile.getParent()]
options.errorprone.disable('AddressSelection')
options.errorprone.disable('AlmostJavadoc')
options.errorprone.disable('AnnotateFormatMethod')
options.errorprone.disable('ByteBufferBackingArray')
options.errorprone.disable('CatchAndPrintStackTrace')
options.errorprone.disable('ComparisonOutOfRange')
options.errorprone.disable('DefaultCharset')
options.errorprone.disable('DoubleCheckedLocking')
options.errorprone.disable('EmptyBlockTag')
Expand All @@ -123,26 +120,19 @@ tasks.withType(JavaCompile).configureEach {
options.errorprone.disable('ImmutableEnumChecker')
options.errorprone.disable('InconsistentCapitalization')
options.errorprone.disable('InlineMeSuggester')
options.errorprone.disable('InvalidBlockTag')
options.errorprone.disable('JavaTimeDefaultTimeZone')
options.errorprone.disable('JavaUtilDate')
options.errorprone.disable('JdkObsolete')
options.errorprone.disable('MissingCasesInEnumSwitch')
options.errorprone.disable('MissingOverride')
options.errorprone.disable('MissingSummary')
options.errorprone.disable('MutablePublicArray')
options.errorprone.disable('NarrowCalculation')
options.errorprone.disable('NarrowingCompoundAssignment')
options.errorprone.disable('NonApiType')
options.errorprone.disable('OperatorPrecedence')
options.errorprone.disable('ReferenceEquality')
options.errorprone.disable('ShortCircuitBoolean')
options.errorprone.disable('StaticAssignmentInConstructor')
options.errorprone.disable('StringCaseLocaleUsage')
options.errorprone.disable('StringSplitter')
options.errorprone.disable('ThreadPriorityCheck')
options.errorprone.disable('UnnecessaryLambda')
options.errorprone.disable('UnnecessaryParentheses')
options.errorprone.disable('UnusedMethod')
options.errorprone.disable('UnusedVariable')
options.compilerArgs += ['-Werror', '--enable-preview',
Expand Down
2 changes: 1 addition & 1 deletion java/org/contikios/cooja/dialogs/SerialUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ protected static void appendToTextArea(JTextArea textArea, String text) {
}

private static String trim(String text) {
return (text != null) && (!(text = text.trim()).isEmpty()) ? text : null;
return (text != null) && !(text = text.trim()).isEmpty() ? text : null;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions java/org/contikios/cooja/mspmote/interfaces/GCRCoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ boolean gcr_valid() {
if (gcr_bits >= 10) {
int val = gcr_val & 0x3ff;
return (GCR_decode[val >> 5] << 4) != 0xff
&& (GCR_decode[val & 0x1f]) != 0xff;
&& GCR_decode[val & 0x1f] != 0xff;
}
return true;
}
Expand All @@ -116,7 +116,7 @@ boolean gcr_valid() {
boolean gcr_get_decoded(int[] raw_data, int current_pos) {
if (gcr_bits >= 10) {
int val = gcr_val & 0x3ff;
raw_data[current_pos] = ((GCR_decode[val >> 5] << 4) | (GCR_decode[val & 0x1f]));
raw_data[current_pos] = ((GCR_decode[val >> 5] << 4) | GCR_decode[val & 0x1f]);
gcr_val = gcr_val >> 10;
gcr_bits = gcr_bits - 10;
return true;
Expand Down
2 changes: 1 addition & 1 deletion java/org/contikios/cooja/mspmote/plugins/MspCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void closePlugin() {
}

private static String trim(String text) {
return (text != null) && (!(text = text.trim()).isEmpty()) ? text : null;
return (text != null) && !(text = text.trim()).isEmpty() ? text : null;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion java/org/contikios/cooja/plugins/LogListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ public boolean appendToFile(File file, String text) {
/* Append to file */
if (!appendToFileWroteHeader) {
appendStream.println("-- Log Listener [" + simulation.getTitle() + "]: Started at " +
(ZonedDateTime.now(ZoneId.systemDefault()).format(DateTimeFormatter.RFC_1123_DATE_TIME)));
ZonedDateTime.now(ZoneId.systemDefault()).format(DateTimeFormatter.RFC_1123_DATE_TIME));
appendToFileWroteHeader = true;
}
appendStream.print(text);
Expand Down
4 changes: 2 additions & 2 deletions java/org/contikios/cooja/plugins/Visualizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1213,13 +1213,13 @@ protected void resetViewport() {
scaleX = 1;
}
else {
scaleX = (bigX - smallX) / (canvas.getWidth());
scaleX = (bigX - smallX) / canvas.getWidth();
}
if (smallY == bigY) {
scaleY = 1;
}
else {
scaleY = (bigY - smallY) / (canvas.getHeight());
scaleY = (bigY - smallY) / canvas.getHeight();
}

viewportTransform.setToIdentity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void paintBeforeMotes(Graphics g) {

private static String getMoteString(Mote mote) {
IPAddress ipAddr = mote.getInterfaces().getIPAddress();
if ((ipAddr != null) && (ipAddr.hasIP())) {
if ((ipAddr != null) && ipAddr.hasIP()) {
if (ipAddr.getLocalIP() == null) {
return "";
}
Expand Down
8 changes: 4 additions & 4 deletions java/org/contikios/mrm/AreaViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ private boolean analyzeBitmapForObstacles() {

int foundObstacles = 0;
for (int x = 0; x < obstacleArray.length; x++) {
for (int y = 0; y < (obstacleArray[0]).length; y++) {
for (int y = 0; y < obstacleArray[0].length; y++) {
if (obstacleArray[x][y]) { // Register obstacle.
double realWidth = (boxSize * backgroundWidth) / backgroundImage.getWidth(null);
double realHeight = (boxSize * backgroundHeight) / backgroundImage.getHeight(null);
Expand Down Expand Up @@ -904,8 +904,8 @@ public void mouseDragged(MouseEvent e) {

// Pan relative to mouse movement and current zoom
// This way the mouse "lock" to the canvas
currentPanX += ((e.getX() - lastHandledPosition.x)) / currentZoomX;
currentPanY += ((e.getY() - lastHandledPosition.y)) / currentZoomY;
currentPanX += (e.getX() - lastHandledPosition.x) / currentZoomX;
currentPanY += (e.getY() - lastHandledPosition.y) / currentZoomY;
lastHandledPosition = e.getPoint();

canvas.repaint();
Expand All @@ -927,7 +927,7 @@ public void mouseDragged(MouseEvent e) {
}

// Zoom relative to mouse movement (keep XY-proportions)
currentZoomY += 0.005 * currentZoomY * ((lastHandledPosition.y - e.getY()));
currentZoomY += 0.005 * currentZoomY * (lastHandledPosition.y - e.getY());
currentZoomY = Math.max(0.05, currentZoomY);
currentZoomX = currentZoomY = Math.min(1500, currentZoomY);

Expand Down
2 changes: 1 addition & 1 deletion java/org/contikios/mrm/MRM.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ protected void updateSignalStrengths() {

/* Reset: Background noise */
double background =
currentChannelModel.getParameterDoubleValue((Parameter.bg_noise_mean));
currentChannelModel.getParameterDoubleValue(Parameter.bg_noise_mean);
for (Radio radio : getRegisteredRadios()) {
radio.setCurrentSignalStrength(background);
}
Expand Down
2 changes: 1 addition & 1 deletion java/se/sics/mspsim/chip/Beeper.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void initSound() {
for (int i = 0; i < WAVE_LEN; i++) {
double f1 = Math.sin(i * 3.141592 * 2 / WAVE_LEN) * 40;
f1 += Math.sin(i * 3.141592 * 4 / WAVE_LEN) * 30;
buf[i] = (byte) (f1);
buf[i] = (byte) f1;
}
buffer = buf;
}
Expand Down
8 changes: 4 additions & 4 deletions java/se/sics/mspsim/chip/CC1101.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ void txNext() {
if (txSendSynchByteCnt < NUM_PREAMBLE) {
txSendSynchByteCnt++;
if (rfListener != null) {
rfListener.receivedByte((byte) (0xaa));
rfListener.receivedByte((byte) 0xaa);
}
cpu.scheduleTimeEventMillis(sendEvent, getInterByteDelayMs());
return;
Expand Down Expand Up @@ -564,7 +564,7 @@ void txNext() {
if (txSentFirstCRC) {
/* send second CRC byte */
if (rfListener != null) {
rfListener.receivedByte((byte) (0xef));
rfListener.receivedByte((byte) 0xef);
}
if (!txfifo.isEmpty()) {
System.out.println("Warning: TXFIFO not empty after sending CRC bytes");
Expand All @@ -581,7 +581,7 @@ void txNext() {
if (txFooterCountdown == 0) {
/* countdown is zero, send first CRC byte */
if (rfListener != null) {
rfListener.receivedByte((byte) (0xee));
rfListener.receivedByte((byte) 0xee);
}
txSentFirstCRC = true;
cpu.scheduleTimeEventMillis(sendEvent, getInterByteDelayMs());
Expand All @@ -601,7 +601,7 @@ void txNext() {
}

if (rfListener != null) {
rfListener.receivedByte((byte) (txfifo.get(0).intValue()));
rfListener.receivedByte((byte) txfifo.get(0).intValue());
}
txfifo.remove(0);
cpu.scheduleTimeEventMillis(sendEvent, getInterByteDelayMs());
Expand Down
10 changes: 5 additions & 5 deletions java/se/sics/mspsim/chip/CC1120.java
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ void txNext() {
if (txSendSynchByteCnt < NUM_PREAMBLE) {
txSendSynchByteCnt++;
if (rfListener != null) {
rfListener.receivedByte((byte) (0xaa));
rfListener.receivedByte((byte) 0xaa);
}
cpu.scheduleTimeEventMillis(sendEvent, BITRATE_BYTE_DURATION);
return;
Expand Down Expand Up @@ -759,7 +759,7 @@ void txNext() {
if (txSentFirstCRC) {
/* send second CRC byte */
if (rfListener != null) {
rfListener.receivedByte((byte) (0xef));
rfListener.receivedByte((byte) 0xef);
}
if (!txfifo.isEmpty()) {
System.out.println("Warning: TXFIFO not empty after sending CRC bytes");
Expand All @@ -777,7 +777,7 @@ void txNext() {
if (txFooterCountdown == 0) {
/* countdown is zero, send first CRC byte */
if (rfListener != null) {
rfListener.receivedByte((byte) (0xee));
rfListener.receivedByte((byte) 0xee);
}
txSentFirstCRC = true;
cpu.scheduleTimeEventMillis(sendEvent, BITRATE_BYTE_DURATION);
Expand All @@ -795,7 +795,7 @@ void txNext() {
}

if (rfListener != null) {
rfListener.receivedByte((byte) (txfifo.get(0).intValue()));
rfListener.receivedByte((byte) txfifo.get(0).intValue());
}
txfifo.remove(0);
cpu.scheduleTimeEventMillis(sendEvent, BITRATE_BYTE_DURATION);
Expand Down Expand Up @@ -869,7 +869,7 @@ boolean setState(final CC1120RadioState newState) {
&& newState == CC1120RadioState.CC1120_STATE_RX
|| newState == CC1120RadioState.CC1120_STATE_TX) {
changeFrequencyNextState = false;
frequency = ((0xff & nextFreq0)) + ((0xff & nextFreq1) << 8)
frequency = (0xff & nextFreq0) + ((0xff & nextFreq1) << 8)
+ ((0xff & nextFreq2) << 16);

frequency *= 32; /* frequency oscillator */
Expand Down
2 changes: 1 addition & 1 deletion java/se/sics/mspsim/chip/CC2520.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public void setPolarity(boolean polarity) {
// public static final int CCAMUX_XOSC16M_STABLE = 24;

// FRMFILT0/FRMCTRL0 values
public static final int FRAME_FILTER = (1);
public static final int FRAME_FILTER = 1;
public static final int AUTOCRC = (1 << 6);
public static final int AUTOACK = (1 << 5);

Expand Down
2 changes: 1 addition & 1 deletion java/se/sics/mspsim/chip/M25P80.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void dataReceived(USARTSource source, int data) {
} else {
// Do the programming!!!
source.byteReceived(0);
writeBuffer((readAddress++) & 0xff, data);
writeBuffer(readAddress++ & 0xff, data);
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion java/se/sics/mspsim/core/AES128.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected void log(final String format, final Object... arguments) {
@Override
public void write(int address, int value, boolean word, long cycles) {
log("write @ %x <-- %x (word=%b)\n", address, value, word);
int lo = (value) & 0xff; // low byte
int lo = value & 0xff; // low byte
int hi = (value >> 8) & 0xff; // high byte

switch (address - offset) {
Expand Down
4 changes: 2 additions & 2 deletions java/se/sics/mspsim/core/CRC16.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void write(int address, int value, boolean word, long cycles) {
case CRC16.CRCDI:
if (word) {
int hi = (value >> 8) & 0x00ff;
int lo = (value) & 0x00ff;
int lo = value & 0x00ff;
crc.processRb((byte) lo);
crc.processRb((byte) hi);
} else {
Expand All @@ -221,7 +221,7 @@ public void write(int address, int value, boolean word, long cycles) {
case CRC16.CRCDIRB:
if (word) {
int hi = (value >> 8) & 0x00ff;
int lo = (value) & 0x00ff;
int lo = value & 0x00ff;
crc.process((byte) hi);
crc.process((byte) lo);
} else {
Expand Down
8 changes: 4 additions & 4 deletions java/se/sics/mspsim/core/IOPort.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private void writePort(PortReg function, int data, long cycles) {
out = data;
PortListener listener = portListener;
if (listener != null) {
listener.portWrite(this, out | (~dir) & 0xff);
listener.portWrite(this, out | ~dir & 0xff);
}
break;
}
Expand All @@ -269,7 +269,7 @@ private void writePort(PortReg function, int data, long cycles) {
PortListener listener = portListener;
if (listener != null) {
// Any output configured pin (pin-bit = 0) should have 1 here?!
listener.portWrite(this, out | (~dir) & 0xff);
listener.portWrite(this, out | ~dir & 0xff);
}
break;
}
Expand Down Expand Up @@ -404,7 +404,7 @@ public void setPinState(int pin, PinState state) {

@Override
public void reset(int type) {
int oldValue = out | (~dir) & 0xff;
int oldValue = out | ~dir & 0xff;

Arrays.fill(pinState, PinState.LOW);
in = 0;
Expand All @@ -416,7 +416,7 @@ public void reset(int type) {
cpu.flagInterrupt(interrupt, this, (ifg & ie) > 0);

PortListener listener = portListener;
int newValue = out | (~dir) & 0xff;
int newValue = out | ~dir & 0xff;
if (oldValue != newValue && listener != null) {
listener.portWrite(this, newValue);
}
Expand Down
4 changes: 2 additions & 2 deletions java/se/sics/mspsim/core/MSP430Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ public int emulateOP(long maxCycles) throws EmulationException {
nxtCarry = (dst & (1 << (count + 1))) > 0? CARRY: 0;

/* Rotate dst. */
dst = dst >> (count);
dst = dst >> count;

/* Rotate the high bits, insert into dst. */
if (rrword) {
Expand Down Expand Up @@ -2013,7 +2013,7 @@ public int emulateOP(long maxCycles) throws EmulationException {
break;
case BIC: // BIC
// No status reg change
dst = (~src) & dst;
dst = ~src & dst;

write = true;
updateStatus = false;
Expand Down
4 changes: 2 additions & 2 deletions java/se/sics/mspsim/core/RF1A.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ public void write(int address, int value, boolean word, long cycles) {
ioRead = false;
ioWrite = false;
expectingDummyWrite = true;
cc1101.strobe(value & (~CC1101.SPI_READ_BIT) & (~CC1101.SPI_BURST_BIT));
cc1101.strobe(value & ~CC1101.SPI_READ_BIT & ~CC1101.SPI_BURST_BIT);
} else {
/* Store address */
ioRead = CC1101.spiIsRead(value);
ioWrite = !ioRead;
cc1101.setLastInstructionWasRead(ioRead);
ioAddress = value & (~CC1101.SPI_READ_BIT) & (~CC1101.SPI_BURST_BIT);
ioAddress = value & ~CC1101.SPI_READ_BIT & ~CC1101.SPI_BURST_BIT;
if (DEBUG) {
if (ioAddress == CC1101.CC1101_RXFIFO) {
} else if (ioAddress == CC1101.CC1101_MARCSTATE) {
Expand Down
4 changes: 2 additions & 2 deletions java/se/sics/mspsim/core/RTC.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void updateCounters() {

} else {
rtcCount += 1;
long overflow = ((1L << ((rtcEvent + 1) * 8)));
long overflow = (1L << ((rtcEvent + 1) * 8));
overflow -= 1;
if ((rtcCount & overflow) == 0) {
generateInterrupt();
Expand Down Expand Up @@ -486,7 +486,7 @@ public void write(int address, int value, boolean word, long cycles) {
logw(WarningType.MISALIGNED_WRITE, "byte access not implemented");
}

int lo = (value) & 0xff; // low byte
int lo = value & 0xff; // low byte
int hi = (value >> 8) & 0xff; // high byte

switch (address - offset) {
Expand Down
4 changes: 2 additions & 2 deletions java/se/sics/mspsim/core/Timer.java
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ void resetCounter(long cycles) {
// counterAcc - represent the value of the counter at the last reset.
long cycctr = cycles - counterStart;
double tick = cycctr / divider;
counterPassed = (int) (divider * (tick - (long) (tick)));
counterPassed = (int) (divider * (tick - (long) tick));

counterStart = cycles - counterPassed;
// set counterACC to the last returned value (which is the same
Expand Down Expand Up @@ -851,7 +851,7 @@ private int updateCounter(long cycles) {
// counterAcc - represent the value of the counter at the last reset.
long cycctr = cycles - counterStart;
double tick = cycctr / divider;
counterPassed = (int) (divider * (tick - (long) (tick)));
counterPassed = (int) (divider * (tick - (long) tick));
long bigCounter = (long) (tick + counterAcc);

switch (mode) {
Expand Down
2 changes: 1 addition & 1 deletion java/se/sics/mspsim/core/UnifiedClockSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ private void setConfiguration(long cycles) {
int dcoTap = ((read(UCSCTL0, true, cycles) >> DCO_BITPOS) & ((1 << DCO_BITWIDTH) - 1));

// Read modulation disable bit (currently unused)
int disableModulation = ((read(UCSCTL1, true, cycles) & DISMOD));
int disableModulation = read(UCSCTL1, true, cycles) & DISMOD;

// Read DCO range selection from UCSCTL1 register
int dcoRange = ((read(UCSCTL1, true, cycles) >> DCORSEL_BITPOS) & ((1 << DCORSEL_BITWIDTH) - 1));
Expand Down
Loading

0 comments on commit b4dd278

Please sign in to comment.