Re: [PATCH] shmem: skip empty unmap ranges when punching holes
From: Hungyu Lin
Date: Tue Nov 03 2026 - 15:01:31 EST
> To be clear, I was asking whether we could do
>
> if ((u64)(unmap_end) >= (u64)unmap_start)
Sorry, I misunderstood your suggestion.
With offset = 0 and len = 1, unmap_end is -1 and unmap_start is 0.
Casting -1 to u64 makes this comparison true, so it still passes
a zero length to unmap_mapping_range(), meaning unmap to EOF.
The +1 turns -1 into 0 before the cast, so the submitted check
becomes 0 > 0 and skips the empty range.
Thanks,
Hungyu