From ad6af709b8bba90512f51319f63966fdc9619592 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 17 Jul 2022 09:30:21 +0000 Subject: [PATCH] [github-348] tidy up number casting git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902803 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java | 4 ++-- .../apache/poi/hssf/record/cont/ContinuableRecordInput.java | 4 ++-- .../org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java index 7786b22663..8822053180 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java @@ -92,7 +92,7 @@ public abstract class XSSFBParser { b2 &= ~(1<<7); //unset highest bit (if it exists?) recordId = ((int)b2 << 7)+(int)b1; } else { - recordId = (int)b1; + recordId = b1; } long recordLength = 0; @@ -102,7 +102,7 @@ public abstract class XSSFBParser { byte b = is.readByte(); halt = (b >> 7 & 1) == 0; //if highest bit !=1 then continue b &= ~(1<<7); - recordLength += (int)b << (i*7); //multiply by 128^i + recordLength += (long) (int)b << (i*7); //multiply by 128^i i++; } diff --git a/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecordInput.java b/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecordInput.java index 5f50b584bc..401143b987 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecordInput.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecordInput.java @@ -101,8 +101,8 @@ public class ContinuableRecordInput implements LittleEndianInput { ((long)b5 << 40) + ((long)b4 << 32) + ((long)b3 << 24) + - (b2 << 16) + - (b1 << 8) + + ((long)b2 << 16) + + ((long)b1 << 8) + (b0)); } diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java b/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java index a1c7cd4984..ea3159c911 100644 --- a/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java +++ b/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java @@ -172,11 +172,11 @@ public abstract class ChunkedCipherInputStream extends LittleEndianInputStream { private void nextChunk() throws GeneralSecurityException, IOException { if (chunkSize != -1) { - int index = (int)(pos >> chunkBits); + int index = (int) (pos >> chunkBits); initCipherForBlock(cipher, index); if (lastIndex != index) { - long skipN = (index - lastIndex) << chunkBits; + long skipN = ((long) index - lastIndex) << chunkBits; if (super.skip(skipN) < skipN) { throw new EOFException("buffer underrun"); }