On 24/05/2016 15:39, Peter Lieven wrote: > bytes += offset & (align - 1); > offset = offset & ~(align - 1);
Because the low bits have been masked away from offset and added to bytes, > + > + /* if head and tail fall into the same alignment > + * we can omit the second read as it would read > + * the same block again */ > + if ((offset + bytes) & (align - 1) && ... the first part is just "bytes & (align - 1)"... > + offset / align == (offset + bytes) / align) { ... and the second part is just "bytes < align" (you can distribute division over addition because offset / align has no reminder, and simplify to "0 == bytes / align"). Putting it together, it becomes "bytes > 0 && bytes < align", or even "bytes < align". Thanks, Paolo > + size_t tail_offs; > + tail_offs = (offset + bytes) & (align - 1); > + qemu_iovec_add(&local_qiov, head_buf + tail_offs, > + align - tail_offs); > + bytes += align - tail_offs; > + }