Skip to content

tor-basic-utils: Change ByteQty from usize to u64

(Edit: Was previously titled "tor-basic-utils: Support `ByteQty` integers that are one byte higher than `usize::MAX`")

The ByteQty is used by tor-memquota (and likely others in the future) for reading byte quantities from the configuration toml. This is a wrapper around a usize.

On 32-bit systems, a user may want to set a value of "4 GiB" in the toml, but this value can't be represented by a 32-bit usize. Currently if a user specifies "4 GiB" on 32-bit systems it causes an error when parsing the config. I think it would be useful if we added a special case, where a value corresponding to usize::MAX + 1 is interpreted as usize::MAX.

Alternatively, maybe ByteQty should just be a u64. Otherwise we can't reuse ByteQty for things that are not bounded by the system's pointer width. For example file sizes aren't bounded by the size of usize, so if we had an arti config option that was something like "rotate log file when it has exceeded X bytes", it wouldn't make sense for X to be bounded to 32 bits.

Edited by opara