VladimirMarkelov / ttdl

TTDL - Terminal Todo List Manager
MIT License
202 stars 17 forks source link

usize in conv.rs to large for 32 bit #68

Closed iamwacko closed 1 year ago

iamwacko commented 1 year ago

ttdl will not compile for any 32 bit systems, as the usize in conv.rs will overflow on const TB.

error[E0080]: evaluation of constant value failed
--> /home/iamwacko/.cargo/registry/src/github.com-1285ae84e596aae/ttdl-3.6.2/src/conv.rs:6:19
   |
6  |   const TB: usize = GB * 1024;
   |                   ^^^^^^^^^ attempt to compute 1073741824_usize * 1024_usize, which would overflow

note: erroneous constant used
--> /home/iamwacko/.cargo/registry/src/github.com-1285ae84e596aae/ttdl-3.6.2/src/conv.rs:7:19
   |
7  |   const PB: usize = TB * 1024;
   |

note: erroneous constant used
--> /home/iamwacko/.cargo/registry/src/github.com-1285ae84e596aae/ttdl-3.6.2/src/conv.rs:8:19
   |
8  |   const EB: usize = PB * 1024;
   |
VladimirMarkelov commented 1 year ago

Thanks for the report. I switched to u64 for byte size calculations in the commit : commit 6bdab760419c0bbaf7c8ed14acb0edeb527927e2 . If it looks good, I'll update changelog and add a new tag.

iamwacko commented 1 year ago

What you have done looks great, but there is still a usize that is too large for 32 bit. RANGE_END_SKIP, found in conf.rs, is set to 8_999_999_999_998, which is larger than the usize max of 4294967295.

VladimirMarkelov commented 1 year ago

Good catch. I also found another constant in a dependency (in todo_lib) and fixed it as well. Please, try once more.

iamwacko commented 1 year ago

It works now! Thank you.

VladimirMarkelov commented 1 year ago

Great! Thanks for testing