[Spice-devel] [PATCH spice 1/5] Ensure all members of ChannelCbs and ClientCbs are either assigned or NULL
Hans de Goede
hdegoede at redhat.com
Sat Mar 10 11:31:25 PST 2012
While git-bisecting another issue I ended up hitting and not recognizing
the bug fixed by commit 7a079b452b026d6ce38f95dcc397fa64b059fffb.
While fixing this (again) I noticed that (even after the fix) not all
users of ChannelCbs first zero it. So this patch ensures that all users of
ChannelCbs first zero it, and does the same for ClientCbs while at it.
Since before this patch there were multiple zero-ing styles, some using
memset and other using a zero initializer this patch also unifies all
the zero-ing to use a NULL initializer for the first element.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
server/inputs_channel.c | 7 ++-----
server/main_channel.c | 2 +-
server/red_channel.c | 4 ++--
server/red_dispatcher.c | 2 +-
server/red_tunnel_worker.c | 4 ++--
server/red_worker.c | 2 +-
server/smartcard.c | 7 ++-----
server/snd_worker.c | 4 ++--
server/spicevmc.c | 4 ++--
9 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index a3f26c0..932ead7 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -525,14 +525,11 @@ static void key_modifiers_sender(void *opaque)
void inputs_init(void)
{
- ChannelCbs channel_cbs;
- ClientCbs client_cbs;
+ ChannelCbs channel_cbs = { NULL, };
+ ClientCbs client_cbs = { NULL, };
ASSERT(!g_inputs_channel);
- memset(&channel_cbs, 0, sizeof(channel_cbs));
- memset(&client_cbs, 0, sizeof(client_cbs));
-
channel_cbs.config_socket = inputs_channel_config_socket;
channel_cbs.on_disconnect = inputs_channel_on_disconnect;
channel_cbs.send_item = inputs_channel_send_item;
diff --git a/server/main_channel.c b/server/main_channel.c
index a871bc8..a9fd24e 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -1062,7 +1062,7 @@ uint64_t main_channel_client_get_bitrate_per_sec(MainChannelClient *mcc)
MainChannel* main_channel_init(void)
{
RedChannel *channel;
- ChannelCbs channel_cbs = {0,};
+ ChannelCbs channel_cbs = { NULL, };
channel_cbs.config_socket = main_channel_config_socket;
channel_cbs.on_disconnect = main_channel_client_on_disconnect;
diff --git a/server/red_channel.c b/server/red_channel.c
index 2cd98da..13cc525 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -601,7 +601,7 @@ RedChannel *red_channel_create(int size,
ChannelCbs *channel_cbs)
{
RedChannel *channel;
- ClientCbs client_cbs;
+ ClientCbs client_cbs = { NULL, };
ASSERT(size >= sizeof(*channel));
ASSERT(channel_cbs->config_socket && channel_cbs->on_disconnect && handle_message &&
@@ -668,7 +668,7 @@ SpiceCoreInterface dummy_core = {
RedChannel *red_channel_create_dummy(int size, uint32_t type, uint32_t id)
{
RedChannel *channel;
- ClientCbs client_cbs;
+ ClientCbs client_cbs = { NULL, };
ASSERT(size >= sizeof(*channel));
channel = spice_malloc0(size);
diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index 321232b..1aa619c 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -984,7 +984,7 @@ RedDispatcher *red_dispatcher_init(QXLInstance *qxl)
RedChannel *cursor_channel;
sigset_t thread_sig_mask;
sigset_t curr_sig_mask;
- ClientCbs client_cbs = {0,};
+ ClientCbs client_cbs = { NULL, };
quic_init();
sw_canvas_init();
diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
index 9162da4..80e0721 100644
--- a/server/red_tunnel_worker.c
+++ b/server/red_tunnel_worker.c
@@ -3474,8 +3474,8 @@ static void handle_tunnel_channel_client_migrate(RedChannelClient *rcc)
static void red_tunnel_channel_create(TunnelWorker *worker)
{
RedChannel *channel;
- ChannelCbs channel_cbs;
- ClientCbs client_cbs = {0,};
+ ChannelCbs channel_cbs = { NULL, };
+ ClientCbs client_cbs = { NULL, };
channel_cbs.config_socket = tunnel_channel_config_socket;
channel_cbs.on_disconnect = tunnel_channel_client_on_disconnect;
diff --git a/server/red_worker.c b/server/red_worker.c
index a2f31c0..6de95cb 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9664,7 +9664,7 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_t
{
RedChannel *channel = NULL;
CommonChannel *common;
- ChannelCbs channel_cbs;
+ ChannelCbs channel_cbs = { NULL, };
channel_cbs.config_socket = common_channel_config_socket;
channel_cbs.pre_disconnect = pre_disconnect;
diff --git a/server/smartcard.c b/server/smartcard.c
index facc4b3..84aa18b 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -512,14 +512,11 @@ SmartCardChannel *g_smartcard_channel;
static void smartcard_init(void)
{
- ChannelCbs channel_cbs;
- ClientCbs client_cbs;
+ ChannelCbs channel_cbs = { NULL, };
+ ClientCbs client_cbs = { NULL, };
ASSERT(!g_smartcard_channel);
- memset(&channel_cbs, 0, sizeof(channel_cbs));
- memset(&client_cbs, 0, sizeof(client_cbs));
-
channel_cbs.config_socket = smartcard_channel_client_config_socket;
channel_cbs.on_disconnect = smartcard_channel_on_disconnect;
channel_cbs.send_item = smartcard_channel_send_item;
diff --git a/server/snd_worker.c b/server/snd_worker.c
index aa1ceb7..4c51190 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -1464,7 +1464,7 @@ void snd_attach_playback(SpicePlaybackInstance *sin)
{
SndWorker *playback_worker;
RedChannel *channel;
- ClientCbs client_cbs = {0,};
+ ClientCbs client_cbs = { NULL, };
sin->st = spice_new0(SpicePlaybackState, 1);
sin->st->sin = sin;
@@ -1491,7 +1491,7 @@ void snd_attach_record(SpiceRecordInstance *sin)
{
SndWorker *record_worker;
RedChannel *channel;
- ClientCbs client_cbs = {0,};
+ ClientCbs client_cbs = { NULL, };
sin->st = spice_new0(SpiceRecordState, 1);
sin->st->sin = sin;
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 30aaf2f..ea9271c 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -255,8 +255,8 @@ void spicevmc_device_connect(SpiceCharDeviceInstance *sin,
{
static uint8_t id[256] = { 0, };
SpiceVmcState *state;
- ChannelCbs channel_cbs = {0,};
- ClientCbs client_cbs = {0,};
+ ChannelCbs channel_cbs = { NULL, };
+ ClientCbs client_cbs = { NULL, };
channel_cbs.config_socket = spicevmc_red_channel_client_config_socket;
channel_cbs.on_disconnect = spicevmc_red_channel_client_on_disconnect;
--
1.7.9.3
More information about the Spice-devel
mailing list