Skip to content

Commit

Permalink
8259291: Cleanup unnecessary local variables
Browse files Browse the repository at this point in the history
Reviewed-by: mullan
  • Loading branch information
XueleiFan committed Jan 6, 2021
1 parent d20d2fa commit df721f0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
6 changes: 2 additions & 4 deletions src/java.base/share/classes/sun/security/ssl/Finished.java
Expand Up @@ -265,8 +265,7 @@ public byte[] createVerifyData(HandshakeContext context,
"Invalid PRF output, format must be RAW. " +
"Format received: " + prfKey.getFormat());
}
byte[] finished = prfKey.getEncoded();
return finished;
return prfKey.getEncoded();
} catch (GeneralSecurityException e) {
throw new RuntimeException("PRF failed", e);
}
Expand Down Expand Up @@ -317,8 +316,7 @@ public byte[] createVerifyData(HandshakeContext context,
"Invalid PRF output, format must be RAW. " +
"Format received: " + prfKey.getFormat());
}
byte[] finished = prfKey.getEncoded();
return finished;
return prfKey.getEncoded();
} catch (GeneralSecurityException e) {
throw new RuntimeException("PRF failed", e);
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -474,8 +474,7 @@ private long t13Encrypt(
}

byte[] sequenceNumber = encCipher.authenticator.sequenceNumber();
int position = headerSize;
int contentLen = count - position;
int contentLen = count - headerSize;

// ensure the capacity
int requiredPacketSize =
Expand All @@ -495,7 +494,7 @@ private long t13Encrypt(
pv = ProtocolVersion.TLS12;
}

ByteBuffer destination = ByteBuffer.wrap(buf, position, contentLen);
ByteBuffer destination = ByteBuffer.wrap(buf, headerSize, contentLen);
count = headerSize + encCipher.encrypt(contentType, destination);

// Fill out the header, write it and the message.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -674,8 +674,7 @@ public String toString(
String extData;
if (stringizer == null) {
HexDumpEncoder hexEncoder = new HexDumpEncoder();
String encoded = hexEncoder.encode(byteBuffer.duplicate());
extData = encoded;
extData = hexEncoder.encode(byteBuffer.duplicate());
} else {
extData = stringizer.toString(handshakeContext, byteBuffer);
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -63,8 +63,7 @@ void encodeAlert(byte level, byte description) throws IOException {
}

// use the buf of ByteArrayOutputStream
int position = headerSize + writeCipher.getExplicitNonceSize();
count = position;
count = headerSize + writeCipher.getExplicitNonceSize();

write(level);
write(description);
Expand Down Expand Up @@ -221,8 +220,7 @@ void encodeChangeCipherSpec() throws IOException {
}

// use the buf of ByteArrayOutputStream
int position = headerSize + writeCipher.getExplicitNonceSize();
count = position;
count = headerSize + writeCipher.getExplicitNonceSize();

write((byte)1); // byte 1: change_cipher_spec(

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -30,7 +30,6 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,7 +29,6 @@
import java.nio.ByteBuffer;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import javax.net.ssl.SSLProtocolException;
Expand Down

1 comment on commit df721f0

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.