nbd: Refactor the function in which the fix of scan build error is added

Consolidating multiptle reinsertions into a place will make the logic
a little cleaner.

Change-Id: Iab7e9f8e7dcdebbec9d51e151b1d838567c1dcc4
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/427441
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-10-01 16:26:27 +09:00 committed by Jim Harris
parent e1e9b05e9e
commit bb75b28fe4

View File

@ -661,8 +661,7 @@ spdk_nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
ret = write_to_socket(nbd->spdk_sp_fd, (char *)&io->resp + io->offset,
sizeof(io->resp) - io->offset);
if (ret <= 0) {
TAILQ_INSERT_HEAD(&nbd->executed_io_list, io, tailq);
return ret;
goto reinsert;
}
io->offset += ret;
@ -684,8 +683,7 @@ spdk_nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
if (io->state == NBD_IO_XMIT_PAYLOAD) {
ret = write_to_socket(nbd->spdk_sp_fd, io->payload + io->offset, io->payload_size - io->offset);
if (ret <= 0) {
TAILQ_INSERT_HEAD(&nbd->executed_io_list, io, tailq);
return ret;
goto reinsert;
}
io->offset += ret;
@ -697,8 +695,9 @@ spdk_nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
}
}
reinsert:
TAILQ_INSERT_HEAD(&nbd->executed_io_list, io, tailq);
return 0;
return ret;
}
static int