Skip to content

Commit

Permalink
refine int cast long
Browse files Browse the repository at this point in the history
  • Loading branch information
XenoAmess committed Jul 15, 2022
1 parent 8fbe396 commit 450c2b7
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void readNext(byte b1) throws IOException {
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++;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void test62872() throws Exception {
cell = row.createCell(j - 1);

//make some noise
cell.setCellValue(new Date(i * TEN_MINUTES + (j * TEN_MINUTES) / COLUMN_COUNT));
cell.setCellValue(new Date((long) i * TEN_MINUTES + (j * TEN_MINUTES) / COLUMN_COUNT));
}
i++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public long init(LittleEndianInputStream leis, long dataSize, EmfPlusObjectType

// A string of Length Unicode characters that contains the name of the font family.
family = StringUtil.readUnicodeLE(leis, len);
size += len*LittleEndianConsts.SHORT_SIZE;
size += (long) len *LittleEndianConsts.SHORT_SIZE;

return size;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
public final class Notes extends SheetContainer
{
private byte[] _header;
private static long _type = 1008l;
private static long _type = 1008L;

// Links to our more interesting children
private NotesAtom notesAtom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
public final class NotesAtom extends RecordAtom {

private byte[] _header;
private static long _type = 1009l;
private static long _type = 1009L;

private int slideID;
private boolean followMasterObjects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
public final class Slide extends SheetContainer
{
private byte[] _header;
private static long _type = 1006l;
private static long _type = 1006L;

// Links to our more interesting children
private SlideAtom slideAtom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class SlideAtom extends RecordAtom {
// private static final int MASTER_SLIDE_ID = 0x00000000;

private byte[] _header;
private static long _type = 1007l;
private static long _type = 1007L;

private int masterID;
private int notesID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class SlidePersistAtom extends RecordAtom {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 32;

private static final long _type = 1011l;
private static final long _type = 1011L;
private static final int HAS_SHAPES_OTHER_THAN_PLACEHOLDERS = 4;

private static final int[] FLAGS_MASKS = { HAS_SHAPES_OTHER_THAN_PLACEHOLDERS };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void record(Chunk chunk) {
// Work out what MAPIProperty this corresponds to
MAPIProperty prop = MAPIProperty.get(chunk.getChunkId());
if (prop == MAPIProperty.UNKNOWN) {
long id = (chunk.getChunkId() << 16) + (long)chunk.getType().getId();
long id = ((long) chunk.getChunkId() << 16) + (long)chunk.getType().getId();
prop = unknownProperties.get(id);
if (prop == null) {
prop = MAPIProperty.createCustom(chunk.getChunkId(), chunk.getType(), chunk.getEntryName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private long getStreamID(int propertyKind, int nameOffset, ClassID guid, int gui
Consumer<String> propertyNameSetter, Consumer<Long> propertyNameCRC32Setter) {
if (propertyKind == 0) {
// numerical named property
return 0x1000L + (nameOffset ^ (guidIndex << 1)) % 0x1F;
return 0x1000L + (nameOffset ^ ((long) guidIndex << 1)) % 0x1F;
}

// string named property
Expand All @@ -250,7 +250,7 @@ private long getStreamID(int propertyKind, int nameOffset, ClassID guid, int gui
propertyNameCRC32Setter.accept(propertyNameCRC32);
}
}
return 0x1000 + (propertyNameCRC32 ^ ((guidIndex << 1) | 1)) % 0x1F;
return 0x1000 + (propertyNameCRC32 ^ (((long) guidIndex << 1) | 1)) % 0x1F;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public final class TestDocumentEncryptionAtom {
@Test
void recordType() throws IOException {
DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
assertEquals(12052l, dea1.getRecordType());
assertEquals(12052L, dea1.getRecordType());

DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
assertEquals(12052l, dea2.getRecordType());
assertEquals(12052L, dea2.getRecordType());

assertEquals(199, data_a.length);
assertEquals(198, data_b.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void testRealFile() throws Exception {
// Get the ExObjList
ExObjList exObjList = doc.getExObjList(false);
assertNotNull(exObjList);
assertEquals(1033l, exObjList.getRecordType());
assertEquals(1033L, exObjList.getRecordType());

// Check the atom
assertNotNull(exObjList.getExObjListAtom());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public long readLong(){
((long)b5 << 40) +
((long)b4 << 32) +
((long)b3 << 24) +
(b2 << 16) +
(b1 << 8) +
((long) b2 << 16) +
((long) b1 << 8) +
(b0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void nextChunk() throws GeneralSecurityException, IOException {
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");
}
Expand Down

0 comments on commit 450c2b7

Please sign in to comment.