Skip to content

Commit

Permalink
Declare and initialize local variables at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Jun 24, 2023
1 parent 8198c66 commit 355f4f2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/main/java/org/apache/commons/net/time/TimeUDPClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,13 @@ public long getTime(final InetAddress host) throws IOException {
* @throws IOException If an error occurs while retrieving the time.
*/
public long getTime(final InetAddress host, final int port) throws IOException {
long time;
final DatagramPacket sendPacket;
final DatagramPacket receivePacket;

sendPacket = new DatagramPacket(dummyData, dummyData.length, host, port);
receivePacket = new DatagramPacket(timeData, timeData.length);
final DatagramPacket sendPacket = new DatagramPacket(dummyData, dummyData.length, host, port);
final DatagramPacket receivePacket = new DatagramPacket(timeData, timeData.length);

checkOpen().send(sendPacket);
checkOpen().receive(receivePacket);

time = 0L;
long time = 0L;
time |= (((timeData[0] & 0xff) << 24) & 0xffffffffL);
time |= (((timeData[1] & 0xff) << 16) & 0xffffffffL);
time |= (((timeData[2] & 0xff) << 8) & 0xffffffffL);
Expand Down

0 comments on commit 355f4f2

Please sign in to comment.