Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f040a471 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Simplify and fix checksumAdjust.

Make the method shorter, and also make it work if oldWord or
newWord are negative.

Bug: 66928272
Test: test-only change
Change-Id: Iae991c8afc267f3c1d68529872bcd94bc6bd3cba
parent ae70143d
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -779,12 +779,7 @@ public class IpClientIntegrationTest {

    private static short checksumAdjust(short checksum, short oldWord, short newWord) {
        checksum = (short) ~checksum;
        int tempSum = checksumFold(uint16(checksum) + newWord);
        if (tempSum > oldWord) {
            tempSum -= oldWord;
        } else {
            tempSum += 0xffff - oldWord;
        }
        int tempSum = checksumFold(uint16(checksum) + uint16(newWord) + 0xffff - uint16(oldWord));
        return (short) ~tempSum;
    }