Ensure all members of ChannelCbs and ClientCbs are either assigned or NULL

While git-bisecting another issue I ended up hitting and not recognizing
the bug fixed by commit 7a079b452b.

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@redhat.com>
This commit is contained in:
Hans de Goede 2012-03-09 12:49:26 +01:00
parent 1029e7fd4d
commit f24203e122
9 changed files with 15 additions and 21 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;