[Spice-devel] [spice-server PATCH] stream_device_partial_read: check once if whole hdr is read
Uri Lublin
uril at redhat.com
Sun Mar 4 14:12:42 UTC 2018
The "read header" loop checks if the whole header is read twice:
once in the while condition and once in the end of the loop body.
This patch removes the latter check and sets appropriate variables
outside of the loop.
Signed-off-by: Uri Lublin <uril at redhat.com>
---
server/stream-device.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/server/stream-device.c b/server/stream-device.c
index cbd34463f..9d6b0e6c0 100644
--- a/server/stream-device.c
+++ b/server/stream-device.c
@@ -97,13 +97,12 @@ stream_device_partial_read(StreamDevice *dev, SpiceCharDeviceInstance *sin)
return false;
}
dev->hdr_pos += n;
- if (dev->hdr_pos >= sizeof(dev->hdr)) {
- dev->hdr.type = GUINT16_FROM_LE(dev->hdr.type);
- dev->hdr.size = GUINT32_FROM_LE(dev->hdr.size);
- dev->msg_pos = 0;
- }
}
+ dev->hdr.type = GUINT16_FROM_LE(dev->hdr.type);
+ dev->hdr.size = GUINT32_FROM_LE(dev->hdr.size);
+ dev->msg_pos = 0;
+
switch ((StreamMsgType) dev->hdr.type) {
case STREAM_TYPE_FORMAT:
if (dev->hdr.size != sizeof(StreamMsgFormat)) {
--
2.14.3
More information about the Spice-devel
mailing list