Rewrite the logic for handling multiple partitions in clogs scan

This should be more correct (and more obviously correct) in the face of
zero-sized partitions.