Commit 30f52282 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

util/pipe: Simplify some null checks



Several null checks are not actually necessary.

Change-Id: I6827e3d4147ed0b9fb22b2148656cba87be5e18c
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17507


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 4c0b2d16
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ spdk_pipe_writer_get_buffer(struct spdk_pipe *pipe, uint32_t requested_sz, struc
	} else {
		sz = spdk_min(requested_sz, read - write);

		iovs[0].iov_base = (sz == 0) ? NULL : (pipe->buf + write);
		iovs[0].iov_base = pipe->buf + write;
		iovs[0].iov_len = sz;
		iovs[1].iov_base = NULL;
		iovs[1].iov_len = 0;
@@ -156,7 +156,7 @@ spdk_pipe_reader_get_buffer(struct spdk_pipe *pipe, uint32_t requested_sz, struc
	read = pipe->read;
	write = pipe->write;

	if (read == write && !pipe->full) {
	if ((read == write && !pipe->full) || requested_sz == 0) {
		iovs[0].iov_base = NULL;
		iovs[0].iov_len = 0;
		iovs[1].iov_base = NULL;
@@ -164,14 +164,14 @@ spdk_pipe_reader_get_buffer(struct spdk_pipe *pipe, uint32_t requested_sz, struc
	} else if (read < write) {
		sz = spdk_min(requested_sz, write - read);

		iovs[0].iov_base = (sz == 0) ? NULL : (pipe->buf + read);
		iovs[0].iov_base = pipe->buf + read;
		iovs[0].iov_len = sz;
		iovs[1].iov_base = NULL;
		iovs[1].iov_len = 0;
	} else {
		sz = spdk_min(requested_sz, pipe->sz - read);

		iovs[0].iov_base = (sz == 0) ? NULL : (pipe->buf + read);
		iovs[0].iov_base = pipe->buf + read;
		iovs[0].iov_len = sz;

		requested_sz -= sz;