Commit 1c468a0f authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454394


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 18f785bd
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -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++;
	}

	while (offset_blocks < num_blocks) {
		if (!_dif_sgl_append(&sgl, buf, data_block_size)) {
			goto end;
		}
		buf += ctx->block_size;
		offset_blocks++;
		head_unalign = 0;
	}

end:
	if (_mapped_len != NULL) {
		*_mapped_len = sgl.total_size;
	}