zbd: Avoid duplicating the code for calculating the number of sectors with data