Commit 418acf5c authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

dif: Change a few loops from while loop to for loop



Using for loop is better for a few cases now.

Change-Id: I48e3a276fb860f2b969e7c331bdfdac8102172d7
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454527


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarPiotr Pelpliński <piotr.pelplinski@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 404ad843
Loading
Loading
Loading
Loading
+12 −18
Original line number Diff line number Diff line
@@ -324,11 +324,10 @@ static void
dif_generate_split(struct _dif_sgl *sgl, uint32_t num_blocks,
		   const struct spdk_dif_ctx *ctx)
{
	uint32_t offset_blocks = 0;
	uint32_t offset_blocks;

	while (offset_blocks < num_blocks) {
	for (offset_blocks = 0; offset_blocks < num_blocks; offset_blocks++) {
		_dif_generate_split(sgl, offset_blocks, ctx);
		offset_blocks++;
	}
}

@@ -547,15 +546,14 @@ static int
dif_verify_split(struct _dif_sgl *sgl, uint32_t num_blocks,
		 const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err_blk)
{
	uint32_t offset_blocks = 0;
	uint32_t offset_blocks;
	int rc;

	while (offset_blocks < num_blocks) {
	for (offset_blocks = 0; offset_blocks < num_blocks; offset_blocks++) {
		rc = _dif_verify_split(sgl, offset_blocks, ctx, err_blk);
		if (rc != 0) {
			return rc;
		}
		offset_blocks++;
	}

	return 0;
@@ -665,11 +663,10 @@ static void
dif_generate_copy_split(struct _dif_sgl *src_sgl, struct _dif_sgl *dst_sgl,
			uint32_t num_blocks, const struct spdk_dif_ctx *ctx)
{
	uint32_t offset_blocks = 0;
	uint32_t offset_blocks;

	while (offset_blocks < num_blocks) {
	for (offset_blocks = 0; offset_blocks < num_blocks; offset_blocks++) {
		_dif_generate_copy_split(src_sgl, dst_sgl, offset_blocks, ctx);
		offset_blocks++;
	}
}

@@ -793,15 +790,14 @@ dif_verify_copy_split(struct _dif_sgl *src_sgl, struct _dif_sgl *dst_sgl,
		      uint32_t num_blocks, const struct spdk_dif_ctx *ctx,
		      struct spdk_dif_error *err_blk)
{
	uint32_t offset_blocks = 0;
	uint32_t offset_blocks;
	int rc;

	while (offset_blocks < num_blocks) {
	for (offset_blocks = 0; offset_blocks < num_blocks; offset_blocks++) {
		rc = _dif_verify_copy_split(src_sgl, dst_sgl, offset_blocks, ctx, err_blk);
		if (rc != 0) {
			return rc;
		}
		offset_blocks++;
	}

	return 0;
@@ -1047,11 +1043,10 @@ static void
dix_generate_split(struct _dif_sgl *data_sgl, struct _dif_sgl *md_sgl,
		   uint32_t num_blocks, const struct spdk_dif_ctx *ctx)
{
	uint32_t offset_blocks = 0;
	uint32_t offset_blocks;

	while (offset_blocks < num_blocks) {
	for (offset_blocks = 0; offset_blocks < num_blocks; offset_blocks++) {
		_dix_generate_split(data_sgl, md_sgl, offset_blocks, ctx);
		offset_blocks++;
	}
}

@@ -1158,15 +1153,14 @@ dix_verify_split(struct _dif_sgl *data_sgl, struct _dif_sgl *md_sgl,
		 uint32_t num_blocks, const struct spdk_dif_ctx *ctx,
		 struct spdk_dif_error *err_blk)
{
	uint32_t offset_blocks = 0;
	uint32_t offset_blocks;
	int rc;

	while (offset_blocks < num_blocks) {
	for (offset_blocks = 0; offset_blocks < num_blocks; offset_blocks++) {
		rc = _dix_verify_split(data_sgl, md_sgl, offset_blocks, ctx, err_blk);
		if (rc != 0) {
			return rc;
		}
		offset_blocks++;
	}

	return 0;