On Wed, 2025-11-19 at 12:36 +0900, Alexandre Courbot wrote: > You can use the `Alignment` type here, as the rest of the code does: > > let size = num::usize_as_u64(obj.size()) > .align_up(Alignment::new::<GSP_PAGE_SIZE>())?; > > Now `align_up` returns an error in case of overflow, that we will need > to pass down to the caller by changing the return type of `new`. It is a > bit annoying, but better than the behavior of `next_mutiple_of` in such > a case, which is to panic. :)
I see your point, but these are u64s that we're talking about. The only way next_mutiple_of() can panic is if obj.size() is greater than 0xFFFFFFFFFFFFF000, which is not possible. I would say in this case, a panic is preferable to a convoluted error return that will never be exercised, because failure here indicates a coding error, not an input error.
