Skip to content
Permalink
Browse files
Merge pull request #104 from arturobernalg/feature/min_max
Use Math.min and Math.max method instead of manual calculations.
  • Loading branch information
garydgregory committed Apr 30, 2022
2 parents a62115c + ca114bc commit f99b6fd645da974ec0a98db75f737ec3546a907c
Showing 3 changed files with 4 additions and 16 deletions.
@@ -164,7 +164,7 @@ public int read(final byte buffer[], int offset, final int length) throws IOExce

ch = available();

this.length = length > ch ? ch : length;
this.length = Math.min(length, ch);

// If nothing is available, block to read only one character
if (this.length < 1) {
@@ -528,10 +528,6 @@ public void sendFile(final String fileName, final int mode, final InputStream in
*/
public void setMaxTimeouts(final int numTimeouts)
{
if (numTimeouts < 1) {
maxTimeouts = 1;
} else {
maxTimeouts = numTimeouts;
}
maxTimeouts = Math.max(numTimeouts, 1);
}
}
@@ -121,11 +121,7 @@ public TFTPDataPacket(final InetAddress destination, final int port, final int b
this.data = data;
this.offset = offset;

if (length > MAX_DATA_LENGTH) {
this.length = MAX_DATA_LENGTH;
} else {
this.length = length;
}
this.length = Math.min(length, MAX_DATA_LENGTH);
}

/**
@@ -251,11 +247,7 @@ public void setData(final byte[] data, final int offset, final int length)
this.offset = offset;
this.length = length;

if (length > MAX_DATA_LENGTH) {
this.length = MAX_DATA_LENGTH;
} else {
this.length = length;
}
this.length = Math.min(length, MAX_DATA_LENGTH);
}

/**

0 comments on commit f99b6fd

Please sign in to comment.