[Spice-devel] [PATCH 06/22] Get rid of C-style memset initializations, use C++ style aggregates
Christophe Fergeau
cfergeau at redhat.com
Tue Mar 6 16:15:04 UTC 2018
On Thu, Mar 01, 2018 at 09:01:37PM +0100, Christophe de Dinechin wrote:
> > On 28 Feb 2018, at 17:36, Christophe Fergeau <cfergeau at redhat.com> wrote:
> >
> > My understanding is that the previous iteration was quite controversial,
> > I would just drop it from the series unless you get acks from everyone
> > involved this time.
>
> It’s a bit difficult to drop that from the series, as it is a core element of the next steps if you look carefully.
I only looked at the code with the full series applied, but it really seems like both way would
be possible?
diff --git a/src/concrete-agent.cpp b/src/concrete-agent.cpp
index fe8564f..2e1472a 100644
--- a/src/concrete-agent.cpp
+++ b/src/concrete-agent.cpp
@@ -140,7 +140,10 @@ public:
}
void write_message_body(Stream &stream, unsigned w, unsigned h, uint8_t c)
{
- StreamMsgFormat msg = { .width = w, .height = h, .codec = c, .padding1 = {} };
+ StreamMsgFormat msg;
+ msg.width = w;
+ msg.height = h;
+ msg.codec = c;
stream.write_all("format", &msg, sizeof(msg));
}
};
diff --git a/src/message.hpp b/src/message.hpp
index fd69033..674e122 100644
--- a/src/message.hpp
+++ b/src/message.hpp
@@ -21,13 +21,12 @@ class Message
public:
template <typename ...PayloadArgs>
Message(PayloadArgs... payload_args)
- : hdr(StreamDevHeader {
- .protocol_version = STREAM_DEVICE_PROTOCOL,
- .padding = 0, // Workaround GCC bug "sorry: not implemented"
- .type = Type,
- .size = (uint32_t) Info::size(payload_args...)
- })
- { }
+ {
+ hdr.protocol_version = STREAM_DEVICE_PROTOCOL;
+ hdr.padding = 0;
+ hdr.type = Type;
+ hdr.size = (uint32_t) Info::size(payload_args...);
+ }
void write_header(Stream &stream)
{
stream.write_all("header", &hdr, sizeof(hdr));
Not strongly advocating for that change to be made just now, I was just
a bit surprised by how you dismissed this ;)
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180306/0fc8ee4f/attachment-0001.sig>
More information about the Spice-devel
mailing list