dif: Merge two code blocks into a single while loop in set_md_interleave_iovs

By clearing head_align to zero after using it, we can merge two code
blocks into a single while loop, and replace goto by simple break.

Change-Id: Ia63cd0d7dbf4b9dddf7da93e11351bb46bd04791
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454394
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-05-15 10:14:19 +09:00 committed by Jim Harris
parent 18f785bd2c
commit 1c468a0f66

View File

@ -1327,26 +1327,19 @@ spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
_dif_sgl_init(&sgl, iovs, iovcnt);
buf += offset_blocks * ctx->block_size;
if (head_unalign != 0) {
while (offset_blocks < num_blocks) {
buf += head_unalign;
if (!_dif_sgl_append(&sgl, buf, data_block_size - head_unalign)) {
goto end;
break;
}
buf += ctx->block_size - head_unalign;
offset_blocks++;
head_unalign = 0;
}
while (offset_blocks < num_blocks) {
if (!_dif_sgl_append(&sgl, buf, data_block_size)) {
goto end;
}
buf += ctx->block_size;
offset_blocks++;
}
end:
if (_mapped_len != NULL) {
*_mapped_len = sgl.total_size;
}