Re: [spice-streaming-agent PATCH] handle_stream_error: add comment for inheriting struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On 7 Mar 2018, at 07:40, Frediano Ziglio <fziglio@xxxxxxxxxx> wrote:
> 
>> 
>> Introduced in 548577dc8adae1a558
>> 
>> Signed-off-by: Uri Lublin <uril@xxxxxxxxxx>
>> ---
>> src/spice-streaming-agent.cpp | 5 +++++
>> 1 file changed, 5 insertions(+)
>> 
>> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
>> index b39782c..e25d47a 100644
>> --- a/src/spice-streaming-agent.cpp
>> +++ b/src/spice-streaming-agent.cpp
>> @@ -145,6 +145,11 @@ static void handle_stream_error(size_t len)
>>                                  std::to_string(sizeof(StreamMsgNotifyError))
>>                                  + ")");
>>     }
>> 
>> +    // This struct inherits StreamMsgNotifyError. Its memory layout is:
>> +    // offset 0: StreamMsgNotifyError.error_code (a uint32_t)
>> +    // offset 4: StreamMsgNotifyError.msg and also msg.msg (a
>> uint8_t[1024]).
>> +    // Both StreamMsgNotifyError.msg and msg.msg point to the same
>> +    // memory location (practically local msg overrides inherited msg).
>>     struct : StreamMsgNotifyError {
>>         uint8_t msg[1024];
>>     } msg;
> 
> When I sent my suggestion I didn't wanted to clash with inherited field,
> just didn't invented a new name.
> Maybe would be easier and more clear to rename to msg_buffer or similar
> to avoid the confusion?

Would fix the issue I pointed out. But as I mentioned there, gcc emkits a warning that we access the array out of bounds (msg has zero length). You can silence that using a temporary char * pointer.

> 
> Frediano
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]