[Spice-devel] [PATCH spice-streaming-agent 2/2] Do not redefine "msg" field
Frediano Ziglio
fziglio at redhat.com
Fri Mar 9 07:41:04 UTC 2018
>
> msg.msg was redefining msg.StreamMsgNotifyError::msg.
> This cause some confusion.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> src/spice-streaming-agent.cpp | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> index 37addf4..777e330 100644
> --- a/src/spice-streaming-agent.cpp
> +++ b/src/spice-streaming-agent.cpp
> @@ -146,13 +146,13 @@ static void handle_stream_error(size_t len)
> }
>
> struct NotifyError : StreamMsgNotifyError {
> - uint8_t msg[1024];
> + uint8_t msg_buffer[1024];
> } msg;
>
> size_t len_to_read = std::min(len, sizeof(msg) - 1);
>
> read_all(&msg, len_to_read);
> - msg.msg[len_to_read - sizeof(StreamMsgNotifyError)] = '\0';
> + ((uint8_t *) &msg)[len_to_read] = '\0';
>
Not much proud of this. Maybe a reinterpret_cast would help?
Defining a union and a more complicated structure looks like
overwhelming here. On the other hand more subtly we do the same
conversion in the line above (read_all call).
> syslog(LOG_ERR, "Received NotifyError message from the server: %d -
> %s\n",
> msg.error_code, msg.msg);
Frediano
More information about the Spice-devel
mailing list