Skip to content

Commit

Permalink
Optimize the function of filter_send
Browse files Browse the repository at this point in the history
The iov_size has been calculated in filter_send(). we can directly
return the size.In this way, this is no need to repeat calculations
in filter_redirector_receive_iov();

Signed-off-by: Lei Rao <[email protected]>
Reviewed-by: Li Zhijian <[email protected]>
Reviewed-by: Zhang Chen <[email protected]>
Reviewed-by: Lukas Straub <[email protected]>
Tested-by: Lukas Straub <[email protected]>
Signed-off-by: Zhang Chen <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
  • Loading branch information
raolei-intel authored and jasowang committed Jun 11, 2021
1 parent 229620d commit 7c2eae9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/filter-mirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static int filter_send(MirrorState *s,
goto err;
}

return 0;
return size;

err:
return ret < 0 ? ret : -EIO;
Expand Down Expand Up @@ -159,7 +159,7 @@ static ssize_t filter_mirror_receive_iov(NetFilterState *nf,
int ret;

ret = filter_send(s, iov, iovcnt);
if (ret) {
if (ret < 0) {
error_report("filter mirror send failed(%s)", strerror(-ret));
}

Expand All @@ -182,10 +182,10 @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf,

if (qemu_chr_fe_backend_connected(&s->chr_out)) {
ret = filter_send(s, iov, iovcnt);
if (ret) {
if (ret < 0) {
error_report("filter redirector send failed(%s)", strerror(-ret));
}
return iov_size(iov, iovcnt);
return ret;
} else {
return 0;
}
Expand Down

0 comments on commit 7c2eae9

Please sign in to comment.