adelolmo/hd-idle

diskstats test fail - cannot use 17004224768 (untyped int constant) as int value in struct literal (overflows)

PaulWebster opened this issue · 2 comments

Trying to build on Raspberry Pi - aarch64 - go version go1.19.3 linux/arm
Error
diskstats/snapshot_test.go:73:60: cannot use 17004224768 (untyped int constant) as int value in struct literal (overflows)

I assume this means that the "int" in the code has been compiled as 32-bit rather than 64-bit - so there might be a compiler set-up issue on my system.

Maybe they should be defined as uint64 based on
https://www.kernel.org/doc/Documentation/admin-guide/iostats.rst

Complete novice in Go here ... but I have made my own version that changes the definition of Reads and Writes to uint64 and also changed the 2 related Atoi calls to ParseUint

reads, _ := strconv.Atoi(cols[readsCol])

I think this is needed because if building on a 32-bit userspace then need to ensure that the values are 64 bit because that is how they are defined (as text) in /proc/diskstats

Created pull request
#84

Hi @PaulWebster

Given the data you present, I get to the same conclusion: use uint64 for the reads and writes.

I'm having a look to you PR.

Fixed by #84