Skip to content

Commit 56730f9

Browse files
committed
FindBugs - don't assign modulus twice
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1064428 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9ac451e commit 56730f9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/java/org/apache/commons/codec/binary/Base32.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ void encode(byte[] in, int inPos, int inAvail) { // package protected for access
344344
} else {
345345
for (int i = 0; i < inAvail; i++) {
346346
ensureBufferSize(encodeSize);
347-
modulus = (++modulus) % BYTES_PER_UNENCODED_BLOCK;
347+
modulus = (modulus+1) % BYTES_PER_UNENCODED_BLOCK;
348348
int b = in[inPos++];
349349
if (b < 0) {
350350
b += 256;
@@ -409,7 +409,7 @@ void decode(byte[] in, int inPos, int inAvail) { // package protected for access
409409
if (b >= 0 && b < this.decodeTable.length) {
410410
int result = this.decodeTable[b];
411411
if (result >= 0) {
412-
modulus = (++modulus) % BYTES_PER_ENCODED_BLOCK;
412+
modulus = (modulus+1) % BYTES_PER_ENCODED_BLOCK;
413413
bitWorkArea = (bitWorkArea << BITS_PER_ENCODED_BYTE) + result; // collect decoded bytes
414414
if (modulus == 0) { // we can output the 5 bytes
415415
buffer[pos++] = (byte) ((bitWorkArea >> 32) & MASK_8BITS);

src/java/org/apache/commons/codec/binary/Base64.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ void encode(byte[] in, int inPos, int inAvail) {
363363
} else {
364364
for (int i = 0; i < inAvail; i++) {
365365
ensureBufferSize(encodeSize);
366-
modulus = (++modulus) % BYTES_PER_UNENCODED_BLOCK;
366+
modulus = (modulus+1) % BYTES_PER_UNENCODED_BLOCK;
367367
int b = in[inPos++];
368368
if (b < 0) {
369369
b += 256;
@@ -426,7 +426,7 @@ void decode(byte[] in, int inPos, int inAvail) {
426426
if (b >= 0 && b < DECODE_TABLE.length) {
427427
int result = DECODE_TABLE[b];
428428
if (result >= 0) {
429-
modulus = (++modulus) % BYTES_PER_ENCODED_BLOCK;
429+
modulus = (modulus+1) % BYTES_PER_ENCODED_BLOCK;
430430
bitWorkArea = (bitWorkArea << BITS_PER_ENCODED_BYTE) + result;
431431
if (modulus == 0) {
432432
buffer[pos++] = (byte) ((bitWorkArea >> 16) & MASK_8BITS);

0 commit comments

Comments
 (0)