Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: diskfs/go-diskfs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 210533cce143b349fc986547e43559bdd35bd4a6
Choose a base ref
..
head repository: diskfs/go-diskfs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a4ce2edf13b2dfddddca7b594fc63def0bb2322d
Choose a head ref
Showing with 6 additions and 6 deletions.
  1. +6 −6 filesystem/ext4/checksum.go
12 changes: 6 additions & 6 deletions filesystem/ext4/checksum.go
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ func crc32c(base uint32, b []byte) uint32 {
// Compute the CRC32C checksum
// for reasons unknown, the checksum from go package hash/crc32, using crc32.Update(), is different from the one calculated by the kernel
// so we use this
return crc32Body(base, b, crc32cTables)
return crc32Body(base, b, &crc32cTables)
}

// doCRC processes a single byte
@@ -68,16 +68,16 @@ func doCRC(crc uint32, x byte, tab *[256]uint32) uint32 {
}

// doCRC4 processes 4 bytes
func doCRC4(crc, q uint32, tab *[8][256]uint32) uint32 {
func doCRC4(q uint32, tab *[8][256]uint32) uint32 {
return tab[3][q&0xff] ^ tab[2][(q>>8)&0xff] ^ tab[1][(q>>16)&0xff] ^ tab[0][(q>>24)&0xff]
}

// doCRC8 processes 8 bytes
func doCRC8(crc, q uint32, tab *[8][256]uint32) uint32 {
func doCRC8(q uint32, tab *[8][256]uint32) uint32 {
return tab[7][q&0xff] ^ tab[6][(q>>8)&0xff] ^ tab[5][(q>>16)&0xff] ^ tab[4][(q>>24)&0xff]
}

func crc32Body(crc uint32, buf []byte, tab [8][256]uint32) uint32 {
func crc32Body(crc uint32, buf []byte, tab *[8][256]uint32) uint32 {
// Align it
for len(buf) > 0 && (uintptr(len(buf))&3) != 0 {
crc = doCRC(crc, buf[0], &tab[0])
@@ -88,9 +88,9 @@ func crc32Body(crc uint32, buf []byte, tab [8][256]uint32) uint32 {
remLen := len(buf) % 8
for len(buf) >= 8 {
q := crc ^ binary.LittleEndian.Uint32(buf[:4])
crc = doCRC8(crc, q, &tab)
crc = doCRC8(q, tab)
q = binary.LittleEndian.Uint32(buf[4:8])
crc ^= doCRC4(crc, q, &tab)
crc ^= doCRC4(q, tab)
buf = buf[8:]
}