On Fri, 2017-07-07 at 16:26 +0200, Pavel Grunt wrote: > Silence -Wmissing-field-initializers warnings. Forgot to mention, it happens when building tests. My gcc --version: gcc (GCC) 7.1.1 20170622 (Red Hat 7.1.1-3) But I'm not sure it is specific to gcc version, a similar fix has been replied recently for spice-server and reporter mentioned gcc 4.9... > --- > imo it also makes the code more readable (especially tests/session.c) > --- > src/channel-display-gst.c | 3 +- > src/channel-main.c | 4 +- > src/channel-record.c | 16 +++-- > src/spice-channel.c | 12 ++-- > src/spice-gtk-session.c | 14 ++--- > src/spice-pulse.c | 18 +++--- > src/spice-session.c | 2 +- > tests/session.c | 156 +++++++++++++++++++++++++------------------ > --- > 8 files changed, 118 insertions(+), 107 deletions(-) > > diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c > index 9b79403..807ff85 100644 > --- a/src/channel-display-gst.c > +++ b/src/channel-display-gst.c > @@ -306,7 +306,7 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder) > gchar *desc; > gboolean auto_enabled; > guint opt; > - GstAppSinkCallbacks appsink_cbs = { NULL }; > + GstAppSinkCallbacks appsink_cbs = { .new_sample = new_sample }; > GError *err = NULL; > GstBus *bus; > > @@ -344,7 +344,6 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder) > decoder->appsrc = GST_APP_SRC(gst_bin_get_by_name(GST_BIN(decoder- > >pipeline), "src")); > decoder->appsink = GST_APP_SINK(gst_bin_get_by_name(GST_BIN(decoder- > >pipeline), "sink")); > > - appsink_cbs.new_sample = new_sample; > gst_app_sink_set_callbacks(decoder->appsink, &appsink_cbs, decoder, > NULL); > bus = gst_pipeline_get_bus(GST_PIPELINE(decoder->pipeline)); > gst_bus_add_watch(bus, handle_pipeline_message, decoder); > diff --git a/src/channel-main.c b/src/channel-main.c > index 4edd575..104b18a 100644 > --- a/src/channel-main.c > +++ b/src/channel-main.c > @@ -1275,7 +1275,7 @@ static void agent_sync_audio_record(SpiceMainChannel > *main_channel) > static void agent_display_config(SpiceMainChannel *channel) > { > SpiceMainChannelPrivate *c = channel->priv; > - VDAgentDisplayConfig config = { 0, }; > + VDAgentDisplayConfig config = { .flags = 0, .depth = 0}; > > if (c->display_disable_wallpaper) { > config.flags |= VD_AGENT_DISPLAY_CONFIG_FLAG_DISABLE_WALLPAPER; > @@ -2334,7 +2334,7 @@ static void main_migrate_connect(SpiceChannel *channel, > { > SpiceMainChannelPrivate *main_priv = SPICE_MAIN_CHANNEL(channel)->priv; > int reply_type = SPICE_MSGC_MAIN_MIGRATE_CONNECT_ERROR; > - spice_migrate mig = { 0, }; > + spice_migrate mig = { .from = NULL, }; > SpiceMsgOut *out; > SpiceSession *session; > > diff --git a/src/channel-record.c b/src/channel-record.c > index 9834e85..2023bb4 100644 > --- a/src/channel-record.c > +++ b/src/channel-record.c > @@ -255,18 +255,18 @@ static void > spice_record_channel_class_init(SpiceRecordChannelClass *klass) > static void spice_record_mode(SpiceRecordChannel *channel, uint32_t time, > uint32_t mode, uint8_t *data, uint32_t > data_size) > { > - SpiceMsgcRecordMode m = {0, }; > + SpiceMsgcRecordMode m = { > + .time = time, > + .mode = mode, > + .data = data, > + .data_size = data_size, > + }; > SpiceMsgOut *msg; > > g_return_if_fail(channel != NULL); > if (spice_channel_get_read_only(SPICE_CHANNEL(channel))) > return; > > - m.mode = mode; > - m.time = time; > - m.data = data; > - m.data_size = data_size; > - > msg = spice_msg_out_new(SPICE_CHANNEL(channel), SPICE_MSGC_RECORD_MODE); > msg->marshallers->msgc_record_mode(msg->marshaller, &m); > spice_msg_out_send(msg); > @@ -317,7 +317,7 @@ void spice_record_send_data(SpiceRecordChannel *channel, > gpointer data, > gsize bytes, uint32_t time) > { > SpiceRecordChannelPrivate *rc; > - SpiceMsgcRecordPacket p = {0, }; > + SpiceMsgcRecordPacket p = { .time = time }; > > g_return_if_fail(SPICE_IS_RECORD_CHANNEL(channel)); > rc = channel->priv; > @@ -339,8 +339,6 @@ void spice_record_send_data(SpiceRecordChannel *channel, > gpointer data, > if (rc->mode != SPICE_AUDIO_DATA_MODE_RAW) > encode_buf = g_alloca(SND_CODEC_MAX_COMPRESSED_BYTES); > > - p.time = time; > - > while (bytes > 0) { > gsize n; > int frame_size; > diff --git a/src/spice-channel.c b/src/spice-channel.c > index 4c3db9d..3e88d7a 100644 > --- a/src/spice-channel.c > +++ b/src/spice-channel.c > @@ -928,12 +928,17 @@ static void spice_channel_write_msg(SpiceChannel > *channel, SpiceMsgOut *out) > #ifdef G_OS_UNIX > static ssize_t read_fd(int fd, int *msgfd) > { > - struct msghdr msg = { NULL, }; > struct iovec iov[1]; > union { > struct cmsghdr cmsg; > char control[CMSG_SPACE(sizeof(int))]; > } msg_control; > + struct msghdr msg = { > + .msg_iov = iov, > + .msg_iovlen = 1, > + .msg_control = &msg_control, > + .msg_controllen = sizeof(msg_control), > + }; > struct cmsghdr *cmsg; > ssize_t ret; > char c; > @@ -941,11 +946,6 @@ static ssize_t read_fd(int fd, int *msgfd) > iov[0].iov_base = &c; > iov[0].iov_len = 1; > > - msg.msg_iov = iov; > - msg.msg_iovlen = 1; > - msg.msg_control = &msg_control; > - msg.msg_controllen = sizeof(msg_control); > - > ret = recvmsg(fd, &msg, 0); > if (ret > 0) { > for (cmsg = CMSG_FIRSTHDR(&msg); > diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c > index e338ce6..edb6c7d 100644 > --- a/src/spice-gtk-session.c > +++ b/src/spice-gtk-session.c > @@ -773,26 +773,26 @@ static void clipboard_get(GtkClipboard *clipboard, > { > g_return_if_fail(SPICE_IS_GTK_SESSION(user_data)); > > - RunInfo ri = { NULL, }; > SpiceGtkSession *self = user_data; > SpiceGtkSessionPrivate *s = self->priv; > gboolean agent_connected = FALSE; > gulong clipboard_handler; > gulong agent_handler; > - int selection; > + int selection = get_selection_from_clipboard(s, clipboard); > + RunInfo ri = { > + .selection_data = selection_data, > + .info = info, > + .selection = selection, > + .self = self, > + }; > > SPICE_DEBUG("clipboard get"); > > - selection = get_selection_from_clipboard(s, clipboard); > g_return_if_fail(selection != -1); > g_return_if_fail(info < SPICE_N_ELEMENTS(atom2agent)); > g_return_if_fail(s->main != NULL); > > - ri.selection_data = selection_data; > - ri.info = info; > ri.loop = g_main_loop_new(NULL, FALSE); > - ri.selection = selection; > - ri.self = self; > > clipboard_handler = g_signal_connect(s->main, "main-clipboard-selection", > G_CALLBACK(clipboard_got_from_guest) > , > diff --git a/src/spice-pulse.c b/src/spice-pulse.c > index 5248bc3..519ca3d 100644 > --- a/src/spice-pulse.c > +++ b/src/spice-pulse.c > @@ -359,7 +359,11 @@ static void create_playback(SpicePulse *pulse) > { > SpicePulsePrivate *p = pulse->priv; > pa_stream_flags_t flags; > - pa_buffer_attr buffer_attr = { 0, }; > + pa_buffer_attr buffer_attr = { > + .maxlength = -1, > + .prebuf = -1, > + .minreq = -1, > + }; > > g_return_if_fail(p != NULL); > g_return_if_fail(p->context != NULL); > @@ -373,10 +377,7 @@ static void create_playback(SpicePulse *pulse) > pa_stream_set_underflow_callback(p->playback.stream, stream_underflow_cb, > pulse); > pa_stream_set_latency_update_callback(p->playback.stream, > stream_update_latency_callback, pulse); > > - buffer_attr.maxlength = -1; > buffer_attr.tlength = pa_usec_to_bytes(p->target_delay * > PA_USEC_PER_MSEC, &p->playback.spec); > - buffer_attr.prebuf = -1; > - buffer_attr.minreq = -1; > flags = PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE; > > if (pa_stream_connect_playback(p->playback.stream, > @@ -519,7 +520,11 @@ static void stream_read_callback(pa_stream *s, size_t > length, void *data) > static void create_record(SpicePulse *pulse) > { > SpicePulsePrivate *p = pulse->priv; > - pa_buffer_attr buffer_attr = { 0, }; > + pa_buffer_attr buffer_attr = { > + .maxlength = -1, > + .prebuf = -1, > + .minreq = -1, > + }; > pa_stream_flags_t flags; > > g_return_if_fail(p != NULL); > @@ -534,10 +539,7 @@ static void create_record(SpicePulse *pulse) > pa_stream_set_state_callback(p->record.stream, stream_state_callback, > pulse); > > /* FIXME: we might want customizable latency */ > - buffer_attr.maxlength = -1; > - buffer_attr.prebuf = -1; > buffer_attr.fragsize = buffer_attr.tlength = pa_usec_to_bytes(20 * > PA_USEC_PER_MSEC, &p->record.spec); > - buffer_attr.minreq = (uint32_t) -1; > flags = PA_STREAM_ADJUST_LATENCY; > > if (pa_stream_connect_record(p->record.stream, NULL, &buffer_attr, flags) > < 0) { > diff --git a/src/spice-session.c b/src/spice-session.c > index 6f8cf5e..bdc6b43 100644 > --- a/src/spice-session.c > +++ b/src/spice-session.c > @@ -2155,7 +2155,7 @@ GSocketConnection* > spice_session_channel_open_host(SpiceSession *session, SpiceC > > SpiceSessionPrivate *s = session->priv; > SpiceChannelPrivate *c = channel->priv; > - spice_open_host open_host = { 0, }; > + spice_open_host open_host = { .from = NULL, }; > gchar *port, *endptr; > > // FIXME: make open_host() cancellable > diff --git a/tests/session.c b/tests/session.c > index 7ed4a41..70dd300 100644 > --- a/tests/session.c > +++ b/tests/session.c > @@ -192,42 +192,48 @@ static void test_session_uri_ipv4_good(void) > { > const TestCase tests[] = { > /* Arguments with empty value */ > - { "5900", NULL, > - "localhost", > - NULL, NULL, > - "spice://localhost?port=5900&tls-port=", > - "spice://localhost?port=5900&" }, > - { "5910", NULL, > - "localhost", > - "user", NULL, > - "spice://user@localhost?tls-port=&port=5910", > - "spice://localhost?port=5910&" }, > - { NULL, "5920", > - "localhost", > - "user", "password", > - "spice://user@localhost?tls-port=5920&port=&password=password", > - "spice://localhost?tls-port=5920", > - "password may be visible in process listings"}, > - { NULL, "5930", > - "localhost", > - NULL, NULL, > - "spice://localhost?port=&tls-port=5930", > - "spice://localhost?tls-port=5930" }, > - { "42", NULL, > - "localhost", > - NULL, NULL, > - "spice://localhost:42", > - "spice://localhost?port=42&" }, > - { "42", "5930", > - "localhost", > - NULL, NULL, > - "spice://localhost:42?tls-port=5930", > - "spice://localhost?port=42&tls-port=5930" }, > - { "42", "5930", > - "127.0.0.1", > - NULL, NULL, > - "spice://127.0.0.1:42?tls-port=5930", > - "spice://127.0.0.1?port=42&tls-port=5930" }, > + { > + .port = "5900", > + .host = "localhost", > + .uri_input = "spice://localhost?port=5900&tls-port=", > + .uri_output = "spice://localhost?port=5900&", > + },{ > + .port = "5910", > + .host = "localhost", > + .username = "user", > + .uri_input = "spice://user@localhost?tls-port=&port=5910", > + .uri_output = "spice://localhost?port=5910&", > + },{ > + .tls_port = "5920", > + .host = "localhost", > + .username = "user", > + .password = "password", > + .uri_input = "spice://user@localhost?tls- > port=5920&port=&password=password", > + .uri_output = "spice://localhost?tls-port=5920", > + .message = "password may be visible in process listings", > + },{ > + .tls_port ="5930", > + .host = "localhost", > + .uri_input = "spice://localhost?port=&tls-port=5930", > + .uri_output = "spice://localhost?tls-port=5930", > + },{ > + .port = "42", > + .host = "localhost", > + .uri_input = "spice://localhost:42", > + .uri_output ="spice://localhost?port=42&", > + },{ > + .port = "42", > + .tls_port = "5930", > + .host = "localhost", > + .uri_input ="spice://localhost:42?tls-port=5930", > + .uri_output = "spice://localhost?port=42&tls-port=5930", > + },{ > + .port = "42", > + .tls_port = "5930", > + .host = "127.0.0.1", > + .uri_input = "spice://127.0.0.1:42?tls-port=5930", > + .uri_output = "spice://127.0.0.1?port=42&tls-port=5930", > + }, > }; > > test_session_uri_good(tests, G_N_ELEMENTS(tests)); > @@ -237,42 +243,48 @@ static void test_session_uri_ipv6_good(void) > { > const TestCase tests[] = { > /* Arguments with empty value */ > - { "5900", NULL, > - "[2010:836B:4179::836B:4179]", > - NULL, NULL, > - "spice://[2010:836B:4179::836B:4179]?port=5900&tls-port=", > - "spice://[2010:836B:4179::836B:4179]?port=5900&" }, > - { "5910", NULL, > - "[::192.9.5.5]", > - "user", NULL, > - "spice://user@[::192.9.5.5]?tls-port=&port=5910", > - "spice://[::192.9.5.5]?port=5910&" }, > - { NULL, "5920", > - "[3ffe:2a00:100:7031::1]", > - "user", "password", > - "spice://user@[3ffe:2a00:100:7031::1]?tls- > port=5920&port=&password=password", > - "spice://[3ffe:2a00:100:7031::1]?tls-port=5920", > - "password may be visible in process listings"}, > - { NULL, "5930", > - "[1080:0:0:0:8:800:200C:417A]", > - NULL, NULL, > - "spice://[1080:0:0:0:8:800:200C:417A]?port=&tls-port=5930", > - "spice://[1080:0:0:0:8:800:200C:417A]?tls-port=5930" }, > - { "42", NULL, > - "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", > - NULL, NULL, > - "spice://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:42", > - "spice://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]?port=42&" }, > - { "42", "5930", > - "[::192.9.5.5]", > - NULL, NULL, > - "spice://[::192.9.5.5]:42?tls-port=5930", > - "spice://[::192.9.5.5]?port=42&tls-port=5930" }, > - { "42", "5930", > - "[::FFFF:129.144.52.38]", > - NULL, NULL, > - "spice://[::FFFF:129.144.52.38]:42?tls-port=5930", > - "spice://[::FFFF:129.144.52.38]?port=42&tls-port=5930" }, > + { > + .port = "5900", > + .host = "[2010:836B:4179::836B:4179]", > + .uri_input = "spice://[2010:836B:4179::836B:4179]?port=5900&tls- > port=", > + .uri_output = "spice://[2010:836B:4179::836B:4179]?port=5900&", > + },{ > + .port = "5910", > + .host = "[::192.9.5.5]", > + .username = "user", > + .uri_input = "spice://user@[::192.9.5.5]?tls-port=&port=5910", > + .uri_output = "spice://[::192.9.5.5]?port=5910&", > + },{ > + .tls_port = "5920", > + .host = "[3ffe:2a00:100:7031::1]", > + .username = "user", > + .password = "password", > + .uri_input = "spice://user@[3ffe:2a00:100:7031::1]?tls- > port=5920&port=&password=password", > + .uri_output = "spice://[3ffe:2a00:100:7031::1]?tls-port=5920", > + .message = "password may be visible in process listings", > + },{ > + .tls_port = "5930", > + .host = "[1080:0:0:0:8:800:200C:417A]", > + .uri_input = "spice://[1080:0:0:0:8:800:200C:417A]?port=&tls- > port=5930", > + .uri_output = "spice://[1080:0:0:0:8:800:200C:417A]?tls- > port=5930", > + },{ > + .port = "42", > + .host = "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", > + .uri_input = > "spice://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:42", > + .uri_output = > "spice://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]?port=42&", > + },{ > + .port = "42", > + .tls_port = "5930", > + .host = "[::192.9.5.5]", > + .uri_input = "spice://[::192.9.5.5]:42?tls-port=5930", > + .uri_output = "spice://[::192.9.5.5]?port=42&tls-port=5930", > + },{ > + .port = "42", > + .tls_port = "5930", > + .host = "[::FFFF:129.144.52.38]", > + .uri_input = "spice://[::FFFF:129.144.52.38]:42?tls-port=5930", > + .uri_output = "spice://[::FFFF:129.144.52.38]?port=42&tls- > port=5930", > + }, > }; > > test_session_uri_good(tests, G_N_ELEMENTS(tests)); _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel