[Spice-commits] 2 commits - server/char-device.cpp server/dcc.cpp server/dcc-send.cpp server/display-channel.cpp server/glz-encoder-dict.c server/image-encoders.cpp server/inputs-channel.cpp server/main-channel-client.cpp server/main-channel.cpp server/main-dispatcher.cpp server/mjpeg-encoder.c server/pixmap-cache.cpp server/red-channel-client.cpp server/red-channel.cpp server/red-parse-qxl.cpp server/red-pipe-item.cpp server/red-replay-qxl.cpp server/reds.cpp server/red-stream.cpp server/red-stream-device.cpp server/red-worker.cpp server/sound.cpp server/spice-bitmap-utils.c server/spicevmc.cpp server/stream-channel.cpp server/tests server/tree.cpp server/video-stream.cpp server/websocket.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Apr 11 06:52:21 UTC 2021
server/char-device.cpp | 8 +-
server/dcc-send.cpp | 66 +++++++++-------------
server/dcc.cpp | 12 ++--
server/display-channel.cpp | 7 +-
server/glz-encoder-dict.c | 4 -
server/image-encoders.cpp | 6 +-
server/inputs-channel.cpp | 20 +++---
server/main-channel-client.cpp | 10 ++-
server/main-channel.cpp | 21 +++----
server/main-dispatcher.cpp | 16 ++---
server/mjpeg-encoder.c | 3 -
server/pixmap-cache.cpp | 2
server/red-channel-client.cpp | 16 +++--
server/red-channel.cpp | 6 +-
server/red-parse-qxl.cpp | 2
server/red-pipe-item.cpp | 2
server/red-replay-qxl.cpp | 31 +++++-----
server/red-stream-device.cpp | 18 +++---
server/red-stream.cpp | 6 --
server/red-worker.cpp | 106 ++++++++++++++++++------------------
server/reds.cpp | 55 +++++++++---------
server/sound.cpp | 20 +++---
server/spice-bitmap-utils.c | 41 +++++++------
server/spicevmc.cpp | 8 +-
server/stream-channel.cpp | 6 +-
server/tests/test-channel.cpp | 4 -
server/tests/test-display-base.cpp | 14 ++--
server/tests/test-stream-device.cpp | 2
server/tests/vmc-emu.cpp | 2
server/tree.cpp | 8 +-
server/video-stream.cpp | 12 ++--
server/websocket.c | 3 -
32 files changed, 265 insertions(+), 272 deletions(-)
New commits:
commit fc9ca6c71a5bf8cb87dc9bebca94cf5169a22649
Author: Rosen Penev <rosenp at gmail.com>
Date: Mon Oct 5 03:13:29 2020 -0700
clang-tidy: do not use else after return
Found with readability-else-after-return
Easier to read.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
diff --git a/server/dcc-send.cpp b/server/dcc-send.cpp
index 6a41ae7c..1031c6a6 100644
--- a/server/dcc-send.cpp
+++ b/server/dcc-send.cpp
@@ -142,9 +142,8 @@ static bool is_bitmap_lossy(DisplayChannelClient *dcc, SpiceImage *image, SpiceR
if (dcc_pixmap_cache_hit(dcc, image->descriptor.id, &is_hit_lossy)) {
out_data->type = BITMAP_DATA_TYPE_CACHE;
return is_hit_lossy;
- } else {
- out_data->type = BITMAP_DATA_TYPE_BITMAP_TO_CACHE;
}
+ out_data->type = BITMAP_DATA_TYPE_BITMAP_TO_CACHE;
} else {
out_data->type = BITMAP_DATA_TYPE_BITMAP;
}
@@ -166,10 +165,9 @@ static bool is_brush_lossy(DisplayChannelClient *dcc, SpiceBrush *brush,
if (brush->type == SPICE_BRUSH_TYPE_PATTERN) {
return is_bitmap_lossy(dcc, brush->u.pattern.pat, NULL,
out_data);
- } else {
- out_data->type = BITMAP_DATA_TYPE_INVALID;
- return FALSE;
}
+ out_data->type = BITMAP_DATA_TYPE_INVALID;
+ return FALSE;
}
static RedChannelClient::Pipe::iterator get_pipe_tail(RedChannelClient::Pipe& pipe)
@@ -388,11 +386,9 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
stat_inc_counter(display->priv->cache_hits_counter, 1);
pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
return FILL_BITS_TYPE_CACHE;
- } else {
- pixmap_cache_unlocked_set_lossy(dcc->priv->pixmap_cache, simage->descriptor.id,
- FALSE);
- image.descriptor.flags |= SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME;
}
+ pixmap_cache_unlocked_set_lossy(dcc->priv->pixmap_cache, simage->descriptor.id, FALSE);
+ image.descriptor.flags |= SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME;
}
}
@@ -460,27 +456,23 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
}
pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
return FILL_BITS_TYPE_BITMAP;
- } else {
- red_display_add_image_to_pixmap_cache(dcc, simage, &image,
- comp_send_data.is_lossy);
-
- spice_marshall_Image(m, &image,
- &bitmap_palette_out, &lzplt_palette_out);
- spice_assert(bitmap_palette_out == NULL);
+ }
+ red_display_add_image_to_pixmap_cache(dcc, simage, &image, comp_send_data.is_lossy);
- marshaller_add_compressed(m, comp_send_data.comp_buf,
- comp_send_data.comp_buf_size);
+ spice_marshall_Image(m, &image, &bitmap_palette_out, &lzplt_palette_out);
+ spice_assert(bitmap_palette_out == NULL);
- if (lzplt_palette_out && comp_send_data.lzplt_palette) {
- spice_marshall_Palette(lzplt_palette_out, comp_send_data.lzplt_palette);
- }
+ marshaller_add_compressed(m, comp_send_data.comp_buf,
+ comp_send_data.comp_buf_size);
- spice_assert(!comp_send_data.is_lossy || can_lossy);
- pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
- return (comp_send_data.is_lossy ? FILL_BITS_TYPE_COMPRESS_LOSSY :
- FILL_BITS_TYPE_COMPRESS_LOSSLESS);
+ if (lzplt_palette_out && comp_send_data.lzplt_palette) {
+ spice_marshall_Palette(lzplt_palette_out, comp_send_data.lzplt_palette);
}
- break;
+
+ spice_assert(!comp_send_data.is_lossy || can_lossy);
+ pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
+ return (comp_send_data.is_lossy ? FILL_BITS_TYPE_COMPRESS_LOSSY :
+ FILL_BITS_TYPE_COMPRESS_LOSSLESS);
}
case SPICE_IMAGE_TYPE_QUIC:
red_display_add_image_to_pixmap_cache(dcc, simage, &image, FALSE);
diff --git a/server/display-channel.cpp b/server/display-channel.cpp
index 0e2b6890..50059636 100644
--- a/server/display-channel.cpp
+++ b/server/display-channel.cpp
@@ -882,7 +882,8 @@ static bool current_add(DisplayChannel *display, Ring *ring, Drawable *drawable)
* on to the next one. */
now = ring_next(ring, now);
continue;
- } else if (sibling->type != TREE_ITEM_TYPE_SHADOW) {
+ }
+ if (sibling->type != TREE_ITEM_TYPE_SHADOW) {
/* there is an overlap between the two regions */
/* NOTE: Shadow types represent a source region for a COPY_BITS
* operation, they don't represent a region that will be drawn.
diff --git a/server/glz-encoder-dict.c b/server/glz-encoder-dict.c
index 72e3d1bb..6a1da292 100644
--- a/server/glz-encoder-dict.c
+++ b/server/glz-encoder-dict.c
@@ -264,9 +264,9 @@ static inline int __get_pixels_num(LzImageType image_type, unsigned int num_line
{
if (IS_IMAGE_TYPE_RGB[image_type]) {
return num_lines * stride / RGB_BYTES_PER_PIXEL[image_type];
- } else {
- return num_lines * stride * PLT_PIXELS_PER_BYTE[image_type];
}
+
+ return num_lines * stride * PLT_PIXELS_PER_BYTE[image_type];
}
static void __glz_dictionary_window_segs_realloc(SharedDictionary *dict)
diff --git a/server/main-channel-client.cpp b/server/main-channel-client.cpp
index d815ad24..d1f031cc 100644
--- a/server/main-channel-client.cpp
+++ b/server/main-channel-client.cpp
@@ -115,12 +115,14 @@ uint8_t *MainChannelClient::alloc_recv_buf(uint16_t type, uint32_t size)
if (type == SPICE_MSGC_MAIN_AGENT_DATA) {
RedChannel *channel = get_channel();
return reds_get_agent_data_buffer(channel->get_server(), this, size);
- } else if (size > sizeof(priv->recv_buf)) {
+ }
+
+ if (size > sizeof(priv->recv_buf)) {
/* message too large, caller will log a message and close the connection */
return NULL;
- } else {
- return priv->recv_buf;
}
+
+ return priv->recv_buf;
}
void MainChannelClient::release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg)
diff --git a/server/main-channel.cpp b/server/main-channel.cpp
index fefda684..4abfd3bc 100644
--- a/server/main-channel.cpp
+++ b/server/main-channel.cpp
@@ -258,20 +258,19 @@ int MainChannel::migrate_connect(RedsMigSpice *new_mig_target, int try_seamless)
if (!try_seamless) {
return main_channel_connect_semi_seamless(this);
- } else {
- RedChannelClient *rcc;
- GList *clients = get_clients();
+ }
- /* just test the first one */
- rcc = (RedChannelClient*) g_list_nth_data(clients, 0);
+ RedChannelClient *rcc;
+ GList *clients = get_clients();
- if (!rcc->test_remote_cap(SPICE_MAIN_CAP_SEAMLESS_MIGRATE)) {
- return main_channel_connect_semi_seamless(this);
- } else {
- return main_channel_connect_seamless(this);
- }
+ /* just test the first one */
+ rcc = (RedChannelClient*) g_list_nth_data(clients, 0);
+
+ if (!rcc->test_remote_cap(SPICE_MAIN_CAP_SEAMLESS_MIGRATE)) {
+ return main_channel_connect_semi_seamless(this);
}
+ return main_channel_connect_seamless(this);
}
void MainChannel::migrate_cancel_wait()
diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c
index 0b4f5a4c..7d2482a6 100644
--- a/server/mjpeg-encoder.c
+++ b/server/mjpeg-encoder.c
@@ -1020,9 +1020,8 @@ static void mjpeg_encoder_decrease_bit_rate(MJpegEncoder *encoder)
if (now - rate_control->warmup_start_time < MJPEG_WARMUP_TIME) {
spice_debug("during warmup. ignoring");
return;
- } else {
- rate_control->warmup_start_time = 0;
}
+ rate_control->warmup_start_time = 0;
}
if (bit_rate_info->num_enc_frames > MJPEG_BIT_RATE_EVAL_MIN_NUM_FRAMES ||
diff --git a/server/red-channel-client.cpp b/server/red-channel-client.cpp
index f39c6d6a..635d1f0a 100644
--- a/server/red-channel-client.cpp
+++ b/server/red-channel-client.cpp
@@ -1003,9 +1003,11 @@ static int red_peer_receive(RedStream *stream, uint8_t *buf, uint32_t size)
spice_assert(now == -1);
if (errno == EAGAIN) {
break;
- } else if (errno == EINTR) {
+ }
+ if (errno == EINTR) {
continue;
- } else if (errno != EPIPE) {
+ }
+ if (errno != EPIPE) {
g_warning("%s", strerror(errno));
}
return -1;
@@ -1214,7 +1216,8 @@ void RedChannelClientPrivate::handle_pong(SpiceMsgPing *ping)
if (latency_monitor.state == PING_STATE_WARMUP) {
latency_monitor.state = PING_STATE_LATENCY;
return;
- } else if (latency_monitor.state != PING_STATE_LATENCY) {
+ }
+ if (latency_monitor.state != PING_STATE_LATENCY) {
spice_warning("unexpected");
return;
}
@@ -1631,10 +1634,9 @@ bool RedChannelClient::wait_outgoing_item(int64_t timeout)
if (blocked) {
spice_warning("timeout");
return FALSE;
- } else {
- spice_assert(no_item_being_sent());
- return TRUE;
}
+ spice_assert(no_item_being_sent());
+ return TRUE;
}
bool RedChannelClient::no_item_being_sent() const
diff --git a/server/red-channel.cpp b/server/red-channel.cpp
index 282d304a..d4830c6a 100644
--- a/server/red-channel.cpp
+++ b/server/red-channel.cpp
@@ -510,10 +510,10 @@ bool RedChannel::wait_all_sent(int64_t timeout)
max_pipe_size, blocked);
red_channel_disconnect_if_pending_send(this);
return FALSE;
- } else {
- spice_assert(red_channel_no_item_being_sent(this));
- return TRUE;
}
+
+ spice_assert(red_channel_no_item_being_sent(this));
+ return TRUE;
}
RedsState* RedChannel::get_server()
diff --git a/server/red-replay-qxl.cpp b/server/red-replay-qxl.cpp
index 2fb1e9ab..83ffa22f 100644
--- a/server/red-replay-qxl.cpp
+++ b/server/red-replay-qxl.cpp
@@ -1095,9 +1095,8 @@ static QXLPHYSICAL red_replay_drawable(SpiceReplay *replay, uint32_t flags)
}
if (flags & QXL_COMMAND_FLAG_COMPAT) {
return QXLPHYSICAL_FROM_PTR(red_replay_compat_drawable(replay, flags));
- } else {
- return QXLPHYSICAL_FROM_PTR(red_replay_native_drawable(replay, flags));
}
+ return QXLPHYSICAL_FROM_PTR(red_replay_native_drawable(replay, flags));
}
static QXLUpdateCmd *red_replay_update_cmd(SpiceReplay *replay)
diff --git a/server/red-stream.cpp b/server/red-stream.cpp
index 8a01857d..df4ddbb2 100644
--- a/server/red-stream.cpp
+++ b/server/red-stream.cpp
@@ -262,9 +262,8 @@ bool red_stream_set_auto_flush(RedStream *s, bool auto_flush)
if (socket_set_cork(s->socket, 1)) {
s->priv->use_cork = false;
return false;
- } else {
- s->priv->corked = true;
}
+ s->priv->corked = true;
} else if (s->priv->corked) {
socket_set_cork(s->socket, 0);
s->priv->corked = false;
@@ -532,9 +531,8 @@ RedStreamSslStatus red_stream_ssl_accept(RedStream *stream)
ssl_error == SSL_ERROR_WANT_WRITE)) {
if (ssl_error == SSL_ERROR_WANT_READ) {
return RED_STREAM_SSL_STATUS_WAIT_FOR_READ;
- } else {
- return RED_STREAM_SSL_STATUS_WAIT_FOR_WRITE;
}
+ return RED_STREAM_SSL_STATUS_WAIT_FOR_WRITE;
}
red_dump_openssl_errors();
diff --git a/server/reds.cpp b/server/reds.cpp
index 58faccc3..1bd36ac9 100644
--- a/server/reds.cpp
+++ b/server/reds.cpp
@@ -4368,9 +4368,8 @@ static int calc_compression_level(RedsState *reds)
if ((reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_OFF) ||
(spice_server_get_image_compression(reds) != SPICE_IMAGE_COMPRESSION_QUIC)) {
return 0;
- } else {
- return 1;
}
+ return 1;
}
void reds_on_ic_change(RedsState *reds)
diff --git a/server/sound.cpp b/server/sound.cpp
index af2c1bda..67e3b268 100644
--- a/server/sound.cpp
+++ b/server/sound.cpp
@@ -497,9 +497,9 @@ static int snd_playback_send_ctl(PlaybackChannelClient *playback_client)
if ((client->client_active = client->active)) {
return snd_playback_send_start(playback_client);
- } else {
- return snd_playback_send_stop(playback_client);
}
+
+ return snd_playback_send_stop(playback_client);
}
static bool snd_record_send_start(RecordChannelClient *record_client)
@@ -536,9 +536,9 @@ static int snd_record_send_ctl(RecordChannelClient *record_client)
if ((client->client_active = client->active)) {
return snd_record_send_start(record_client);
- } else {
- return snd_record_send_stop(record_client);
}
+
+ return snd_record_send_stop(record_client);
}
static bool snd_record_send_volume(RecordChannelClient *record_client)
diff --git a/server/spice-bitmap-utils.c b/server/spice-bitmap-utils.c
index c0df4fac..50903e38 100644
--- a/server/spice-bitmap-utils.c
+++ b/server/spice-bitmap-utils.c
@@ -87,9 +87,9 @@ BitmapGradualType bitmap_get_graduality_level(SpiceBitmap *bitmap)
if (score < GRADUAL_MEDIUM_SCORE_TH) {
return BITMAP_GRADUAL_MEDIUM;
- } else {
- return BITMAP_GRADUAL_LOW;
}
+
+ return BITMAP_GRADUAL_LOW;
}
int bitmap_has_extra_stride(SpiceBitmap *bitmap)
@@ -97,25 +97,26 @@ int bitmap_has_extra_stride(SpiceBitmap *bitmap)
spice_assert(bitmap);
if (bitmap_fmt_is_rgb(bitmap->format)) {
return ((bitmap->x * bitmap_fmt_get_bytes_per_pixel(bitmap->format)) < bitmap->stride);
- } else {
- switch (bitmap->format) {
- case SPICE_BITMAP_FMT_8BIT:
- return (bitmap->x < bitmap->stride);
- case SPICE_BITMAP_FMT_4BIT_BE:
- case SPICE_BITMAP_FMT_4BIT_LE: {
- int bytes_width = SPICE_ALIGN(bitmap->x, 2) >> 1;
- return bytes_width < bitmap->stride;
- }
- case SPICE_BITMAP_FMT_1BIT_BE:
- case SPICE_BITMAP_FMT_1BIT_LE: {
- int bytes_width = SPICE_ALIGN(bitmap->x, 8) >> 3;
- return bytes_width < bitmap->stride;
- }
- default:
- spice_error("invalid image type %u", bitmap->format);
- return 0;
- }
}
+
+ switch (bitmap->format) {
+ case SPICE_BITMAP_FMT_8BIT:
+ return (bitmap->x < bitmap->stride);
+ case SPICE_BITMAP_FMT_4BIT_BE:
+ case SPICE_BITMAP_FMT_4BIT_LE: {
+ int bytes_width = SPICE_ALIGN(bitmap->x, 2) >> 1;
+ return bytes_width < bitmap->stride;
+ }
+ case SPICE_BITMAP_FMT_1BIT_BE:
+ case SPICE_BITMAP_FMT_1BIT_LE: {
+ int bytes_width = SPICE_ALIGN(bitmap->x, 8) >> 3;
+ return bytes_width < bitmap->stride;
+ }
+ default:
+ spice_error("invalid image type %u", bitmap->format);
+ return 0;
+ }
+
return 0;
}
diff --git a/server/websocket.c b/server/websocket.c
index 82b20b49..6b974cce 100644
--- a/server/websocket.c
+++ b/server/websocket.c
@@ -369,7 +369,8 @@ int websocket_read(RedsWebSocket *ws, uint8_t *buf, size_t size, unsigned *flags
websocket_clear_frame(frame);
send_pending_data(ws);
return 0;
- } else if (frame->type == BINARY_FRAME || frame->type == TEXT_FRAME) {
+ }
+ if (frame->type == BINARY_FRAME || frame->type == TEXT_FRAME) {
rc = 0;
if (frame->expected_len > frame->relayed) {
rc = ws->raw_read(ws->raw_stream, buf,
commit 944dc8662edf46480c19d087cbab668e1d1d9c00
Author: Rosen Penev <rosenp at gmail.com>
Date: Mon Oct 5 02:27:47 2020 -0700
clang-tidy: use auto
Found with modernize-use-auto
auto is shorter and can sometimes disambiguate pointer constness.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
diff --git a/server/char-device.cpp b/server/char-device.cpp
index 225b3366..2bad1c37 100644
--- a/server/char-device.cpp
+++ b/server/char-device.cpp
@@ -133,7 +133,7 @@ static void red_char_device_client_free(RedCharDevice *dev,
spice_debug("write_queue_is_empty %d", g_queue_is_empty(&dev->priv->write_queue) && !dev->priv->cur_write_buf);
l = g_queue_peek_head_link(&dev->priv->write_queue);
while (l) {
- RedCharDeviceWriteBuffer *write_buf = (RedCharDeviceWriteBuffer *) l->data;
+ auto write_buf = (RedCharDeviceWriteBuffer *) l->data;
next = l->next;
if (write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
@@ -755,7 +755,7 @@ void RedCharDevice::migrate_data_marshall_empty(SpiceMarshaller *m)
static void migrate_data_marshaller_write_buffer_free(uint8_t *data, void *opaque)
{
- RedCharDeviceWriteBuffer *write_buf = (RedCharDeviceWriteBuffer *)opaque;
+ auto write_buf = (RedCharDeviceWriteBuffer *)opaque;
red_char_device_write_buffer_unref(write_buf);
}
@@ -800,7 +800,7 @@ void RedCharDevice::migrate_data_marshall(SpiceMarshaller *m)
}
for (item = g_queue_peek_tail_link(&priv->write_queue); item != NULL; item = item->prev) {
- RedCharDeviceWriteBuffer *write_buf = (RedCharDeviceWriteBuffer *) item->data;
+ auto write_buf = (RedCharDeviceWriteBuffer *) item->data;
spice_marshaller_add_by_ref_full(m2, write_buf->buf, write_buf->buf_used,
migrate_data_marshaller_write_buffer_free,
@@ -915,7 +915,7 @@ RedCharDevice::~RedCharDevice()
priv->cur_write_buf = NULL;
while (priv->clients != NULL) {
- RedCharDeviceClient *dev_client = (RedCharDeviceClient *) priv->clients->data;
+ auto dev_client = (RedCharDeviceClient *) priv->clients->data;
red_char_device_client_free(this, dev_client);
}
priv->running = FALSE;
diff --git a/server/dcc-send.cpp b/server/dcc-send.cpp
index d42a64e4..6a41ae7c 100644
--- a/server/dcc-send.cpp
+++ b/server/dcc-send.cpp
@@ -338,7 +338,7 @@ static void marshaller_add_compressed(SpiceMarshaller *m,
static void marshaller_unref_drawable(uint8_t *data, void *opaque)
{
- Drawable *drawable = (Drawable *) opaque;
+ auto drawable = (Drawable *) opaque;
drawable_unref(drawable);
}
@@ -1634,7 +1634,7 @@ static void red_lossy_marshall_qxl_draw_text(DisplayChannelClient *dcc,
static void red_release_video_encoder_buffer(uint8_t *data, void *opaque)
{
- VideoBuffer *buffer = (VideoBuffer*)opaque;
+ auto buffer = (VideoBuffer*)opaque;
buffer->free(buffer);
}
@@ -2224,7 +2224,7 @@ static void marshall_monitors_config(RedChannelClient *rcc, SpiceMarshaller *bas
{
int heads_size = sizeof(SpiceHead) * monitors_config->count;
int i;
- SpiceMsgDisplayMonitorsConfig *msg = (SpiceMsgDisplayMonitorsConfig *) g_malloc0(sizeof(*msg) + heads_size);
+ auto msg = (SpiceMsgDisplayMonitorsConfig *) g_malloc0(sizeof(SpiceMsgDisplayMonitorsConfig) + heads_size);
int count = 0; // ignore monitors_config->count, it may contain zero width monitors, remove them now
rcc->init_send_data(SPICE_MSG_DISPLAY_MONITORS_CONFIG);
@@ -2279,7 +2279,7 @@ static void marshall_gl_draw(RedChannelClient *rcc,
SpiceMarshaller *m,
RedPipeItem *item)
{
- RedGlDrawItem *p = static_cast<RedGlDrawItem*>(item);
+ auto p = static_cast<RedGlDrawItem*>(item);
rcc->init_send_data(SPICE_MSG_DISPLAY_GL_DRAW);
spice_marshall_msg_display_gl_draw(m, &p->draw);
@@ -2328,7 +2328,7 @@ void DisplayChannelClient::send_item(RedPipeItem *pipe_item)
::reset_send_data(dcc);
switch (pipe_item->type) {
case RED_PIPE_ITEM_TYPE_DRAW: {
- RedDrawablePipeItem *dpi = static_cast<RedDrawablePipeItem*>(pipe_item);
+ auto dpi = static_cast<RedDrawablePipeItem*>(pipe_item);
marshall_qxl_drawable(this, m, dpi);
break;
}
@@ -2336,7 +2336,7 @@ void DisplayChannelClient::send_item(RedPipeItem *pipe_item)
marshall_inval_palette(this, m, static_cast<RedCachePipeItem*>(pipe_item));
break;
case RED_PIPE_ITEM_TYPE_STREAM_CREATE: {
- StreamCreateDestroyItem *item = static_cast<StreamCreateDestroyItem*>(pipe_item);
+ auto item = static_cast<StreamCreateDestroyItem*>(pipe_item);
marshall_stream_start(this, m, item->agent);
break;
}
@@ -2344,7 +2344,7 @@ void DisplayChannelClient::send_item(RedPipeItem *pipe_item)
marshall_stream_clip(this, m, static_cast<VideoStreamClipItem*>(pipe_item));
break;
case RED_PIPE_ITEM_TYPE_STREAM_DESTROY: {
- StreamCreateDestroyItem *item = static_cast<StreamCreateDestroyItem*>(pipe_item);
+ auto item = static_cast<StreamCreateDestroyItem*>(pipe_item);
marshall_stream_end(this, m, item->agent);
break;
}
@@ -2368,22 +2368,22 @@ void DisplayChannelClient::send_item(RedPipeItem *pipe_item)
init_send_data(SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES);
break;
case RED_PIPE_ITEM_TYPE_CREATE_SURFACE: {
- RedSurfaceCreateItem *surface_create = static_cast<RedSurfaceCreateItem*>(pipe_item);
+ auto surface_create = static_cast<RedSurfaceCreateItem*>(pipe_item);
marshall_surface_create(this, m, &surface_create->surface_create);
break;
}
case RED_PIPE_ITEM_TYPE_DESTROY_SURFACE: {
- RedSurfaceDestroyItem *surface_destroy = static_cast<RedSurfaceDestroyItem*>(pipe_item);
+ auto surface_destroy = static_cast<RedSurfaceDestroyItem*>(pipe_item);
marshall_surface_destroy(this, m, surface_destroy->surface_destroy.surface_id);
break;
}
case RED_PIPE_ITEM_TYPE_MONITORS_CONFIG: {
- RedMonitorsConfigItem *monconf_item = static_cast<RedMonitorsConfigItem*>(pipe_item);
+ auto monconf_item = static_cast<RedMonitorsConfigItem*>(pipe_item);
marshall_monitors_config(this, m, monconf_item->monitors_config);
break;
}
case RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT: {
- RedStreamActivateReportItem *report_item =
+ auto report_item =
static_cast<RedStreamActivateReportItem*>(pipe_item);
marshall_stream_activate_report(this, m, report_item);
break;
diff --git a/server/dcc.cpp b/server/dcc.cpp
index 4920cb87..f7b87c72 100644
--- a/server/dcc.cpp
+++ b/server/dcc.cpp
@@ -530,7 +530,7 @@ XXX_CAST(RedChannelClient, DisplayChannelClient, DISPLAY_CHANNEL_CLIENT);
RedPipeItemPtr dcc_gl_draw_item_new(RedChannelClient *rcc, void *data, int num)
{
DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
- const SpiceMsgDisplayGlDraw *draw = (const SpiceMsgDisplayGlDraw *) data;
+ auto draw = (const SpiceMsgDisplayGlDraw *) data;
if (!red_stream_is_plain_unix(rcc->get_stream()) ||
!rcc->test_remote_cap(SPICE_DISPLAY_CAP_GL_SCANOUT)) {
@@ -928,9 +928,9 @@ static gint sort_video_codecs_by_client_preference(gconstpointer a_pointer,
gconstpointer b_pointer,
gpointer user_data)
{
- const RedVideoCodec *a = (const RedVideoCodec *) a_pointer;
- const RedVideoCodec *b = (const RedVideoCodec *) b_pointer;
- GArray *client_pref = (GArray *) user_data;
+ auto a = (const RedVideoCodec *) a_pointer;
+ auto b = (const RedVideoCodec *) b_pointer;
+ auto client_pref = (GArray *) user_data;
return (g_array_index(client_pref, gint, a->type) -
g_array_index(client_pref, gint, b->type));
@@ -1097,8 +1097,8 @@ bool DisplayChannelClient::handle_migrate_data(uint32_t size, void *message)
DisplayChannelClient *dcc = this;
DisplayChannel *display = DCC_TO_DC(dcc);
int surfaces_restored = FALSE;
- SpiceMigrateDataHeader *header = (SpiceMigrateDataHeader *)message;
- SpiceMigrateDataDisplay *migrate_data = (SpiceMigrateDataDisplay *)(header + 1);
+ auto header = (SpiceMigrateDataHeader *)message;
+ auto migrate_data = (SpiceMigrateDataDisplay *)(header + 1);
uint8_t *surfaces;
int i;
diff --git a/server/display-channel.cpp b/server/display-channel.cpp
index 79679c4d..0e2b6890 100644
--- a/server/display-channel.cpp
+++ b/server/display-channel.cpp
@@ -1807,7 +1807,7 @@ static void surface_update_dest(RedSurface *surface, const SpiceRect *area)
{
SpiceCanvas *canvas = surface->context.canvas;
int stride = surface->context.stride;
- uint8_t *line_0 = (uint8_t*) surface->context.line_0;
+ auto line_0 = (uint8_t*) surface->context.line_0;
if (surface->context.canvas_draws_on_surface)
return;
@@ -2099,7 +2099,7 @@ void display_channel_create_surface(DisplayChannel *display, uint32_t surface_id
surface->context.stride = stride;
surface->context.line_0 = line_0;
if (!data_is_valid) {
- char *data = (char*) line_0;
+ auto data = (char*) line_0;
if (stride < 0) {
data -= abs(stride) * (height - 1);
}
diff --git a/server/image-encoders.cpp b/server/image-encoders.cpp
index caafdc4c..f7d04741 100644
--- a/server/image-encoders.cpp
+++ b/server/image-encoders.cpp
@@ -387,7 +387,7 @@ static void image_encoders_init_lz(ImageEncoders *enc)
static void glz_usr_free_image(GlzEncoderUsrContext *usr, GlzUsrImageContext *image)
{
GlzData *lz_data = SPICE_CONTAINEROF(usr, GlzData, usr);
- GlzDrawableInstanceItem *glz_drawable_instance = (GlzDrawableInstanceItem *)image;
+ auto glz_drawable_instance = (GlzDrawableInstanceItem *)image;
ImageEncoders *drawable_enc = glz_drawable_instance->glz_drawable->encoders;
ImageEncoders *this_enc = SPICE_CONTAINEROF(lz_data, ImageEncoders, glz_data);
if (this_enc == drawable_enc) {
@@ -688,7 +688,7 @@ static GlzSharedDictionary *glz_shared_dictionary_new(RedClient *client, uint8_t
{
spice_return_val_if_fail(dict != NULL, NULL);
- GlzSharedDictionary *shared_dict = g_new0(GlzSharedDictionary, 1);
+ auto shared_dict = g_new0(GlzSharedDictionary, 1);
shared_dict->dict = dict;
shared_dict->id = id;
@@ -709,7 +709,7 @@ static GlzSharedDictionary *find_glz_dictionary(RedClient *client, uint8_t dict_
GlzSharedDictionary *ret = NULL;
for (l = glz_dictionary_list; l != NULL; l = l->next) {
- GlzSharedDictionary *dict = (GlzSharedDictionary *) l->data;
+ auto dict = (GlzSharedDictionary *) l->data;
if ((dict->client == client) && (dict->id == dict_id)) {
ret = dict;
break;
diff --git a/server/inputs-channel.cpp b/server/inputs-channel.cpp
index 9a1880cb..1e134f16 100644
--- a/server/inputs-channel.cpp
+++ b/server/inputs-channel.cpp
@@ -51,7 +51,7 @@ struct SpiceKbdState {
static SpiceKbdState* spice_kbd_state_new(InputsChannel *inputs)
{
- SpiceKbdState *st = g_new0(SpiceKbdState, 1);
+ auto st = g_new0(SpiceKbdState, 1);
st->inputs = inputs;
return st;
}
@@ -71,7 +71,7 @@ struct SpiceTabletState {
static SpiceTabletState* spice_tablet_state_new(RedsState* reds)
{
- SpiceTabletState *st = g_new0(SpiceTabletState, 1);
+ auto st = g_new0(SpiceTabletState, 1);
st->reds = reds;
return st;
}
@@ -247,12 +247,12 @@ bool InputsChannelClient::handle_message(uint16_t type, uint32_t size, void *mes
switch (type) {
case SPICE_MSGC_INPUTS_KEY_DOWN: {
- SpiceMsgcKeyDown *key_down = (SpiceMsgcKeyDown *) message;
+ auto key_down = (SpiceMsgcKeyDown *) message;
inputs_channel->sync_locks(key_down->code);
}
/* fallthrough */
case SPICE_MSGC_INPUTS_KEY_UP: {
- SpiceMsgcKeyUp *key_up = (SpiceMsgcKeyUp *) message;
+ auto key_up = (SpiceMsgcKeyUp *) message;
for (i = 0; i < 4; i++) {
uint8_t code = (key_up->code >> (i * 8)) & 0xff;
if (code == 0) {
@@ -264,7 +264,7 @@ bool InputsChannelClient::handle_message(uint16_t type, uint32_t size, void *mes
break;
}
case SPICE_MSGC_INPUTS_KEY_SCANCODE: {
- uint8_t *code = (uint8_t *) message;
+ auto code = (uint8_t *) message;
for (i = 0; i < size; i++) {
kbd_push_scan(inputs_channel->keyboard, code[i]);
inputs_channel->sync_locks(code[i]);
@@ -273,7 +273,7 @@ bool InputsChannelClient::handle_message(uint16_t type, uint32_t size, void *mes
}
case SPICE_MSGC_INPUTS_MOUSE_MOTION: {
SpiceMouseInstance *mouse = inputs_channel->mouse;
- SpiceMsgcMouseMotion *mouse_motion = (SpiceMsgcMouseMotion *) message;
+ auto mouse_motion = (SpiceMsgcMouseMotion *) message;
on_mouse_motion();
if (mouse && reds_get_mouse_mode(reds) == SPICE_MOUSE_MODE_SERVER) {
@@ -286,7 +286,7 @@ bool InputsChannelClient::handle_message(uint16_t type, uint32_t size, void *mes
break;
}
case SPICE_MSGC_INPUTS_MOUSE_POSITION: {
- SpiceMsgcMousePosition *pos = (SpiceMsgcMousePosition *) message;
+ auto pos = (SpiceMsgcMousePosition *) message;
SpiceTabletInstance *tablet = inputs_channel->tablet;
on_mouse_motion();
@@ -309,7 +309,7 @@ bool InputsChannelClient::handle_message(uint16_t type, uint32_t size, void *mes
break;
}
case SPICE_MSGC_INPUTS_MOUSE_PRESS: {
- SpiceMsgcMousePress *mouse_press = (SpiceMsgcMousePress *) message;
+ auto mouse_press = (SpiceMsgcMousePress *) message;
int dz = 0;
if (mouse_press->button == SPICE_MOUSE_BUTTON_UP) {
dz = -1;
@@ -340,7 +340,7 @@ bool InputsChannelClient::handle_message(uint16_t type, uint32_t size, void *mes
break;
}
case SPICE_MSGC_INPUTS_MOUSE_RELEASE: {
- SpiceMsgcMouseRelease *mouse_release = (SpiceMsgcMouseRelease *) message;
+ auto mouse_release = (SpiceMsgcMouseRelease *) message;
if (reds_get_mouse_mode(reds) == SPICE_MOUSE_MODE_CLIENT) {
if (reds_config_get_agent_mouse(reds) && reds_has_vdagent(reds)) {
inputs_channel->mouse_state.buttons =
@@ -363,7 +363,7 @@ bool InputsChannelClient::handle_message(uint16_t type, uint32_t size, void *mes
break;
}
case SPICE_MSGC_INPUTS_KEY_MODIFIERS: {
- SpiceMsgcKeyModifiers *modifiers = (SpiceMsgcKeyModifiers *) message;
+ auto modifiers = (SpiceMsgcKeyModifiers *) message;
uint8_t leds;
SpiceKbdInstance *keyboard = inputs_channel->keyboard;
diff --git a/server/main-channel-client.cpp b/server/main-channel-client.cpp
index 6d6cc18e..d815ad24 100644
--- a/server/main-channel-client.cpp
+++ b/server/main-channel-client.cpp
@@ -236,7 +236,7 @@ void MainChannelClient::push_init(int display_channels_hint,
static RedPipeItemPtr main_name_item_new(const char *name)
{
- RedNamePipeItem *item = new (strlen(name) + 1) RedNamePipeItem();
+ auto item = new (strlen(name) + 1) RedNamePipeItem();
item->msg.name_len = strlen(name) + 1;
memcpy(&item->msg.name, name, item->msg.name_len);
diff --git a/server/main-channel.cpp b/server/main-channel.cpp
index 425ebf00..fefda684 100644
--- a/server/main-channel.cpp
+++ b/server/main-channel.cpp
@@ -82,7 +82,7 @@ bool MainChannelClient::handle_migrate_data(uint32_t size, void *message)
{
RedChannel *channel = get_channel();
MainChannelClient *mcc = this;
- SpiceMigrateDataHeader *header = (SpiceMigrateDataHeader *)message;
+ auto header = (SpiceMigrateDataHeader *)message;
/* not supported with multi-clients */
spice_assert(channel->get_n_clients() == 1);
diff --git a/server/main-dispatcher.cpp b/server/main-dispatcher.cpp
index 94dbb4c1..680dc960 100644
--- a/server/main-dispatcher.cpp
+++ b/server/main-dispatcher.cpp
@@ -78,8 +78,8 @@ struct MainDispatcherClientDisconnectMessage {
static void main_dispatcher_handle_channel_event(void *opaque,
void *payload)
{
- RedsState *reds = (RedsState*) opaque;
- MainDispatcherChannelEventMessage *channel_event = (MainDispatcherChannelEventMessage*) payload;
+ auto reds = (RedsState*) opaque;
+ auto channel_event = (MainDispatcherChannelEventMessage*) payload;
reds_handle_channel_event(reds, channel_event->event, channel_event->info);
}
@@ -101,8 +101,8 @@ void MainDispatcher::channel_event(int event, SpiceChannelEventInfo *info)
static void main_dispatcher_handle_migrate_complete(void *opaque,
void *payload)
{
- RedsState *reds = (RedsState*) opaque;
- MainDispatcherMigrateSeamlessDstCompleteMessage *mig_complete = (MainDispatcherMigrateSeamlessDstCompleteMessage*) payload;
+ auto reds = (RedsState*) opaque;
+ auto mig_complete = (MainDispatcherMigrateSeamlessDstCompleteMessage*) payload;
reds_on_client_seamless_migrate_complete(reds, mig_complete->client);
mig_complete->client->unref();
@@ -111,8 +111,8 @@ static void main_dispatcher_handle_migrate_complete(void *opaque,
static void main_dispatcher_handle_mm_time_latency(void *opaque,
void *payload)
{
- RedsState *reds = (RedsState*) opaque;
- MainDispatcherMmTimeLatencyMessage *msg = (MainDispatcherMmTimeLatencyMessage*) payload;
+ auto reds = (RedsState*) opaque;
+ auto msg = (MainDispatcherMmTimeLatencyMessage*) payload;
reds_set_client_mm_time_latency(reds, msg->client, msg->latency);
msg->client->unref();
}
@@ -120,8 +120,8 @@ static void main_dispatcher_handle_mm_time_latency(void *opaque,
static void main_dispatcher_handle_client_disconnect(void *opaque,
void *payload)
{
- RedsState *reds = (RedsState*) opaque;
- MainDispatcherClientDisconnectMessage *msg = (MainDispatcherClientDisconnectMessage*) payload;
+ auto reds = (RedsState*) opaque;
+ auto msg = (MainDispatcherClientDisconnectMessage*) payload;
spice_debug("client=%p", msg->client);
reds_client_disconnect(reds, msg->client);
diff --git a/server/pixmap-cache.cpp b/server/pixmap-cache.cpp
index 49659ea4..699f73a9 100644
--- a/server/pixmap-cache.cpp
+++ b/server/pixmap-cache.cpp
@@ -90,7 +90,7 @@ static Ring pixmap_cache_list = {&pixmap_cache_list, &pixmap_cache_list};
static PixmapCache *pixmap_cache_new(RedClient *client, uint8_t id, int64_t size)
{
- PixmapCache *cache = g_new0(PixmapCache, 1);
+ auto cache = g_new0(PixmapCache, 1);
ring_item_init(&cache->base);
pthread_mutex_init(&cache->lock, NULL);
diff --git a/server/red-channel-client.cpp b/server/red-channel-client.cpp
index 961c7bd5..f39c6d6a 100644
--- a/server/red-channel-client.cpp
+++ b/server/red-channel-client.cpp
@@ -482,7 +482,7 @@ void RedChannelClient::send_ping()
void RedChannelClient::send_empty_msg(RedPipeItem *base)
{
- RedEmptyMsgPipeItem *msg_pipe_item = static_cast<RedEmptyMsgPipeItem*>(base);
+ auto msg_pipe_item = static_cast<RedEmptyMsgPipeItem*>(base);
init_send_data(msg_pipe_item->msg);
begin_send_message();
diff --git a/server/red-parse-qxl.cpp b/server/red-parse-qxl.cpp
index 4c4cf672..ead0254b 100644
--- a/server/red-parse-qxl.cpp
+++ b/server/red-parse-qxl.cpp
@@ -1244,7 +1244,7 @@ RedDrawable *red_drawable_new(QXLInstance *qxl, RedMemSlotInfo *slots,
int group_id, QXLPHYSICAL addr,
uint32_t flags)
{
- RedDrawable *red = g_new0(RedDrawable, 1);
+ auto red = g_new0(RedDrawable, 1);
red->refs = 1;
diff --git a/server/red-pipe-item.cpp b/server/red-pipe-item.cpp
index 143f2e27..a81de073 100644
--- a/server/red-pipe-item.cpp
+++ b/server/red-pipe-item.cpp
@@ -27,7 +27,7 @@ RedPipeItem::RedPipeItem(int init_type):
static void marshaller_unref_pipe_item(uint8_t *, void *opaque)
{
- RedPipeItem *item = (RedPipeItem*) opaque;
+ auto item = (RedPipeItem*) opaque;
shared_ptr_unref(item);
}
diff --git a/server/red-replay-qxl.cpp b/server/red-replay-qxl.cpp
index d0b608f4..2fb1e9ab 100644
--- a/server/red-replay-qxl.cpp
+++ b/server/red-replay-qxl.cpp
@@ -334,12 +334,12 @@ static ssize_t red_replay_data_chunks(SpiceReplay *replay, const char *prefix,
static void red_replay_data_chunks_free(SpiceReplay *replay, void *data, size_t base_size)
{
- QXLDataChunk *cur = (QXLDataChunk *)((uint8_t*)data +
+ auto cur = (QXLDataChunk *)((uint8_t*)data +
(base_size ? base_size - sizeof(QXLDataChunk) : 0));
cur = (QXLDataChunk*) QXLPHYSICAL_TO_PTR(cur->next_chunk);
while (cur) {
- QXLDataChunk *next = (QXLDataChunk*) QXLPHYSICAL_TO_PTR(cur->next_chunk);
+ auto next = (QXLDataChunk*) QXLPHYSICAL_TO_PTR(cur->next_chunk);
g_free(cur);
cur = next;
}
@@ -384,7 +384,7 @@ static QXLPath *red_replay_path(SpiceReplay *replay)
static void red_replay_path_free(SpiceReplay *replay, QXLPHYSICAL p)
{
- QXLPath *qxl = (QXLPath*) QXLPHYSICAL_TO_PTR(p);
+ auto qxl = (QXLPath*) QXLPHYSICAL_TO_PTR(p);
red_replay_data_chunks_free(replay, qxl, sizeof(*qxl));
}
@@ -519,7 +519,7 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
static void red_replay_image_free(SpiceReplay *replay, QXLPHYSICAL p, uint32_t flags)
{
- QXLImage *qxl = (QXLImage*) QXLPHYSICAL_TO_PTR(p);
+ auto qxl = (QXLImage*) QXLPHYSICAL_TO_PTR(p);
if (!qxl)
return;
@@ -884,7 +884,7 @@ static void red_replay_composite_free(SpiceReplay *replay, QXLComposite *qxl, ui
static QXLDrawable *red_replay_native_drawable(SpiceReplay *replay, uint32_t flags)
{
- QXLDrawable *qxl = (QXLDrawable*) replay_malloc0(replay, sizeof(QXLDrawable)); // TODO - this is too large usually
+ auto qxl = (QXLDrawable*) replay_malloc0(replay, sizeof(QXLDrawable)); // TODO - this is too large usually
int i;
int temp;
@@ -1024,7 +1024,7 @@ static void red_replay_native_drawable_free(SpiceReplay *replay, QXLDrawable *qx
static QXLCompatDrawable *red_replay_compat_drawable(SpiceReplay *replay, uint32_t flags)
{
int temp;
- QXLCompatDrawable *qxl = (QXLCompatDrawable*) replay_malloc0(replay, sizeof(QXLCompatDrawable)); // TODO - too large usually
+ auto qxl = (QXLCompatDrawable*) replay_malloc0(replay, sizeof(QXLCompatDrawable)); // TODO - too large usually
red_replay_rect_ptr(replay, "bbox", &qxl->bbox);
red_replay_clip_ptr(replay, &qxl->clip);
@@ -1102,7 +1102,7 @@ static QXLPHYSICAL red_replay_drawable(SpiceReplay *replay, uint32_t flags)
static QXLUpdateCmd *red_replay_update_cmd(SpiceReplay *replay)
{
- QXLUpdateCmd *qxl = (QXLUpdateCmd*) replay_malloc0(replay, sizeof(QXLUpdateCmd));
+ auto qxl = (QXLUpdateCmd*) replay_malloc0(replay, sizeof(QXLUpdateCmd));
replay_fscanf(replay, "update\n");
red_replay_rect_ptr(replay, "area", &qxl->area);
@@ -1130,7 +1130,7 @@ static QXLSurfaceCmd *red_replay_surface_cmd(SpiceReplay *replay)
size_t size;
size_t read_size;
int temp;
- QXLSurfaceCmd *qxl = (QXLSurfaceCmd*) replay_malloc0(replay, sizeof(QXLSurfaceCmd));
+ auto qxl = (QXLSurfaceCmd*) replay_malloc0(replay, sizeof(QXLSurfaceCmd));
replay_fscanf(replay, "surface_cmd\n");
replay_fscanf(replay, "surface_id %d\n", &qxl->surface_id);
@@ -1213,7 +1213,7 @@ static QXLCursor *red_replay_cursor(SpiceReplay *replay)
static QXLCursorCmd *red_replay_cursor_cmd(SpiceReplay *replay)
{
int temp;
- QXLCursorCmd *qxl = (QXLCursorCmd*) replay_malloc0(replay, sizeof(QXLCursorCmd));
+ auto qxl = (QXLCursorCmd*) replay_malloc0(replay, sizeof(QXLCursorCmd));
replay_fscanf(replay, "cursor_cmd\n");
replay_fscanf(replay, "type %d\n", &temp);
@@ -1244,7 +1244,7 @@ static QXLCursorCmd *red_replay_cursor_cmd(SpiceReplay *replay)
static void red_replay_cursor_cmd_free(SpiceReplay *replay, QXLCursorCmd *qxl)
{
if (qxl->type == QXL_CURSOR_SET) {
- QXLCursor *cursor = (QXLCursor*) QXLPHYSICAL_TO_PTR(qxl->u.set.shape);
+ auto cursor = (QXLCursor*) QXLPHYSICAL_TO_PTR(qxl->u.set.shape);
red_replay_data_chunks_free(replay, cursor, sizeof(*cursor));
}
@@ -1400,22 +1400,22 @@ SPICE_GNUC_VISIBLE void spice_replay_free_cmd(SpiceReplay *replay, QXLCommandExt
case QXL_CMD_DRAW: {
// FIXME: compat flag must be saved somewhere...
spice_return_if_fail(cmd->flags == 0);
- QXLDrawable *qxl = (QXLDrawable*) QXLPHYSICAL_TO_PTR(cmd->cmd.data);
+ auto qxl = (QXLDrawable*) QXLPHYSICAL_TO_PTR(cmd->cmd.data);
red_replay_native_drawable_free(replay, qxl, cmd->flags);
break;
}
case QXL_CMD_UPDATE: {
- QXLUpdateCmd *qxl = (QXLUpdateCmd*) QXLPHYSICAL_TO_PTR(cmd->cmd.data);
+ auto qxl = (QXLUpdateCmd*) QXLPHYSICAL_TO_PTR(cmd->cmd.data);
g_free(qxl);
break;
}
case QXL_CMD_SURFACE: {
- QXLSurfaceCmd *qxl = (QXLSurfaceCmd*) QXLPHYSICAL_TO_PTR(cmd->cmd.data);
+ auto qxl = (QXLSurfaceCmd*) QXLPHYSICAL_TO_PTR(cmd->cmd.data);
red_replay_surface_cmd_free(replay, qxl);
break;
}
case QXL_CMD_CURSOR: {
- QXLCursorCmd *qxl = (QXLCursorCmd*) QXLPHYSICAL_TO_PTR(cmd->cmd.data);
+ auto qxl = (QXLCursorCmd*) QXLPHYSICAL_TO_PTR(cmd->cmd.data);
red_replay_cursor_cmd_free(replay, qxl);
break;
}
diff --git a/server/red-stream-device.cpp b/server/red-stream-device.cpp
index 8f7868bc..ba0871cb 100644
--- a/server/red-stream-device.cpp
+++ b/server/red-stream-device.cpp
@@ -182,10 +182,10 @@ StreamDevice::handle_msg_invalid(const char *error_msg)
write_buffer_get_server(total_size, false);
buf->buf_used = total_size;
- StreamDevHeader *const header = (StreamDevHeader *)buf->buf;
+ auto const header = (StreamDevHeader *)buf->buf;
fill_dev_hdr(header, STREAM_TYPE_NOTIFY_ERROR, msg_size);
- StreamMsgNotifyError *const error = (StreamMsgNotifyError *)(header+1);
+ auto const error = (StreamMsgNotifyError *)(header+1);
error->error_code = GUINT32_TO_LE(0);
strcpy((char *) error->msg, error_msg);
@@ -380,7 +380,7 @@ get_cursor_type_bits(unsigned int cursor_type)
static RedCursorCmd *
stream_msg_cursor_set_to_cursor_cmd(const StreamMsgCursorSet *msg, size_t msg_size)
{
- RedCursorCmd *cmd = g_new0(RedCursorCmd, 1);
+ auto cmd = g_new0(RedCursorCmd, 1);
cmd->type = QXL_CURSOR_SET;
cmd->u.set.position.x = 0; // TODO
cmd->u.set.position.y = 0; // TODO
@@ -477,7 +477,7 @@ StreamDevice::handle_msg_cursor_move()
move->x = GINT32_FROM_LE(move->x);
move->y = GINT32_FROM_LE(move->y);
- RedCursorCmd *cmd = g_new0(RedCursorCmd, 1);
+ auto cmd = g_new0(RedCursorCmd, 1);
cmd->type = QXL_CURSOR_MOVE;
cmd->u.position.x = move->x;
cmd->u.position.y = move->y;
@@ -495,7 +495,7 @@ void
StreamDevice::stream_start(void *opaque, StreamMsgStartStop *start,
StreamChannel *stream_channel G_GNUC_UNUSED)
{
- StreamDevice *dev = (StreamDevice *) opaque;
+ auto dev = (StreamDevice *) opaque;
if (!dev->opened) {
return;
@@ -508,7 +508,7 @@ StreamDevice::stream_start(void *opaque, StreamMsgStartStop *start,
dev->write_buffer_get_server(total_size, false);
buf->buf_used = total_size;
- StreamDevHeader *hdr = (StreamDevHeader *)buf->buf;
+ auto hdr = (StreamDevHeader *)buf->buf;
fill_dev_hdr(hdr, STREAM_TYPE_START_STOP, msg_size);
memcpy(&hdr[1], start, msg_size);
@@ -520,7 +520,7 @@ void
StreamDevice::stream_queue_stat(void *opaque, const StreamQueueStat *stats G_GNUC_UNUSED,
StreamChannel *stream_channel G_GNUC_UNUSED)
{
- StreamDevice *dev = (StreamDevice *) opaque;
+ auto dev = (StreamDevice *) opaque;
if (!dev->opened) {
return;
@@ -632,10 +632,10 @@ send_capabilities(RedCharDevice *char_dev)
char_dev->write_buffer_get_server(total_size, false);
buf->buf_used = total_size;
- StreamDevHeader *const hdr = (StreamDevHeader *)buf->buf;
+ auto const hdr = (StreamDevHeader *)buf->buf;
fill_dev_hdr(hdr, STREAM_TYPE_CAPABILITIES, msg_size);
- StreamMsgCapabilities *const caps = (StreamMsgCapabilities *)(hdr+1);
+ auto const caps = (StreamMsgCapabilities *)(hdr+1);
memset(caps, 0, msg_size);
char_dev->write_buffer_add(buf);
diff --git a/server/red-worker.cpp b/server/red-worker.cpp
index 98ce13a9..b1ea5a6a 100644
--- a/server/red-worker.cpp
+++ b/server/red-worker.cpp
@@ -331,8 +331,8 @@ static void flush_all_qxl_commands(RedWorker *worker)
static void handle_dev_update_async(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
- RedWorkerMessageUpdateAsync *msg = (RedWorkerMessageUpdateAsync*) payload;
+ auto worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageUpdateAsync*) payload;
QXLRect *qxl_dirty_rects = NULL;
uint32_t num_dirty_rects = 0;
@@ -352,8 +352,8 @@ static void handle_dev_update_async(void *opaque, void *payload)
static void handle_dev_update(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
- RedWorkerMessageUpdate *msg = (RedWorkerMessageUpdate*) payload;
+ auto worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageUpdate*) payload;
QXLRect *qxl_dirty_rects = msg->qxl_dirty_rects;
spice_return_if_fail(red_qxl_is_running(worker->qxl));
@@ -369,8 +369,8 @@ static void handle_dev_update(void *opaque, void *payload)
static void handle_dev_del_memslot(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
- RedWorkerMessageDelMemslot *msg = (RedWorkerMessageDelMemslot*) payload;
+ auto worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageDelMemslot*) payload;
uint32_t slot_id = msg->slot_id;
uint32_t slot_group_id = msg->slot_group_id;
@@ -379,8 +379,8 @@ static void handle_dev_del_memslot(void *opaque, void *payload)
static void handle_dev_destroy_surface_wait(void *opaque, void *payload)
{
- RedWorkerMessageDestroySurfaceWait *msg = (RedWorkerMessageDestroySurfaceWait*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageDestroySurfaceWait*) payload;
+ auto worker = (RedWorker*) opaque;
spice_return_if_fail(msg->surface_id == 0);
@@ -390,7 +390,7 @@ static void handle_dev_destroy_surface_wait(void *opaque, void *payload)
static void handle_dev_destroy_surfaces(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
flush_all_qxl_commands(worker);
display_channel_destroy_surfaces(worker->display_channel);
@@ -452,8 +452,8 @@ static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id,
static void handle_dev_create_primary_surface(void *opaque, void *payload)
{
- RedWorkerMessageCreatePrimarySurface *msg = (RedWorkerMessageCreatePrimarySurface*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageCreatePrimarySurface*) payload;
+ auto worker = (RedWorker*) opaque;
dev_create_primary_surface(worker, msg->surface_id, msg->surface);
}
@@ -482,8 +482,8 @@ static void destroy_primary_surface(RedWorker *worker, uint32_t surface_id)
static void handle_dev_destroy_primary_surface(void *opaque, void *payload)
{
- RedWorkerMessageDestroyPrimarySurface *msg = (RedWorkerMessageDestroyPrimarySurface*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageDestroyPrimarySurface*) payload;
+ auto worker = (RedWorker*) opaque;
uint32_t surface_id = msg->surface_id;
destroy_primary_surface(worker, surface_id);
@@ -491,8 +491,8 @@ static void handle_dev_destroy_primary_surface(void *opaque, void *payload)
static void handle_dev_destroy_primary_surface_async(void *opaque, void *payload)
{
- RedWorkerMessageDestroyPrimarySurfaceAsync *msg = (RedWorkerMessageDestroyPrimarySurfaceAsync*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageDestroyPrimarySurfaceAsync*) payload;
+ auto worker = (RedWorker*) opaque;
uint32_t surface_id = msg->surface_id;
destroy_primary_surface(worker, surface_id);
@@ -502,8 +502,8 @@ static void handle_dev_destroy_primary_surface_async(void *opaque, void *payload
static void handle_dev_flush_surfaces_async(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
- RedWorkerMessageFlushSurfacesAsync *msg = (RedWorkerMessageFlushSurfacesAsync*) payload;
+ auto worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageFlushSurfacesAsync*) payload;
flush_all_qxl_commands(worker);
display_channel_flush_all_surfaces(worker->display_channel);
@@ -512,7 +512,7 @@ static void handle_dev_flush_surfaces_async(void *opaque, void *payload)
static void handle_dev_stop(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
spice_debug("stop");
if (!red_qxl_is_running(worker->qxl)) {
@@ -536,7 +536,7 @@ static void handle_dev_stop(void *opaque, void *payload)
static void handle_dev_start(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
if (red_qxl_is_running(worker->qxl)) {
return;
@@ -556,7 +556,7 @@ static void handle_dev_start(void *opaque, void *payload)
static void handle_dev_wakeup(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
stat_inc_counter(worker->wakeup_counter, 1);
red_qxl_clear_pending(worker->qxl->st, RED_DISPATCHER_PENDING_WAKEUP);
@@ -564,7 +564,7 @@ static void handle_dev_wakeup(void *opaque, void *payload)
static void handle_dev_oom(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
DisplayChannel *display = worker->display_channel;
int ring_is_empty;
@@ -585,22 +585,22 @@ static void handle_dev_oom(void *opaque, void *payload)
static void handle_dev_reset_cursor(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
worker->cursor_channel->reset();
}
static void handle_dev_reset_image_cache(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
display_channel_reset_image_cache(worker->display_channel);
}
static void handle_dev_destroy_surface_wait_async(void *opaque, void *payload)
{
- RedWorkerMessageDestroySurfaceWaitAsync *msg = (RedWorkerMessageDestroySurfaceWaitAsync*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageDestroySurfaceWaitAsync*) payload;
+ auto worker = (RedWorker*) opaque;
display_channel_destroy_surface_wait(worker->display_channel, msg->surface_id);
red_qxl_async_complete(worker->qxl, msg->base.cookie);
@@ -608,8 +608,8 @@ static void handle_dev_destroy_surface_wait_async(void *opaque, void *payload)
static void handle_dev_destroy_surfaces_async(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
- RedWorkerMessageDestroySurfacesAsync *msg = (RedWorkerMessageDestroySurfacesAsync*) payload;
+ auto worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageDestroySurfacesAsync*) payload;
flush_all_qxl_commands(worker);
display_channel_destroy_surfaces(worker->display_channel);
@@ -619,8 +619,8 @@ static void handle_dev_destroy_surfaces_async(void *opaque, void *payload)
static void handle_dev_create_primary_surface_async(void *opaque, void *payload)
{
- RedWorkerMessageCreatePrimarySurfaceAsync *msg = (RedWorkerMessageCreatePrimarySurfaceAsync*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageCreatePrimarySurfaceAsync*) payload;
+ auto worker = (RedWorker*) opaque;
dev_create_primary_surface(worker, msg->surface_id, msg->surface);
red_qxl_create_primary_surface_complete(worker->qxl->st, &msg->surface);
@@ -634,8 +634,8 @@ static inline uint32_t qxl_monitors_config_size(uint32_t heads)
static void handle_dev_monitors_config_async(void *opaque, void *payload)
{
- RedWorkerMessageMonitorsConfigAsync *msg = (RedWorkerMessageMonitorsConfigAsync*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageMonitorsConfigAsync*) payload;
+ auto worker = (RedWorker*) opaque;
uint16_t count, max_allowed;
const QXLMonitorsConfig *dev_monitors_config =
(QXLMonitorsConfig*)memslot_get_virt(&worker->mem_slots, msg->monitors_config,
@@ -678,8 +678,8 @@ async_complete:
static void handle_dev_set_compression(void *opaque, void *payload)
{
- RedWorkerMessageSetCompression *msg = (RedWorkerMessageSetCompression*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageSetCompression*) payload;
+ auto worker = (RedWorker*) opaque;
SpiceImageCompression image_compression = msg->image_compression;
display_channel_set_image_compression(worker->display_channel, image_compression);
@@ -690,16 +690,16 @@ static void handle_dev_set_compression(void *opaque, void *payload)
static void handle_dev_set_streaming_video(void *opaque, void *payload)
{
- RedWorkerMessageSetStreamingVideo *msg = (RedWorkerMessageSetStreamingVideo*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageSetStreamingVideo*) payload;
+ auto worker = (RedWorker*) opaque;
display_channel_set_stream_video(worker->display_channel, msg->streaming_video);
}
static void handle_dev_set_video_codecs(void *opaque, void *payload)
{
- RedWorkerMessageSetVideoCodecs *msg = (RedWorkerMessageSetVideoCodecs*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageSetVideoCodecs*) payload;
+ auto worker = (RedWorker*) opaque;
display_channel_set_video_codecs(worker->display_channel, msg->video_codecs);
g_array_unref(msg->video_codecs);
@@ -707,8 +707,8 @@ static void handle_dev_set_video_codecs(void *opaque, void *payload)
static void handle_dev_set_mouse_mode(void *opaque, void *payload)
{
- RedWorkerMessageSetMouseMode *msg = (RedWorkerMessageSetMouseMode*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageSetMouseMode*) payload;
+ auto worker = (RedWorker*) opaque;
spice_debug("mouse mode %u", msg->mode);
worker->cursor_channel->set_mouse_mode(msg->mode);
@@ -723,8 +723,8 @@ static void dev_add_memslot(RedWorker *worker, QXLDevMemSlot mem_slot)
static void handle_dev_add_memslot(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
- RedWorkerMessageAddMemslot *msg = (RedWorkerMessageAddMemslot*) payload;
+ auto worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageAddMemslot*) payload;
QXLDevMemSlot mem_slot = msg->mem_slot;
memslot_info_add_slot(&worker->mem_slots, mem_slot.slot_group_id, mem_slot.slot_id,
@@ -734,8 +734,8 @@ static void handle_dev_add_memslot(void *opaque, void *payload)
static void handle_dev_add_memslot_async(void *opaque, void *payload)
{
- RedWorkerMessageAddMemslotAsync *msg = (RedWorkerMessageAddMemslotAsync*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageAddMemslotAsync*) payload;
+ auto worker = (RedWorker*) opaque;
dev_add_memslot(worker, msg->mem_slot);
red_qxl_async_complete(worker->qxl, msg->base.cookie);
@@ -743,14 +743,14 @@ static void handle_dev_add_memslot_async(void *opaque, void *payload)
static void handle_dev_reset_memslots(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
memslot_info_reset(&worker->mem_slots);
}
static void handle_dev_driver_unload(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
worker->driver_cap_monitors_config = false;
}
@@ -758,7 +758,7 @@ static void handle_dev_driver_unload(void *opaque, void *payload)
static
void handle_dev_gl_scanout(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
display_channel_gl_scanout(worker->display_channel);
}
@@ -766,15 +766,15 @@ void handle_dev_gl_scanout(void *opaque, void *payload)
static
void handle_dev_gl_draw_async(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
- RedWorkerMessageGlDraw *draw = (RedWorkerMessageGlDraw*) payload;
+ auto worker = (RedWorker*) opaque;
+ auto draw = (RedWorkerMessageGlDraw*) payload;
display_channel_gl_draw(worker->display_channel, &draw->draw);
}
static void handle_dev_close(void *opaque, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
g_main_loop_quit(worker->loop);
}
@@ -796,8 +796,8 @@ static bool loadvm_command(RedWorker *worker, QXLCommandExt *ext)
static void handle_dev_loadvm_commands(void *opaque, void *payload)
{
- RedWorkerMessageLoadvmCommands *msg = (RedWorkerMessageLoadvmCommands*) payload;
- RedWorker *worker = (RedWorker*) opaque;
+ auto msg = (RedWorkerMessageLoadvmCommands*) payload;
+ auto worker = (RedWorker*) opaque;
uint32_t i;
uint32_t count = msg->count;
QXLCommandExt *ext = msg->ext;
@@ -813,7 +813,7 @@ static void handle_dev_loadvm_commands(void *opaque, void *payload)
static void worker_dispatcher_record(void *opaque, uint32_t message_type, void *payload)
{
- RedWorker *worker = (RedWorker*) opaque;
+ auto worker = (RedWorker*) opaque;
red_record_event(worker->record, 1, message_type);
}
@@ -1085,7 +1085,7 @@ RedWorker* red_worker_new(QXLInstance *qxl)
static void *red_worker_main(void *arg)
{
- RedWorker *worker = (RedWorker *) arg;
+ auto worker = (RedWorker *) arg;
spice_debug("begin");
#if defined(__APPLE__)
diff --git a/server/reds.cpp b/server/reds.cpp
index 8cec7bbc..58faccc3 100644
--- a/server/reds.cpp
+++ b/server/reds.cpp
@@ -453,7 +453,7 @@ static RedCharDeviceWriteBuffer *vdagent_new_write_buffer(RedCharDeviceVDIPort *
}
char_dev_buf->buf_used = total_msg_size;
- VDInternalBuf *internal_buf = (VDInternalBuf *)char_dev_buf->buf;
+ auto internal_buf = (VDInternalBuf *)char_dev_buf->buf;
internal_buf->chunk_header.port = VDP_SERVER_PORT;
internal_buf->chunk_header.size = sizeof(VDAgentMessage) + size;
internal_buf->header.protocol = VD_AGENT_PROTOCOL;
@@ -505,7 +505,7 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
/* note that client might be NULL, if the vdagent was once
* up and than was removed */
- RedCharDeviceClientOpaque *client_opaque = (RedCharDeviceClientOpaque *) client;
+ auto client_opaque = (RedCharDeviceClientOpaque *) client;
if (reds->agent_dev->client_exists(client_opaque)) {
reds->agent_dev->client_remove(client_opaque);
}
@@ -868,7 +868,7 @@ void reds_send_device_display_info(RedsState *reds)
return;
}
- VDInternalBuf *internal_buf = (VDInternalBuf *)char_dev_buf->buf;
+ auto internal_buf = (VDInternalBuf *)char_dev_buf->buf;
int free_info;
size_t len_info;
@@ -887,15 +887,15 @@ void reds_send_device_display_info(RedsState *reds)
/* after calling this, we unref the message, and the ref is in the instance side */
void RedCharDeviceVDIPort::send_msg_to_client(RedPipeItem *msg, RedCharDeviceClientOpaque *opaque)
{
- RedClient *client = (RedClient *) opaque;
- RedVDIReadBuf *agent_data_buf = static_cast<RedVDIReadBuf*>(msg);
+ auto client = (RedClient *) opaque;
+ auto agent_data_buf = static_cast<RedVDIReadBuf*>(msg);
client->get_main()->push_agent_data(red::shared_ptr<RedAgentDataPipeItem>(agent_data_buf));
}
void RedCharDeviceVDIPort::send_tokens_to_client(RedCharDeviceClientOpaque *opaque, uint32_t tokens)
{
- RedClient *client = (RedClient *) opaque;
+ auto client = (RedClient *) opaque;
client->get_main()->push_agent_tokens(tokens);
}
@@ -916,7 +916,7 @@ void RedCharDeviceVDIPort::on_free_self_token()
void RedCharDeviceVDIPort::remove_client(RedCharDeviceClientOpaque *opaque)
{
- RedClient *client = (RedClient *) opaque;
+ auto client = (RedClient *) opaque;
client->get_main()->shutdown();
}
@@ -945,7 +945,7 @@ void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState *mou
reds->pending_mouse_event = FALSE;
- VDInternalBuf *internal_buf = (VDInternalBuf *)char_dev_buf->buf;
+ auto internal_buf = (VDInternalBuf *)char_dev_buf->buf;
internal_buf->u.mouse_state = *mouse_state;
reds->agent_dev->write_buffer_add(char_dev_buf);
@@ -1020,7 +1020,7 @@ void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t
* and vice versa, the sending from the server to the client won't have
* flow control, but will have no other problem.
*/
- RedCharDeviceClientOpaque *client_opaque = (RedCharDeviceClientOpaque *) client;
+ auto client_opaque = (RedCharDeviceClientOpaque *) client;
if (!dev_state->client_exists(client_opaque)) {
int client_added;
@@ -1463,7 +1463,7 @@ bool reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc,
} else {
spice_debug("agent was not attached on the source host");
if (reds->vdagent) {
- RedCharDeviceClientOpaque *client_opaque =
+ auto client_opaque =
(RedCharDeviceClientOpaque *) mcc->get_client();
/* red_char_device_client_remove disables waiting for migration data */
agent_dev->client_remove(client_opaque);
@@ -1487,7 +1487,7 @@ static void reds_channel_init_auth_caps(RedLinkInfo *link, RedChannel *channel)
static const uint32_t *red_link_info_get_caps(const RedLinkInfo *link)
{
- const uint8_t *caps_start = (const uint8_t *)link->link_mess;
+ const auto caps_start = (const uint8_t *)link->link_mess;
return (const uint32_t *)(caps_start + link->link_mess->caps_offset);
}
@@ -1657,7 +1657,7 @@ static RedsMigTargetClient* reds_mig_target_client_find(RedsState *reds, RedClie
GList *l;
for (l = reds->mig_target_clients; l != NULL; l = l->next) {
- RedsMigTargetClient *mig_client = (RedsMigTargetClient*) l->data;
+ auto mig_client = (RedsMigTargetClient*) l->data;
if (mig_client->client == client) {
return mig_client;
@@ -1890,7 +1890,7 @@ static bool reds_link_mig_target_channels(RedsState *reds, RedClient *client)
/* Each channel should check if we are during migration, and
* act accordingly. */
for(item = mig_client->pending_links; item != NULL; item = item->next) {
- RedsMigPendingLink *mig_link = (RedsMigPendingLink*) item->data;
+ auto mig_link = (RedsMigPendingLink*) item->data;
RedChannel *channel;
channel = reds_find_channel(reds, mig_link->link_msg->channel_type,
@@ -2018,7 +2018,7 @@ static void reds_handle_link(RedLinkInfo *link)
static void reds_handle_ticket(void *opaque)
{
- RedLinkInfo *link = (RedLinkInfo *)opaque;
+ auto link = (RedLinkInfo *)opaque;
RedsState *reds = link->reds;
char *password;
int password_size;
@@ -2113,7 +2113,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
static void reds_handle_auth_mechanism(void *opaque)
{
- RedLinkInfo *link = (RedLinkInfo *)opaque;
+ auto link = (RedLinkInfo *)opaque;
RedsState *reds = link->reds;
spice_debug("Auth method: %d", link->auth_mechanism.auth_mechanism);
@@ -2149,7 +2149,7 @@ static int reds_security_check(RedLinkInfo *link)
static void reds_handle_read_link_done(void *opaque)
{
- RedLinkInfo *link = (RedLinkInfo *)opaque;
+ auto link = (RedLinkInfo *)opaque;
RedsState *reds = link->reds;
SpiceLinkMess *link_mess = link->link_mess;
uint32_t num_caps;
@@ -2223,7 +2223,7 @@ static void reds_handle_read_link_done(void *opaque)
static void reds_handle_link_error(void *opaque, int err)
{
- RedLinkInfo *link = (RedLinkInfo *)opaque;
+ auto link = (RedLinkInfo *)opaque;
switch (err) {
case 0:
case EPIPE:
@@ -2238,7 +2238,7 @@ static void reds_handle_link_error(void *opaque, int err)
static void reds_handle_new_link(RedLinkInfo *link);
static void reds_handle_read_header_done(void *opaque)
{
- RedLinkInfo *link = (RedLinkInfo *)opaque;
+ auto link = (RedLinkInfo *)opaque;
SpiceLinkHeader *header = &link->link_header;
header->major_version = GUINT32_FROM_LE(header->major_version);
@@ -2274,7 +2274,7 @@ static void reds_handle_read_header_done(void *opaque)
static void reds_handle_read_magic_done(void *opaque)
{
- RedLinkInfo *link = (RedLinkInfo *)opaque;
+ auto link = (RedLinkInfo *)opaque;
const SpiceLinkHeader *header = &link->link_header;
if (header->magic != SPICE_MAGIC) {
@@ -2314,7 +2314,7 @@ static void reds_handle_new_link(RedLinkInfo *link)
static void reds_handle_ssl_accept(int fd, int event, void *data)
{
- RedLinkInfo *link = (RedLinkInfo *)data;
+ auto link = (RedLinkInfo *)data;
RedStreamSslStatus return_code = red_stream_ssl_accept(link->stream);
switch (return_code) {
@@ -2404,7 +2404,7 @@ error:
static void reds_accept_ssl_connection(int fd, int event, void *data)
{
- RedsState *reds = (RedsState*) data;
+ auto reds = (RedsState*) data;
RedLinkInfo *link;
int socket;
@@ -2421,7 +2421,7 @@ static void reds_accept_ssl_connection(int fd, int event, void *data)
static void reds_accept(int fd, int event, void *data)
{
- RedsState *reds = (RedsState*) data;
+ auto reds = (RedsState*) data;
int socket;
if ((socket = accept(fd, NULL, 0)) == -1) {
@@ -2674,7 +2674,7 @@ static int load_dh_params(SSL_CTX *ctx, char *file)
/*The password code is not thread safe*/
static int ssl_password_cb(char *buf, int size, int flags, void *userdata)
{
- RedsState *reds = (RedsState*) userdata;
+ auto reds = (RedsState*) userdata;
char *pass = reds->config->ssl_parameters.keyfile_password;
int len = g_strlcpy(buf, pass, size);
if (len >= size) {
@@ -2837,7 +2837,7 @@ SPICE_DESTRUCTOR_FUNC(reds_exit)
pthread_mutex_lock(&global_reds_lock);
for (l = servers; l != NULL; l = l->next) {
- RedsState *reds = (RedsState*) l->data;
+ auto reds = (RedsState*) l->data;
reds_cleanup(reds);
}
pthread_mutex_unlock(&global_reds_lock);
@@ -3047,7 +3047,7 @@ attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstance *sin)
* 2.b If this happens second ==> we already have spice migrate data
* then restore state
*/
- RedCharDeviceClientOpaque *client_opaque =
+ auto client_opaque =
(RedCharDeviceClientOpaque *) reds_get_client(reds);
if (!dev->client_exists(client_opaque)) {
int client_added;
@@ -3438,7 +3438,7 @@ static const char default_video_codecs[] = "spice:mjpeg;" GSTREAMER_CODECS;
SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
{
const char *record_filename;
- RedsState *reds = new RedsState;
+ auto reds = new RedsState;
reds->config = g_new0(RedServerConfig, 1);
reds->config->default_channel_security =
diff --git a/server/sound.cpp b/server/sound.cpp
index 4c636872..af2c1bda 100644
--- a/server/sound.cpp
+++ b/server/sound.cpp
@@ -252,7 +252,7 @@ static void snd_playback_free_frame(PlaybackChannelClient *playback_client, Audi
void PlaybackChannelClient::on_message_marshalled(uint8_t *, void *opaque)
{
- PlaybackChannelClient *client = reinterpret_cast<PlaybackChannelClient*>(opaque);
+ auto client = reinterpret_cast<PlaybackChannelClient*>(opaque);
if (client->in_progress) {
snd_playback_free_frame(client, client->in_progress);
@@ -335,7 +335,7 @@ bool RecordChannelClient::handle_message(uint16_t type, uint32_t size, void *mes
case SPICE_MSGC_RECORD_DATA:
return snd_record_handle_write(this, size, message);
case SPICE_MSGC_RECORD_MODE: {
- SpiceMsgcRecordMode *msg_mode = (SpiceMsgcRecordMode *)message;
+ auto msg_mode = (SpiceMsgcRecordMode *)message;
SndChannel *channel = get_channel();
mode_time = msg_mode->time;
if (msg_mode->mode != SPICE_AUDIO_DATA_MODE_RAW) {
@@ -362,7 +362,7 @@ bool RecordChannelClient::handle_message(uint16_t type, uint32_t size, void *mes
}
case SPICE_MSGC_RECORD_START_MARK: {
- SpiceMsgcRecordStartMark *mark = (SpiceMsgcRecordStartMark *)message;
+ auto mark = (SpiceMsgcRecordStartMark *)message;
start_time = mark->time;
break;
}
@@ -941,13 +941,13 @@ void snd_set_playback_latency(RedClient *client, uint32_t latency)
GList *l;
for (l = snd_channels; l != NULL; l = l->next) {
- SndChannel *now = (SndChannel*) l->data;
+ auto now = (SndChannel*) l->data;
SndChannelClient *scc = snd_channel_get_client(now);
if (now->type() == SPICE_CHANNEL_PLAYBACK && scc &&
scc->get_client() == client) {
if (scc->test_remote_cap(SPICE_PLAYBACK_CAP_LATENCY)) {
- PlaybackChannelClient* playback = (PlaybackChannelClient*)scc;
+ auto playback = (PlaybackChannelClient*)scc;
playback->latency = latency;
snd_set_command(scc, SND_PLAYBACK_LATENCY_MASK);
@@ -1277,7 +1277,7 @@ void snd_set_playback_compression(bool on)
GList *l;
for (l = snd_channels; l != NULL; l = l->next) {
- SndChannel *now = (SndChannel*) l->data;
+ auto now = (SndChannel*) l->data;
SndChannelClient *client = snd_channel_get_client(now);
if (now->type() == SPICE_CHANNEL_PLAYBACK && client) {
PlaybackChannelClient* playback = PLAYBACK_CHANNEL_CLIENT(client);
diff --git a/server/spicevmc.cpp b/server/spicevmc.cpp
index 2e83d788..483c6461 100644
--- a/server/spicevmc.cpp
+++ b/server/spicevmc.cpp
@@ -283,7 +283,7 @@ static void spicevmc_port_send_event(RedChannelClient *rcc, uint8_t event)
void RedCharDeviceSpiceVmc::remove_client(RedCharDeviceClientOpaque *opaque)
{
- RedClient *client = (RedClient *) opaque;
+ auto client = (RedClient *) opaque;
spice_assert(channel->rcc &&
channel->rcc->get_client() == client);
@@ -480,7 +480,7 @@ static void spicevmc_red_channel_send_data(VmcChannelClient *rcc,
SpiceMarshaller *m,
RedPipeItem *item)
{
- RedVmcPipeItem *i = static_cast<RedVmcPipeItem*>(item);
+ auto i = static_cast<RedVmcPipeItem*>(item);
RedVmcChannel *channel = rcc->get_channel();
/* for compatibility send using not compressed data message */
@@ -524,7 +524,7 @@ static void spicevmc_red_channel_send_port_init(RedChannelClient *rcc,
SpiceMarshaller *m,
RedPipeItem *item)
{
- RedPortInitPipeItem *i = static_cast<RedPortInitPipeItem*>(item);
+ auto i = static_cast<RedPortInitPipeItem*>(item);
SpiceMsgPortInit init;
rcc->init_send_data(SPICE_MSG_PORT_INIT);
@@ -538,7 +538,7 @@ static void spicevmc_red_channel_send_port_event(RedChannelClient *rcc,
SpiceMarshaller *m,
RedPipeItem *item)
{
- RedPortEventPipeItem *i = static_cast<RedPortEventPipeItem*>(item);
+ auto i = static_cast<RedPortEventPipeItem*>(item);
SpiceMsgPortEvent event;
rcc->init_send_data(SPICE_MSG_PORT_EVENT);
diff --git a/server/stream-channel.cpp b/server/stream-channel.cpp
index 9b04eddb..abade377 100644
--- a/server/stream-channel.cpp
+++ b/server/stream-channel.cpp
@@ -210,7 +210,7 @@ void StreamChannelClient::send_item(RedPipeItem *pipe_item)
break;
}
case RED_PIPE_ITEM_TYPE_STREAM_CREATE: {
- StreamCreateItem *item = static_cast<StreamCreateItem*>(pipe_item);
+ auto item = static_cast<StreamCreateItem*>(pipe_item);
stream_id = item->stream_create.id;
init_send_data(SPICE_MSG_DISPLAY_STREAM_CREATE);
spice_marshall_msg_display_stream_create(m, &item->stream_create);
@@ -231,7 +231,7 @@ void StreamChannelClient::send_item(RedPipeItem *pipe_item)
break;
}
case RED_PIPE_ITEM_TYPE_STREAM_DATA: {
- StreamDataItem *item = static_cast<StreamDataItem*>(pipe_item);
+ auto item = static_cast<StreamDataItem*>(pipe_item);
init_send_data(SPICE_MSG_DISPLAY_STREAM_DATA);
spice_marshall_msg_display_stream_data(m, &item->data);
pipe_item->add_to_marshaller(m, item->data.data, item->data.data_size);
@@ -465,7 +465,7 @@ StreamChannel::send_data(const void *data, size_t size, uint32_t mm_time)
return;
}
- StreamDataItem *item = new (size) StreamDataItem();
+ auto item = new (size) StreamDataItem();
item->data.base.id = stream_id;
item->data.base.multi_media_time = mm_time;
item->data.data_size = size;
diff --git a/server/tests/test-channel.cpp b/server/tests/test-channel.cpp
index 037677e3..42733718 100644
--- a/server/tests/test-channel.cpp
+++ b/server/tests/test-channel.cpp
@@ -137,7 +137,7 @@ static SpiceTimer *waked_up_timer;
// timer waiting we get data again
static void timer_wakeup(void *opaque)
{
- SpiceCoreInterface *core = (SpiceCoreInterface*) opaque;
+ auto core = (SpiceCoreInterface*) opaque;
// check we are receiving data again
size_t got_data = 0;
@@ -159,7 +159,7 @@ static void timer_wakeup(void *opaque)
// if we arrive here it means we didn't receive too many watch events
static void timeout_watch_count(void *opaque)
{
- SpiceCoreInterface *core = (SpiceCoreInterface*) opaque;
+ auto core = (SpiceCoreInterface*) opaque;
// get all pending data
alarm(1);
diff --git a/server/tests/test-display-base.cpp b/server/tests/test-display-base.cpp
index dea49b07..62683500 100644
--- a/server/tests/test-display-base.cpp
+++ b/server/tests/test-display-base.cpp
@@ -65,7 +65,7 @@ static void test_spice_destroy_update(SimpleSpiceUpdate *update)
return;
}
if (update->drawable.clip.type != SPICE_CLIP_TYPE_NONE) {
- uint8_t *ptr = (uint8_t*)(uintptr_t)update->drawable.clip.data;
+ auto ptr = (uint8_t*)(uintptr_t)update->drawable.clip.data;
g_free(ptr);
}
g_free(update->bitmap);
@@ -357,7 +357,7 @@ static int format_to_bpp(int format)
static SimpleSurfaceCmd *create_surface(int surface_id, int format, int width, int height, uint8_t *data)
{
- SimpleSurfaceCmd *simple_cmd = g_new0(SimpleSurfaceCmd, 1);
+ auto simple_cmd = g_new0(SimpleSurfaceCmd, 1);
QXLSurfaceCmd *surface_cmd = &simple_cmd->surface_cmd;
int bpp = format_to_bpp(format);
@@ -376,7 +376,7 @@ static SimpleSurfaceCmd *create_surface(int surface_id, int format, int width, i
static SimpleSurfaceCmd *destroy_surface(int surface_id)
{
- SimpleSurfaceCmd *simple_cmd = g_new0(SimpleSurfaceCmd, 1);
+ auto simple_cmd = g_new0(SimpleSurfaceCmd, 1);
QXLSurfaceCmd *surface_cmd = &simple_cmd->surface_cmd;
set_cmd(&simple_cmd->ext, QXL_CMD_SURFACE, (intptr_t)surface_cmd);
@@ -637,7 +637,7 @@ static int req_cmd_notification(QXLInstance *qin)
static void do_wakeup(void *opaque)
{
- Test *test = (Test*) opaque;
+ auto test = (Test*) opaque;
int notify;
test->cursor_notify = NOTIFY_CURSOR_BATCH;
@@ -654,7 +654,7 @@ static void do_wakeup(void *opaque)
static void release_resource(SPICE_GNUC_UNUSED QXLInstance *qin,
struct QXLReleaseInfoExt release_info)
{
- QXLCommandExt *ext = (QXLCommandExt*)(uintptr_t)release_info.info->id;
+ auto ext = (QXLCommandExt*)(uintptr_t)release_info.info->id;
//printf("%s\n", __func__);
spice_assert(release_info.group_id == MEM_SLOT_GROUP_ID);
switch (ext->cmd.type) {
@@ -665,7 +665,7 @@ static void release_resource(SPICE_GNUC_UNUSED QXLInstance *qin,
g_free(ext);
break;
case QXL_CMD_CURSOR: {
- QXLCursorCmd *cmd = (QXLCursorCmd *)(uintptr_t)ext->cmd.data;
+ auto cmd = (QXLCursorCmd *)(uintptr_t)ext->cmd.data;
if (cmd->type == QXL_CURSOR_SET || cmd->type == QXL_CURSOR_MOVE) {
g_free(cmd);
}
@@ -914,7 +914,7 @@ static gboolean ignore_in_use_failures(const gchar *log_domain,
Test* test_new(SpiceCoreInterface* core)
{
- Test *test = g_new0(Test, 1);
+ auto test = g_new0(Test, 1);
int port = -1;
test->qxl_instance.base.sif = &display_sif.base;
diff --git a/server/tests/test-stream-device.cpp b/server/tests/test-stream-device.cpp
index bb9852ae..15c2dfad 100644
--- a/server/tests/test-stream-device.cpp
+++ b/server/tests/test-stream-device.cpp
@@ -309,7 +309,7 @@ static void test_stream_device_format_after_data(TestFixture *fixture, gconstpoi
// check empty message
static void test_stream_device_empty(TestFixture *fixture, gconstpointer user_data)
{
- const StreamMsgType msg_type = (StreamMsgType) GPOINTER_TO_INT(user_data);
+ const auto msg_type = (StreamMsgType) GPOINTER_TO_INT(user_data);
uint8_t *p = vmc->message;
// add some messages into device buffer
diff --git a/server/tests/vmc-emu.cpp b/server/tests/vmc-emu.cpp
index f64ddc37..c3311d5e 100644
--- a/server/tests/vmc-emu.cpp
+++ b/server/tests/vmc-emu.cpp
@@ -84,7 +84,7 @@ static const SpiceCharDeviceInterface vmc_interface = {
VmcEmu *vmc_emu_new(const char *subtype, const char *portname)
{
- VmcEmu *vmc = g_new0(VmcEmu, 1);
+ auto vmc = g_new0(VmcEmu, 1);
vmc->vmc_interface = vmc_interface;
vmc->instance.base.sif = &vmc->vmc_interface.base;
vmc->instance.subtype = g_strdup(subtype);
diff --git a/server/tree.cpp b/server/tree.cpp
index 5feadf26..d1073641 100644
--- a/server/tree.cpp
+++ b/server/tree.cpp
@@ -114,7 +114,7 @@ struct DumpItem {
static void dump_item(TreeItem *item, void *data)
{
- DumpItem *di = (DumpItem*) data;
+ auto di = (DumpItem*) data;
const char *item_prefix = "|--";
int i;
@@ -193,7 +193,7 @@ Shadow* shadow_new(DrawItem *item, const SpicePoint *delta)
return NULL;
}
- Shadow *shadow = g_new(Shadow, 1);
+ auto shadow = g_new(Shadow, 1);
shadow->base.type = TREE_ITEM_TYPE_SHADOW;
shadow->base.container = NULL;
@@ -213,7 +213,7 @@ Shadow* shadow_new(DrawItem *item, const SpicePoint *delta)
* container */
Container* container_new(DrawItem *item)
{
- Container *container = g_new(Container, 1);
+ auto container = g_new(Container, 1);
container->base.type = TREE_ITEM_TYPE_CONTAINER;
container->base.container = item->base.container;
@@ -246,7 +246,7 @@ void container_cleanup(Container *container)
Container *next = container->base.container;
if (container->items.next != &container->items) {
SPICE_VERIFY(SPICE_OFFSETOF(TreeItem, siblings_link) == 0);
- TreeItem *item = (TreeItem *)ring_get_head(&container->items);
+ auto item = (TreeItem *)ring_get_head(&container->items);
spice_assert(item);
ring_remove(&item->siblings_link);
ring_add_after(&item->siblings_link, &container->base.siblings_link);
diff --git a/server/video-stream.cpp b/server/video-stream.cpp
index 67432da4..4c8dbc56 100644
--- a/server/video-stream.cpp
+++ b/server/video-stream.cpp
@@ -341,7 +341,7 @@ static void before_reattach_stream(DisplayChannel *display,
index = display_channel_get_video_stream_id(display, stream);
for (dpi_link = stream->current->pipes; dpi_link; dpi_link = dpi_next) {
- RedDrawablePipeItem *dpi = (RedDrawablePipeItem*) dpi_link->data;
+ auto dpi = (RedDrawablePipeItem*) dpi_link->data;
dpi_next = dpi_link->next;
dcc = dpi->dcc;
agent = dcc_get_video_stream_agent(dcc, index);
@@ -649,7 +649,7 @@ static uint64_t get_initial_bit_rate(DisplayChannelClient *dcc, VideoStream *str
static uint32_t get_roundtrip_ms(void *opaque)
{
- VideoStreamAgent *agent = (VideoStreamAgent*) opaque;
+ auto agent = (VideoStreamAgent*) opaque;
int roundtrip;
RedChannelClient *rcc = agent->dcc;
@@ -670,14 +670,14 @@ static uint32_t get_roundtrip_ms(void *opaque)
static uint32_t get_source_fps(void *opaque)
{
- VideoStreamAgent *agent = (VideoStreamAgent*) opaque;
+ auto agent = (VideoStreamAgent*) opaque;
return agent->stream->input_fps;
}
static void update_client_playback_delay(void *opaque, uint32_t delay_ms)
{
- VideoStreamAgent *agent = (VideoStreamAgent*) opaque;
+ auto agent = (VideoStreamAgent*) opaque;
DisplayChannelClient *dcc = agent->dcc;
RedClient *client = dcc->get_client();
RedsState *reds = client->get_server();
@@ -694,13 +694,13 @@ static void update_client_playback_delay(void *opaque, uint32_t delay_ms)
static void bitmap_ref(gpointer data)
{
- RedDrawable *red_drawable = (RedDrawable*)data;
+ auto red_drawable = (RedDrawable*)data;
red_drawable_ref(red_drawable);
}
static void bitmap_unref(gpointer data)
{
- RedDrawable *red_drawable = (RedDrawable*)data;
+ auto red_drawable = (RedDrawable*)data;
red_drawable_unref(red_drawable);
}
More information about the Spice-commits
mailing list