[Spice-commits] 2 commits - server/char-device.cpp server/common-graphics-channel.cpp server/cursor-channel.cpp server/dcc.cpp server/dcc-send.cpp server/dispatcher.cpp server/display-channel.cpp server/image-cache.cpp server/image-encoders.cpp server/inputs-channel-client.cpp server/inputs-channel.cpp server/main-channel-client.cpp server/main-channel.cpp server/pixmap-cache.cpp server/red-channel-client.cpp server/red-channel.cpp server/red-client.cpp server/red-parse-qxl.cpp server/red-qxl.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/spicevmc.cpp server/stream-channel.cpp server/tests server/tree.cpp server/video-stream.cpp
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Apr 12 05:50:54 UTC 2021
server/char-device.cpp | 38 +++----
server/common-graphics-channel.cpp | 2
server/cursor-channel.cpp | 6 -
server/dcc-send.cpp | 44 ++++----
server/dcc.cpp | 28 ++---
server/dispatcher.cpp | 4
server/display-channel.cpp | 84 ++++++++--------
server/image-cache.cpp | 12 +-
server/image-encoders.cpp | 64 ++++++------
server/inputs-channel-client.cpp | 2
server/inputs-channel.cpp | 8 -
server/main-channel-client.cpp | 6 -
server/main-channel.cpp | 4
server/pixmap-cache.cpp | 4
server/red-channel-client.cpp | 50 ++++-----
server/red-channel.cpp | 6 -
server/red-client.cpp | 4
server/red-parse-qxl.cpp | 104 ++++++++++----------
server/red-qxl.cpp | 18 +--
server/red-replay-qxl.cpp | 98 +++++++++----------
server/red-stream-device.cpp | 16 +--
server/red-stream.cpp | 22 ++--
server/red-worker.cpp | 38 +++----
server/reds.cpp | 182 ++++++++++++++++++------------------
server/sound.cpp | 22 ++--
server/spicevmc.cpp | 14 +-
server/stream-channel.cpp | 10 -
server/tests/test-channel.cpp | 6 -
server/tests/test-dispatcher.cpp | 14 +-
server/tests/test-display-base.cpp | 34 +++---
server/tests/test-stream-device.cpp | 20 +--
server/tree.cpp | 18 +--
server/video-stream.cpp | 24 ++--
33 files changed, 503 insertions(+), 503 deletions(-)
New commits:
commit 8af176b15eef8b3b959fa9dba1f8e997fbc621b5
Author: Rosen Penev <rosenp at gmail.com>
Date: Mon Oct 5 02:23:57 2020 -0700
clang-tidy: use nullptr
Found with modernize-use-nullptr
NULL in C++ is 0 whereas it is a void pointer in C. Avoids implicit
conversions.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Acked-by: Frediano Ziglio <freddy77 at gmail.com>
diff --git a/server/char-device.cpp b/server/char-device.cpp
index 2bad1c37..68f8d33a 100644
--- a/server/char-device.cpp
+++ b/server/char-device.cpp
@@ -125,7 +125,7 @@ static void red_char_device_client_free(RedCharDevice *dev,
GList *l, *next;
red_timer_remove(dev_client->wait_for_tokens_timer);
- dev_client->wait_for_tokens_timer = NULL;
+ dev_client->wait_for_tokens_timer = nullptr;
dev_client->send_queue.clear();
@@ -147,7 +147,7 @@ static void red_char_device_client_free(RedCharDevice *dev,
if (dev->priv->cur_write_buf && dev->priv->cur_write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
dev->priv->cur_write_buf->priv->client == dev_client->client) {
dev->priv->cur_write_buf->priv->origin = WRITE_BUFFER_ORIGIN_NONE;
- dev->priv->cur_write_buf->priv->client = NULL;
+ dev->priv->cur_write_buf->priv->client = nullptr;
}
dev->priv->clients = g_list_remove(dev->priv->clients, dev_client);
@@ -170,7 +170,7 @@ static RedCharDeviceClient *red_char_device_client_find(RedCharDevice *dev,
return dev_client;
}
}
- return NULL;
+ return nullptr;
}
/***************************
@@ -264,7 +264,7 @@ static bool red_char_device_read_from_device(RedCharDevice *dev)
* Reading from the device only in case at least one of the clients have a free token.
* All messages will be discarded if no client is attached to the device
*/
- while ((max_send_tokens || (dev->priv->clients == NULL)) && dev->priv->running) {
+ while ((max_send_tokens || (dev->priv->clients == nullptr)) && dev->priv->running) {
auto msg = dev->read_one_msg_from_device();
if (!msg) {
if (dev->priv->during_read_from_device > 1) {
@@ -451,7 +451,7 @@ red_char_device_write_buffer_get(RedCharDevice *dev, RedCharDeviceClientOpaque *
RedCharDeviceWriteBuffer *ret;
if (origin == WRITE_BUFFER_ORIGIN_SERVER && !dev->priv->num_self_tokens) {
- return NULL;
+ return nullptr;
}
struct RedCharDeviceWriteBufferFull {
@@ -499,7 +499,7 @@ red_char_device_write_buffer_get(RedCharDevice *dev, RedCharDeviceClientOpaque *
return ret;
error:
red_char_device_write_buffer_free(ret);
- return NULL;
+ return nullptr;
}
RedCharDeviceWriteBuffer *RedCharDevice::write_buffer_get_client(RedCharDeviceClientOpaque *client,
@@ -514,7 +514,7 @@ RedCharDeviceWriteBuffer *RedCharDevice::write_buffer_get_server(int size,
{
WriteBufferOrigin origin =
use_token ? WRITE_BUFFER_ORIGIN_SERVER : WRITE_BUFFER_ORIGIN_SERVER_NO_TOKEN;
- return red_char_device_write_buffer_get(this, NULL, size, origin, 0);
+ return red_char_device_write_buffer_get(this, nullptr, size, origin, 0);
}
static RedCharDeviceWriteBuffer *red_char_device_write_buffer_ref(RedCharDeviceWriteBuffer *write_buf)
@@ -556,7 +556,7 @@ void RedCharDevice::write_buffer_release(RedCharDevice *dev,
if (!write_buf) {
return;
}
- *p_write_buf = NULL;
+ *p_write_buf = nullptr;
WriteBufferOrigin buf_origin = write_buf->priv->origin;
uint32_t buf_token_price = write_buf->priv->token_price;
@@ -641,7 +641,7 @@ bool RedCharDevice::client_add(RedCharDeviceClientOpaque *client,
spice_assert(client);
- if (wait_for_migrate_data && (priv->clients != NULL || priv->active)) {
+ if (wait_for_migrate_data && (priv->clients != nullptr || priv->active)) {
spice_warning("can't restore device %p from migration data. The device "
"has already been active", this);
return FALSE;
@@ -676,7 +676,7 @@ void RedCharDevice::client_remove(RedCharDeviceClientOpaque *client)
}
red_char_device_client_free(this, dev_client);
if (priv->wait_for_migrate_data) {
- spice_assert(priv->clients == NULL);
+ spice_assert(priv->clients == nullptr);
priv->wait_for_migrate_data = FALSE;
red_char_device_read_from_device(this);
}
@@ -684,7 +684,7 @@ void RedCharDevice::client_remove(RedCharDeviceClientOpaque *client)
int RedCharDevice::client_exists(RedCharDeviceClientOpaque *client)
{
- return (red_char_device_client_find(this, client) != NULL);
+ return (red_char_device_client_find(this, client) != nullptr);
}
void RedCharDevice::start()
@@ -799,7 +799,7 @@ void RedCharDevice::migrate_data_marshall(SpiceMarshaller *m)
}
}
- for (item = g_queue_peek_tail_link(&priv->write_queue); item != NULL; item = item->prev) {
+ for (item = g_queue_peek_tail_link(&priv->write_queue); item != nullptr; item = item->prev) {
auto write_buf = (RedCharDeviceWriteBuffer *) item->data;
spice_marshaller_add_by_ref_full(m2, write_buf->buf, write_buf->buf_used,
@@ -851,7 +851,7 @@ bool RedCharDevice::restore(SpiceMigrateDataCharDevice *mig_data)
mig_data->write_num_client_tokens);
} else {
priv->cur_write_buf =
- red_char_device_write_buffer_get(this, NULL,
+ red_char_device_write_buffer_get(this, nullptr,
mig_data->write_size, WRITE_BUFFER_ORIGIN_SERVER, 0);
}
/* the first write buffer contains all the data that was saved for migration */
@@ -885,9 +885,9 @@ void RedCharDevice::init_device_instance()
g_return_if_fail(priv->reds);
red_timer_remove(priv->write_to_dev_timer);
- priv->write_to_dev_timer = NULL;
+ priv->write_to_dev_timer = nullptr;
- if (priv->sin == NULL) {
+ if (priv->sin == nullptr) {
return;
}
@@ -908,13 +908,13 @@ void RedCharDevice::init_device_instance()
RedCharDevice::~RedCharDevice()
{
red_timer_remove(priv->write_to_dev_timer);
- priv->write_to_dev_timer = NULL;
+ priv->write_to_dev_timer = nullptr;
write_buffers_queue_free(&priv->write_queue);
red_char_device_write_buffer_free(priv->cur_write_buf);
- priv->cur_write_buf = NULL;
+ priv->cur_write_buf = nullptr;
- while (priv->clients != NULL) {
+ while (priv->clients != nullptr) {
auto dev_client = (RedCharDeviceClient *) priv->clients->data;
red_char_device_client_free(this, dev_client);
}
@@ -928,7 +928,7 @@ RedCharDevice::port_event(uint8_t event)
SPICE_GNUC_VISIBLE void spice_server_port_event(SpiceCharDeviceInstance *sin, uint8_t event)
{
- if (sin->st == NULL) {
+ if (sin->st == nullptr) {
spice_warning("no RedCharDevice attached to instance %p", sin);
return;
}
diff --git a/server/common-graphics-channel.cpp b/server/common-graphics-channel.cpp
index c7cac7e9..7f6e5a90 100644
--- a/server/common-graphics-channel.cpp
+++ b/server/common-graphics-channel.cpp
@@ -31,7 +31,7 @@ uint8_t *CommonGraphicsChannelClient::alloc_recv_buf(uint16_t type, uint32_t siz
if (size > sizeof(recv_buf)) {
spice_warning("unexpected message size %u (max is %zd)", size, sizeof(recv_buf));
- return NULL;
+ return nullptr;
}
return recv_buf;
}
diff --git a/server/cursor-channel.cpp b/server/cursor-channel.cpp
index 8944e221..284f6914 100644
--- a/server/cursor-channel.cpp
+++ b/server/cursor-channel.cpp
@@ -229,7 +229,7 @@ void CursorChannel::process_cmd(RedCursorCmd *cursor_cmd)
void CursorChannel::reset()
{
- cursor_channel_set_item(this, NULL);
+ cursor_channel_set_item(this, nullptr);
cursor_visible = true;
cursor_position.x = cursor_position.y = 0;
cursor_trail_length = cursor_trail_frequency = 0;
@@ -261,7 +261,7 @@ static void cursor_channel_init_client(CursorChannel *cursor, CursorChannelClien
void CursorChannel::do_init()
{
- cursor_channel_init_client(this, NULL);
+ cursor_channel_init_client(this, nullptr);
}
void CursorChannel::set_mouse_mode(uint32_t mode)
@@ -281,7 +281,7 @@ void CursorChannel::on_connect(RedClient *client, RedStream *stream, int migrati
ccc = cursor_channel_client_new(this, client, stream,
migration,
caps);
- if (ccc == NULL) {
+ if (ccc == nullptr) {
return;
}
diff --git a/server/dcc-send.cpp b/server/dcc-send.cpp
index 1031c6a6..4d1558a9 100644
--- a/server/dcc-send.cpp
+++ b/server/dcc-send.cpp
@@ -129,7 +129,7 @@ static bool is_surface_area_lossy(DisplayChannelClient *dcc, uint32_t surface_id
static bool is_bitmap_lossy(DisplayChannelClient *dcc, SpiceImage *image, SpiceRect *area,
BitmapData *out_data)
{
- if (image == NULL) {
+ if (image == nullptr) {
// self bitmap
out_data->type = BITMAP_DATA_TYPE_BITMAP;
return FALSE;
@@ -163,7 +163,7 @@ static bool is_brush_lossy(DisplayChannelClient *dcc, SpiceBrush *brush,
BitmapData *out_data)
{
if (brush->type == SPICE_BRUSH_TYPE_PATTERN) {
- return is_bitmap_lossy(dcc, brush->u.pattern.pat, NULL,
+ return is_bitmap_lossy(dcc, brush->u.pattern.pat, nullptr,
out_data);
}
out_data->type = BITMAP_DATA_TYPE_INVALID;
@@ -226,7 +226,7 @@ static void send_free_list_legacy(DisplayChannelClient *dcc)
FreeList *free_list = &dcc->priv->send_data.free_list;
SpiceMarshaller *marshaller;
int sub_list_len = 1;
- SpiceMarshaller *wait_m = NULL;
+ SpiceMarshaller *wait_m = nullptr;
SpiceMarshaller *inval_m;
SpiceMarshaller *sub_list_m;
@@ -350,10 +350,10 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
{
DisplayChannel *display = DCC_TO_DC(dcc);
SpiceImage image;
- compress_send_data_t comp_send_data = {0};
+ compress_send_data_t comp_send_data = {nullptr};
SpiceMarshaller *bitmap_palette_out, *lzplt_palette_out;
- if (simage == NULL) {
+ if (simage == nullptr) {
spice_assert(drawable->red_drawable->self_bitmap_image);
simage = drawable->red_drawable->self_bitmap_image;
}
@@ -381,8 +381,8 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
}
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
- spice_assert(bitmap_palette_out == NULL);
- spice_assert(lzplt_palette_out == NULL);
+ spice_assert(bitmap_palette_out == nullptr);
+ spice_assert(lzplt_palette_out == nullptr);
stat_inc_counter(display->priv->cache_hits_counter, 1);
pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
return FILL_BITS_TYPE_CACHE;
@@ -413,8 +413,8 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
image.u.surface.surface_id = surface_id;
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
- spice_assert(bitmap_palette_out == NULL);
- spice_assert(lzplt_palette_out == NULL);
+ spice_assert(bitmap_palette_out == nullptr);
+ spice_assert(lzplt_palette_out == nullptr);
pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
return FILL_BITS_TYPE_SURFACE;
}
@@ -440,7 +440,7 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
dcc_palette_cache_palette(dcc, palette, &bitmap->flags);
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
- spice_assert(lzplt_palette_out == NULL);
+ spice_assert(lzplt_palette_out == nullptr);
if (bitmap_palette_out && palette) {
spice_marshall_Palette(bitmap_palette_out, palette);
@@ -460,7 +460,7 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
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);
+ spice_assert(bitmap_palette_out == nullptr);
marshaller_add_compressed(m, comp_send_data.comp_buf,
comp_send_data.comp_buf_size);
@@ -479,8 +479,8 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
image.u.quic = simage->u.quic;
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
- spice_assert(bitmap_palette_out == NULL);
- spice_assert(lzplt_palette_out == NULL);
+ spice_assert(bitmap_palette_out == nullptr);
+ spice_assert(lzplt_palette_out == nullptr);
/* 'drawable' owns this image data, so it must be kept
* alive until the message is sent. */
for (unsigned int i = 0; i < image.u.quic.data->num_chunks; i++) {
@@ -1413,9 +1413,9 @@ static void red_lossy_marshall_qxl_draw_composite(DisplayChannelClient *dcc,
SpiceRect dest_lossy_area;
src_is_lossy = is_bitmap_lossy(dcc, drawable->u.composite.src_bitmap,
- NULL, &src_bitmap_data);
+ nullptr, &src_bitmap_data);
mask_is_lossy = drawable->u.composite.mask_bitmap &&
- is_bitmap_lossy(dcc, drawable->u.composite.mask_bitmap, NULL, &mask_bitmap_data);
+ is_bitmap_lossy(dcc, drawable->u.composite.mask_bitmap, nullptr, &mask_bitmap_data);
dest_is_lossy = is_surface_area_lossy(dcc, drawable->surface_id,
&drawable->bbox, &dest_lossy_area);
@@ -1898,7 +1898,7 @@ static void red_marshall_image(DisplayChannelClient *dcc,
bitmap.x = item->width;
bitmap.y = item->height;
bitmap.stride = item->stride;
- bitmap.palette = 0;
+ bitmap.palette = nullptr;
bitmap.palette_id = 0;
chunks = spice_chunks_new_linear(item->data, bitmap.stride * bitmap.y);
@@ -1918,18 +1918,18 @@ static void red_marshall_image(DisplayChannelClient *dcc,
copy.data.src_area.right = bitmap.x;
copy.data.src_area.bottom = bitmap.y;
copy.data.scale_mode = 0;
- copy.data.src_bitmap = 0;
+ copy.data.src_bitmap = nullptr;
copy.data.mask.flags = 0;
copy.data.mask.pos.x = 0;
copy.data.mask.pos.y = 0;
- copy.data.mask.bitmap = 0;
+ copy.data.mask.bitmap = nullptr;
spice_marshall_msg_display_draw_copy(m, ©,
&src_bitmap_out, &mask_bitmap_out);
- compress_send_data_t comp_send_data = {0};
+ compress_send_data_t comp_send_data = {nullptr};
- int comp_succeeded = dcc_compress_image(dcc, &red_image, &bitmap, NULL, item->can_lossy, &comp_send_data);
+ int comp_succeeded = dcc_compress_image(dcc, &red_image, &bitmap, nullptr, item->can_lossy, &comp_send_data);
surface_lossy_region = &dcc->priv->surface_client_lossy_region[item->surface_id];
if (comp_succeeded) {
@@ -2174,7 +2174,7 @@ static void marshall_upgrade(DisplayChannelClient *dcc, SpiceMarshaller *m,
red_drawable = item->drawable->red_drawable;
spice_assert(red_drawable->type == QXL_DRAW_COPY);
spice_assert(red_drawable->u.copy.rop_descriptor == SPICE_ROPD_OP_PUT);
- spice_assert(red_drawable->u.copy.mask.bitmap == 0);
+ spice_assert(red_drawable->u.copy.mask.bitmap == nullptr);
copy.base.surface_id = 0;
copy.base.box = red_drawable->bbox;
@@ -2260,7 +2260,7 @@ static void marshall_gl_scanout(DisplayChannelClient *dcc,
QXLInstance* qxl = display_channel->priv->qxl;
SpiceMsgDisplayGlScanoutUnix *scanout = red_qxl_get_gl_scanout(qxl);
- if (scanout != NULL) {
+ if (scanout != nullptr) {
dcc->init_send_data(SPICE_MSG_DISPLAY_GL_SCANOUT_UNIX);
spice_marshall_msg_display_gl_scanout_unix(m, scanout);
}
diff --git a/server/dcc.cpp b/server/dcc.cpp
index f7b87c72..faf04213 100644
--- a/server/dcc.cpp
+++ b/server/dcc.cpp
@@ -88,7 +88,7 @@ bool dcc_drawable_is_in_pipe(DisplayChannelClient *dcc, Drawable *drawable)
RedDrawablePipeItem *dpi;
GList *l;
- for (l = drawable->pipes; l != NULL; l = l->next) {
+ for (l = drawable->pipes; l != nullptr; l = l->next) {
dpi = (RedDrawablePipeItem *) l->data;
if (dpi->dcc == dcc) {
return TRUE;
@@ -107,14 +107,14 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
{
int x;
- spice_return_val_if_fail(dcc != NULL, TRUE);
+ spice_return_val_if_fail(dcc != nullptr, TRUE);
/* removing the newest drawables that their destination is surface_id and
no other drawable depends on them */
auto &pipe = dcc->get_pipe();
for (auto l = pipe.begin(); l != pipe.end(); ) {
Drawable *drawable;
- RedDrawablePipeItem *dpi = NULL;
+ RedDrawablePipeItem *dpi = nullptr;
int depend_found = FALSE;
RedPipeItem *item = l->get();
auto item_pos = l;
@@ -435,7 +435,7 @@ void dcc_start(DisplayChannelClient *dcc)
if (red_stream_is_plain_unix(dcc->get_stream()) &&
dcc->test_remote_cap(SPICE_DISPLAY_CAP_GL_SCANOUT)) {
- dcc->pipe_add(dcc_gl_scanout_item_new(dcc, NULL, 0));
+ dcc->pipe_add(dcc_gl_scanout_item_new(dcc, nullptr, 0));
dcc_push_monitors_config(dcc);
}
}
@@ -450,7 +450,7 @@ static void dcc_destroy_stream_agents(DisplayChannelClient *dcc)
region_destroy(&agent->clip);
if (agent->video_encoder) {
agent->video_encoder->destroy(agent->video_encoder);
- agent->video_encoder = NULL;
+ agent->video_encoder = nullptr;
}
}
}
@@ -460,7 +460,7 @@ static void dcc_stop(DisplayChannelClient *dcc)
DisplayChannel *dc = DCC_TO_DC(dcc);
pixmap_cache_unref(dcc->priv->pixmap_cache);
- dcc->priv->pixmap_cache = NULL;
+ dcc->priv->pixmap_cache = nullptr;
dcc_palette_cache_reset(dcc);
g_free(dcc->priv->send_data.free_list.res);
dcc_destroy_stream_agents(dcc);
@@ -493,7 +493,7 @@ void dcc_push_monitors_config(DisplayChannelClient *dcc)
DisplayChannel *dc = DCC_TO_DC(dcc);
MonitorsConfig *monitors_config = dc->priv->monitors_config;
- if (monitors_config == NULL) {
+ if (monitors_config == nullptr) {
spice_warning("monitors_config is NULL");
return;
}
@@ -609,7 +609,7 @@ static SpiceImageCompression get_compression_for_bitmap(SpiceBitmap *bitmap,
if (preferred_compression == SPICE_IMAGE_COMPRESSION_AUTO_GLZ ||
preferred_compression == SPICE_IMAGE_COMPRESSION_AUTO_LZ) {
if (can_quic_compress(bitmap)) {
- if (drawable == NULL ||
+ if (drawable == nullptr ||
drawable->copy_bitmap_graduality == BITMAP_GRADUAL_INVALID) {
if (bitmap_fmt_has_graduality(bitmap->format) &&
bitmap_get_graduality_level(bitmap) == BITMAP_GRADUAL_HIGH) {
@@ -630,7 +630,7 @@ static SpiceImageCompression get_compression_for_bitmap(SpiceBitmap *bitmap,
}
if (preferred_compression == SPICE_IMAGE_COMPRESSION_GLZ) {
- if (drawable == NULL || !bitmap_fmt_has_graduality(bitmap->format)) {
+ if (drawable == nullptr || !bitmap_fmt_has_graduality(bitmap->format)) {
preferred_compression = SPICE_IMAGE_COMPRESSION_LZ;
}
}
@@ -720,7 +720,7 @@ lz_compress:
void dcc_palette_cache_palette(DisplayChannelClient *dcc, SpicePalette *palette,
uint8_t *flags)
{
- if (palette == NULL) {
+ if (palette == nullptr) {
return;
}
if (palette->unique) {
@@ -871,7 +871,7 @@ static bool dcc_handle_stream_report(DisplayChannelClient *dcc,
report->stream_id);
/* Stop streaming the video so the client can see it */
agent->video_encoder->destroy(agent->video_encoder);
- agent->video_encoder = NULL;
+ agent->video_encoder = nullptr;
return TRUE;
}
@@ -942,7 +942,7 @@ static void dcc_update_preferred_video_codecs(DisplayChannelClient *dcc)
char *codecs_str;
server_codecs = display_channel_get_video_codecs(DCC_TO_DC(dcc));
- spice_return_if_fail(server_codecs != NULL);
+ spice_return_if_fail(server_codecs != nullptr);
/* Copy current host preference */
video_codecs = g_array_sized_new(FALSE, FALSE, sizeof(RedVideoCodec), server_codecs->len);
@@ -963,7 +963,7 @@ void dcc_video_codecs_update(DisplayChannelClient *dcc)
{
/* Only worry about video-codecs update if client has sent
* SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE */
- if (dcc->priv->client_preferred_video_codecs == NULL) {
+ if (dcc->priv->client_preferred_video_codecs == nullptr) {
return;
}
@@ -988,7 +988,7 @@ static int dcc_handle_preferred_video_codec_type(DisplayChannelClient *dcc,
GArray *dcc_get_preferred_video_codecs_for_encoding(DisplayChannelClient *dcc)
{
- if (dcc->priv->preferred_video_codecs != NULL) {
+ if (dcc->priv->preferred_video_codecs != nullptr) {
return dcc->priv->preferred_video_codecs;
}
return display_channel_get_video_codecs(DCC_TO_DC(dcc));
diff --git a/server/dispatcher.cpp b/server/dispatcher.cpp
index 34f2d251..22be83ac 100644
--- a/server/dispatcher.cpp
+++ b/server/dispatcher.cpp
@@ -85,7 +85,7 @@ Dispatcher::Dispatcher(uint32_t max_message_type):
spice_error("socketpair failed %s", strerror(errno));
return;
}
- pthread_mutex_init(&priv->lock, NULL);
+ pthread_mutex_init(&priv->lock, nullptr);
priv->recv_fd = channels[0];
priv->send_fd = channels[1];
@@ -290,7 +290,7 @@ void Dispatcher::register_handler(uint32_t message_type,
DispatcherMessage *msg;
assert(message_type < priv->max_message_type);
- assert(priv->messages[message_type].handler == NULL);
+ assert(priv->messages[message_type].handler == nullptr);
msg = &priv->messages[message_type];
msg->handler = handler;
msg->size = size;
diff --git a/server/display-channel.cpp b/server/display-channel.cpp
index 50059636..30d025eb 100644
--- a/server/display-channel.cpp
+++ b/server/display-channel.cpp
@@ -45,7 +45,7 @@ DisplayChannel::~DisplayChannel()
spice_assert(ring_is_empty(&priv->streams));
for (count = 0; count < NUM_SURFACES; ++count) {
- spice_assert(priv->surfaces[count].context.canvas == NULL);
+ spice_assert(priv->surfaces[count].context.canvas == nullptr);
}
}
@@ -59,7 +59,7 @@ static Drawable *display_channel_drawable_try_new(DisplayChannel *display,
uint32_t display_channel_generate_uid(DisplayChannel *display)
{
- spice_return_val_if_fail(display != NULL, 0);
+ spice_return_val_if_fail(display != nullptr, 0);
return ++display->priv->bits_unique;
}
@@ -241,17 +241,17 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
spice_assert(surface->context.canvas);
surface->context.canvas->ops->destroy(surface->context.canvas);
- if (surface->create_cmd != NULL) {
+ if (surface->create_cmd != nullptr) {
red_surface_cmd_unref(surface->create_cmd);
- surface->create_cmd = NULL;
+ surface->create_cmd = nullptr;
}
- if (surface->destroy_cmd != NULL) {
+ if (surface->destroy_cmd != nullptr) {
red_surface_cmd_unref(surface->destroy_cmd);
- surface->destroy_cmd = NULL;
+ surface->destroy_cmd = nullptr;
}
region_destroy(&surface->draw_dirty_region);
- surface->context.canvas = NULL;
+ surface->context.canvas = nullptr;
FOREACH_DCC(display, dcc) {
dcc_destroy_surface(dcc, surface_id);
}
@@ -263,7 +263,7 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
gboolean display_channel_surface_has_canvas(DisplayChannel *display,
uint32_t surface_id)
{
- return display->priv->surfaces[surface_id].context.canvas != NULL;
+ return display->priv->surfaces[surface_id].context.canvas != nullptr;
}
static void streams_update_visible_region(DisplayChannel *display, Drawable *drawable)
@@ -310,7 +310,7 @@ static void pipes_add_drawable(DisplayChannel *display, Drawable *drawable)
{
DisplayChannelClient *dcc;
- spice_warn_if_fail(drawable->pipes == NULL);
+ spice_warn_if_fail(drawable->pipes == nullptr);
FOREACH_DCC(display, dcc) {
dcc_prepend_drawable(dcc, drawable);
}
@@ -323,7 +323,7 @@ static void pipes_add_drawable_after(DisplayChannel *display,
DisplayChannelClient *dcc;
int num_other_linked = 0;
- for (GList *l = pos_after->pipes; l != NULL; l = l->next) {
+ for (GList *l = pos_after->pipes; l != nullptr; l = l->next) {
dpi_pos_after = (RedDrawablePipeItem*) l->data;
num_other_linked++;
@@ -338,7 +338,7 @@ static void pipes_add_drawable_after(DisplayChannel *display,
spice_debug("TODO: not O(n^2)");
FOREACH_DCC(display, dcc) {
int sent = 0;
- for (GList *l = pos_after->pipes; l != NULL; l = l->next) {
+ for (GList *l = pos_after->pipes; l != nullptr; l = l->next) {
dpi_pos_after = (RedDrawablePipeItem*) l->data;
if (dpi_pos_after->dcc == dcc) {
sent = 1;
@@ -821,7 +821,7 @@ static bool current_add_with_shadow(DisplayChannel *display, Ring *ring, Drawabl
// only primary surface streams are supported
if (is_primary_surface(display, item->surface_id)) {
- video_stream_detach_behind(display, &shadow->base.rgn, NULL);
+ video_stream_detach_behind(display, &shadow->base.rgn, nullptr);
}
/* Prepend the shadow to the beginning of the current ring */
@@ -837,7 +837,7 @@ static bool current_add_with_shadow(DisplayChannel *display, Ring *ring, Drawabl
* items already in the tree. Start iterating through the tree
* starting with the shadow item to avoid excluding the new item
* itself */
- exclude_region(display, ring, &shadow->base.siblings_link, &exclude_rgn, NULL, NULL);
+ exclude_region(display, ring, &shadow->base.siblings_link, &exclude_rgn, nullptr, nullptr);
region_destroy(&exclude_rgn);
streams_update_visible_region(display, item);
} else {
@@ -856,7 +856,7 @@ static bool current_add(DisplayChannel *display, Ring *ring, Drawable *drawable)
DrawItem *item = &drawable->tree_item;
RingItem *now;
QRegion exclude_rgn;
- RingItem *exclude_base = NULL;
+ RingItem *exclude_base = nullptr;
stat_start(&display->priv->add_stat, start_time);
spice_assert(!region_is_empty(&item->base.rgn));
@@ -924,13 +924,13 @@ static bool current_add(DisplayChannel *display, Ring *ring, Drawable *drawable)
* item is obscured and has a shadow. -jjongsma
*/
TreeItem *next = sibling;
- exclude_region(display, ring, exclude_base, &exclude_rgn, &next, NULL);
+ exclude_region(display, ring, exclude_base, &exclude_rgn, &next, nullptr);
if (next != sibling) {
/* the @next param is only changed if the given item
* was removed as a side-effect of calling
* exclude_region(), so update our loop variable */
- now = next ? &next->siblings_link : NULL;
- exclude_base = NULL;
+ now = next ? &next->siblings_link : nullptr;
+ exclude_base = nullptr;
continue;
}
}
@@ -971,9 +971,9 @@ static bool current_add(DisplayChannel *display, Ring *ring, Drawable *drawable)
* this loop may have added various Shadow::on_hold regions to
* it. */
if (exclude_base) {
- exclude_region(display, ring, exclude_base, &exclude_rgn, NULL, NULL);
+ exclude_region(display, ring, exclude_base, &exclude_rgn, nullptr, nullptr);
region_clear(&exclude_rgn);
- exclude_base = NULL;
+ exclude_base = nullptr;
}
if (sibling->type == TREE_ITEM_TYPE_CONTAINER) {
container = CONTAINER(sibling);
@@ -1021,7 +1021,7 @@ static bool current_add(DisplayChannel *display, Ring *ring, Drawable *drawable)
* Shadows that were associated with DrawItems that were removed from
* the tree. Add the new item's region to that */
region_or(&exclude_rgn, &item->base.rgn);
- exclude_region(display, ring, exclude_base, &exclude_rgn, NULL, drawable);
+ exclude_region(display, ring, exclude_base, &exclude_rgn, nullptr, drawable);
video_stream_trace_update(display, drawable);
streams_update_visible_region(display, drawable);
/*
@@ -1067,7 +1067,7 @@ static bool drawable_can_stream(DisplayChannel *display, Drawable *drawable)
}
image = red_drawable->u.copy.src_bitmap;
- if (image == NULL ||
+ if (image == nullptr ||
image->descriptor.type != SPICE_IMAGE_TYPE_BITMAP) {
return FALSE;
}
@@ -1167,7 +1167,7 @@ static void handle_self_bitmap(DisplayChannel *display, Drawable *drawable)
image->u.bitmap.stride = dest_stride;
image->descriptor.width = image->u.bitmap.x = width;
image->descriptor.height = image->u.bitmap.y = height;
- image->u.bitmap.palette = NULL;
+ image->u.bitmap.palette = nullptr;
dest = (uint8_t *)spice_malloc_n(height, dest_stride);
image->u.bitmap.data = spice_chunks_new_linear(dest, height * dest_stride);
@@ -1198,7 +1198,7 @@ static void surface_add_reverse_dependency(DisplayChannel *display, int surface_
RedSurface *surface;
if (surface_id == -1) {
- depend_item->drawable = NULL;
+ depend_item->drawable = nullptr;
return;
}
@@ -1223,7 +1223,7 @@ static bool handle_surface_deps(DisplayChannel *display, Drawable *drawable)
QRegion depend_region;
region_init(&depend_region);
region_add(&depend_region, &drawable->red_drawable->surfaces_rects[x]);
- video_stream_detach_behind(display, &depend_region, NULL);
+ video_stream_detach_behind(display, &depend_region, nullptr);
}
}
}
@@ -1293,18 +1293,18 @@ static Drawable *display_channel_get_drawable(DisplayChannel *display, uint8_t e
* to avoid invalid updates if we find an invalid id.
*/
if (!validate_drawable_bbox(display, red_drawable)) {
- return NULL;
+ return nullptr;
}
for (x = 0; x < 3; ++x) {
if (red_drawable->surface_deps[x] != -1
&& !display_channel_validate_surface(display, red_drawable->surface_deps[x])) {
- return NULL;
+ return nullptr;
}
}
drawable = display_channel_drawable_try_new(display, process_commands_generation);
if (!drawable) {
- return NULL;
+ return nullptr;
}
drawable->tree_item.effect = effect;
@@ -1528,7 +1528,7 @@ static Drawable* drawable_try_new(DisplayChannel *display)
Drawable *drawable;
if (!display->priv->free_drawables)
- return NULL;
+ return nullptr;
drawable = &display->priv->free_drawables->u.drawable;
display->priv->free_drawables = display->priv->free_drawables->u.next;
@@ -1547,7 +1547,7 @@ static void drawables_init(DisplayChannel *display)
{
int i;
- display->priv->free_drawables = NULL;
+ display->priv->free_drawables = nullptr;
for (i = 0; i < NUM_DRAWABLES; i++) {
drawable_free(display, &display->priv->drawables[i].u.drawable);
}
@@ -1565,7 +1565,7 @@ static Drawable *display_channel_drawable_try_new(DisplayChannel *display,
while (!(drawable = drawable_try_new(display))) {
if (!free_one_drawable(display, FALSE))
- return NULL;
+ return nullptr;
}
memset(drawable, 0, sizeof(Drawable));
@@ -1591,7 +1591,7 @@ static void depended_item_remove(DependItem *item)
spice_return_if_fail(item->drawable);
spice_return_if_fail(ring_item_is_linked(&item->ring_item));
- item->drawable = NULL;
+ item->drawable = nullptr;
ring_remove(&item->ring_item);
}
@@ -1630,7 +1630,7 @@ void drawable_unref(Drawable *drawable)
return;
spice_warn_if_fail(!drawable->tree_item.shadow);
- spice_warn_if_fail(drawable->pipes == NULL);
+ spice_warn_if_fail(drawable->pipes == nullptr);
if (drawable->stream) {
video_stream_detach_drawable(drawable->stream);
@@ -1859,12 +1859,12 @@ static Drawable* current_find_intersects_rect(Ring *current, RingItem *from,
{
RingItem *it;
QRegion rgn;
- Drawable *last = NULL;
+ Drawable *last = nullptr;
region_init(&rgn);
region_add(&rgn, area);
- for (it = from ? from : ring_next(current, current); it != NULL; it = ring_next(current, it)) {
+ for (it = from ? from : ring_next(current, current); it != nullptr; it = ring_next(current, it)) {
Drawable *now = SPICE_CONTAINEROF(it, Drawable, surface_list_link);
if (region_intersects(&rgn, &now->tree_item.base.rgn)) {
last = now;
@@ -1885,7 +1885,7 @@ void display_channel_draw_until(DisplayChannel *display, const SpiceRect *area,
Drawable *last)
{
RedSurface *surface;
- Drawable *surface_last = NULL;
+ Drawable *surface_last = nullptr;
Ring *ring;
RingItem *ring_item;
Drawable *now;
@@ -1937,7 +1937,7 @@ void display_channel_draw(DisplayChannel *display, const SpiceRect *area, int su
surface = &display->priv->surfaces[surface_id];
- last = current_find_intersects_rect(&surface->current_list, NULL, area);
+ last = current_find_intersects_rect(&surface->current_list, nullptr, area);
if (last)
draw_until(display, surface, last);
@@ -1977,7 +1977,7 @@ void display_channel_update(DisplayChannel *display,
display_channel_draw(display, &rect, surface_id);
surface = &display->priv->surfaces[surface_id];
- if (*qxl_dirty_rects == NULL) {
+ if (*qxl_dirty_rects == nullptr) {
*num_dirty_rects = pixman_region32_n_rects(&surface->draw_dirty_region);
*qxl_dirty_rects = g_new0(QXLRect, *num_dirty_rects);
}
@@ -2074,7 +2074,7 @@ create_canvas_for_surface(DisplayChannel *display, RedSurface *surface, uint32_t
canvas = canvas_create_for_data(surface->context.width, surface->context.height, surface->context.format,
(uint8_t*) surface->context.line_0, surface->context.stride,
&display->priv->image_cache.base,
- &display->priv->image_surfaces, NULL, NULL, NULL);
+ &display->priv->image_surfaces, nullptr, nullptr, nullptr);
surface->context.top_down = TRUE;
surface->context.canvas_draws_on_surface = TRUE;
return canvas;
@@ -2082,7 +2082,7 @@ create_canvas_for_surface(DisplayChannel *display, RedSurface *surface, uint32_t
spice_warn_if_reached();
};
- return NULL;
+ return nullptr;
}
void display_channel_create_surface(DisplayChannel *display, uint32_t surface_id, uint32_t width,
@@ -2106,8 +2106,8 @@ void display_channel_create_surface(DisplayChannel *display, uint32_t surface_id
}
memset(data, 0, height*abs(stride));
}
- g_warn_if_fail(surface->create_cmd == NULL);
- g_warn_if_fail(surface->destroy_cmd == NULL);
+ g_warn_if_fail(surface->create_cmd == nullptr);
+ g_warn_if_fail(surface->destroy_cmd == nullptr);
ring_init(&surface->current);
ring_init(&surface->current_list);
ring_init(&surface->depend_on_me);
@@ -2309,7 +2309,7 @@ static void display_channel_update_compression(DisplayChannel *display, DisplayC
void display_channel_gl_scanout(DisplayChannel *display)
{
- display->pipes_new_add(dcc_gl_scanout_item_new, NULL);
+ display->pipes_new_add(dcc_gl_scanout_item_new, nullptr);
}
static void set_gl_draw_async_count(DisplayChannel *display, int num)
diff --git a/server/image-cache.cpp b/server/image-cache.cpp
index 4881f4d9..960e6ca9 100644
--- a/server/image-cache.cpp
+++ b/server/image-cache.cpp
@@ -30,7 +30,7 @@ static ImageCacheItem *image_cache_find(ImageCache *cache, uint64_t id)
}
item = item->next;
}
- return NULL;
+ return nullptr;
}
static bool image_cache_hit(ImageCache *cache, uint64_t id)
@@ -163,9 +163,9 @@ void image_cache_localize(ImageCache *cache, SpiceImage **image_ptr,
{
SpiceImage *image = *image_ptr;
- if (image == NULL) {
- spice_assert(drawable != NULL);
- spice_assert(drawable->red_drawable->self_bitmap_image != NULL);
+ if (image == nullptr) {
+ spice_assert(drawable != nullptr);
+ spice_assert(drawable->red_drawable->self_bitmap_image != nullptr);
*image_ptr = drawable->red_drawable->self_bitmap_image;
return;
}
@@ -204,13 +204,13 @@ void image_cache_localize(ImageCache *cache, SpiceImage **image_ptr,
void image_cache_localize_brush(ImageCache *cache, SpiceBrush *brush, SpiceImage *image_store)
{
if (brush->type == SPICE_BRUSH_TYPE_PATTERN) {
- image_cache_localize(cache, &brush->u.pattern.pat, image_store, NULL);
+ image_cache_localize(cache, &brush->u.pattern.pat, image_store, nullptr);
}
}
void image_cache_localize_mask(ImageCache *cache, SpiceQMask *mask, SpiceImage *image_store)
{
if (mask->bitmap) {
- image_cache_localize(cache, &mask->bitmap, image_store, NULL);
+ image_cache_localize(cache, &mask->bitmap, image_store, nullptr);
}
}
diff --git a/server/image-encoders.cpp b/server/image-encoders.cpp
index f7d04741..bb70fa63 100644
--- a/server/image-encoders.cpp
+++ b/server/image-encoders.cpp
@@ -202,7 +202,7 @@ static void encoder_data_init(EncoderData *data)
{
data->bufs_tail = g_new(RedCompressBuf, 1);
data->bufs_head = data->bufs_tail;
- data->bufs_head->send_next = NULL;
+ data->bufs_head->send_next = nullptr;
}
static void encoder_data_reset(EncoderData *data)
@@ -213,7 +213,7 @@ static void encoder_data_reset(EncoderData *data)
g_free(buf);
buf = next;
}
- data->bufs_head = data->bufs_tail = NULL;
+ data->bufs_head = data->bufs_tail = nullptr;
}
/* Allocate more space for compressed buffer.
@@ -226,7 +226,7 @@ static int encoder_usr_more_space(EncoderData *enc_data, uint8_t **io_ptr)
buf = g_new(RedCompressBuf, 1);
enc_data->bufs_tail->send_next = buf;
enc_data->bufs_tail = buf;
- buf->send_next = NULL;
+ buf->send_next = nullptr;
*io_ptr = buf->buf.bytes;
return sizeof(buf->buf);
}
@@ -458,7 +458,7 @@ void image_encoders_init(ImageEncoders *enc, ImageEncoderSharedData *shared_data
ring_init(&enc->glz_drawables);
ring_init(&enc->glz_drawables_inst_to_free);
- pthread_mutex_init(&enc->glz_drawables_inst_to_free_lock, NULL);
+ pthread_mutex_init(&enc->glz_drawables_inst_to_free_lock, nullptr);
image_encoders_init_glz_data(enc);
image_encoders_init_quic(enc);
@@ -477,18 +477,18 @@ void image_encoders_free(ImageEncoders *enc)
{
image_encoders_release_glz(enc);
quic_destroy(enc->quic);
- enc->quic = NULL;
+ enc->quic = nullptr;
lz_destroy(enc->lz);
- enc->lz = NULL;
+ enc->lz = nullptr;
jpeg_encoder_destroy(enc->jpeg);
- enc->jpeg = NULL;
+ enc->jpeg = nullptr;
#ifdef USE_LZ4
lz4_encoder_destroy(enc->lz4);
- enc->lz4 = NULL;
+ enc->lz4 = nullptr;
#endif
- if (enc->zlib != NULL) {
+ if (enc->zlib != nullptr) {
zlib_encoder_destroy(enc->zlib);
- enc->zlib = NULL;
+ enc->zlib = nullptr;
}
pthread_mutex_destroy(&enc->glz_drawables_inst_to_free_lock);
}
@@ -543,7 +543,7 @@ static void red_glz_drawable_free(RedGlzDrawable *glz_drawable)
{
ImageEncoders *enc = glz_drawable->encoders;
RingItem *head_instance = ring_get_head(&glz_drawable->instances);
- int cont = (head_instance != NULL);
+ int cont = (head_instance != nullptr);
while (cont) {
if (glz_drawable->instances_count == 1) {
@@ -597,7 +597,7 @@ int image_encoders_free_some_independent_glz_drawables(ImageEncoders *enc)
return 0;
}
ring_link = ring_get_head(&enc->glz_drawables);
- while ((n < RED_RELEASE_BUNCH_SIZE) && (ring_link != NULL)) {
+ while ((n < RED_RELEASE_BUNCH_SIZE) && (ring_link != nullptr)) {
RedGlzDrawable *glz_drawable = SPICE_CONTAINEROF(ring_link, RedGlzDrawable, link);
ring_link = ring_next(&enc->glz_drawables, ring_link);
if (!glz_drawable->has_drawable) {
@@ -686,7 +686,7 @@ void image_encoders_glz_get_restore_data(ImageEncoders *enc,
static GlzSharedDictionary *glz_shared_dictionary_new(RedClient *client, uint8_t id,
GlzEncDictContext *dict)
{
- spice_return_val_if_fail(dict != NULL, NULL);
+ spice_return_val_if_fail(dict != nullptr, NULL);
auto shared_dict = g_new0(GlzSharedDictionary, 1);
@@ -695,7 +695,7 @@ static GlzSharedDictionary *glz_shared_dictionary_new(RedClient *client, uint8_t
shared_dict->refs = 1;
shared_dict->migrate_freeze = FALSE;
shared_dict->client = client;
- pthread_rwlock_init(&shared_dict->encode_lock, NULL);
+ pthread_rwlock_init(&shared_dict->encode_lock, nullptr);
return shared_dict;
}
@@ -706,9 +706,9 @@ static GList *glz_dictionary_list;
static GlzSharedDictionary *find_glz_dictionary(RedClient *client, uint8_t dict_id)
{
GList *l;
- GlzSharedDictionary *ret = NULL;
+ GlzSharedDictionary *ret = nullptr;
- for (l = glz_dictionary_list; l != NULL; l = l->next) {
+ for (l = glz_dictionary_list; l != nullptr; l = l->next) {
auto dict = (GlzSharedDictionary *) l->data;
if ((dict->client == client) && (dict->id == dict_id)) {
ret = dict;
@@ -748,14 +748,14 @@ gboolean image_encoders_get_glz_dictionary(ImageEncoders *enc,
shared_dict->refs++;
} else {
shared_dict = create_glz_dictionary(enc, client, id, window_size);
- if (shared_dict != NULL) {
+ if (shared_dict != nullptr) {
glz_dictionary_list = g_list_prepend(glz_dictionary_list, shared_dict);
}
}
pthread_mutex_unlock(&glz_dictionary_list_lock);
enc->glz_dict = shared_dict;
- return shared_dict != NULL;
+ return shared_dict != nullptr;
}
static GlzSharedDictionary *restore_glz_dictionary(ImageEncoders *enc,
@@ -774,7 +774,7 @@ gboolean image_encoders_restore_glz_dictionary(ImageEncoders *enc,
uint8_t id,
GlzEncDictRestoreData *restore_data)
{
- GlzSharedDictionary *shared_dict = NULL;
+ GlzSharedDictionary *shared_dict = nullptr;
spice_return_val_if_fail(!enc->glz_dict, FALSE);
@@ -786,20 +786,20 @@ gboolean image_encoders_restore_glz_dictionary(ImageEncoders *enc,
shared_dict->refs++;
} else {
shared_dict = restore_glz_dictionary(enc, client, id, restore_data);
- if(shared_dict != NULL) {
+ if(shared_dict != nullptr) {
glz_dictionary_list = g_list_prepend(glz_dictionary_list, shared_dict);
}
}
pthread_mutex_unlock(&glz_dictionary_list_lock);
enc->glz_dict = shared_dict;
- return shared_dict != NULL;
+ return shared_dict != nullptr;
}
gboolean image_encoders_glz_create(ImageEncoders *enc, uint8_t id)
{
enc->glz = glz_encoder_create(id, enc->glz_dict->dict, &enc->glz_data.usr);
- return enc->glz != NULL;
+ return enc->glz != nullptr;
}
/* destroy encoder, and dictionary if no one uses it*/
@@ -810,13 +810,13 @@ static void image_encoders_release_glz(ImageEncoders *enc)
image_encoders_free_glz_drawables(enc);
glz_encoder_destroy(enc->glz);
- enc->glz = NULL;
+ enc->glz = nullptr;
if (!(shared_dict = enc->glz_dict)) {
return;
}
- enc->glz_dict = NULL;
+ enc->glz_dict = nullptr;
pthread_mutex_lock(&glz_dictionary_list_lock);
if (--shared_dict->refs != 0) {
pthread_mutex_unlock(&glz_dictionary_list_lock);
@@ -880,7 +880,7 @@ bool image_encoders_compress_quic(ImageEncoders *enc, SpiceImage *dest,
quic_data->data.u.lines_data.reverse = 1;
stride = -src->stride;
}
- size = quic_encode(quic, type, src->x, src->y, NULL, 0, stride,
+ size = quic_encode(quic, type, src->x, src->y, nullptr, 0, stride,
quic_data->data.bufs_head->buf.words,
G_N_ELEMENTS(quic_data->data.bufs_head->buf.words));
@@ -942,7 +942,7 @@ bool image_encoders_compress_lz(ImageEncoders *enc,
size = lz_encode(lz, type, src->x, src->y,
!!(src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN),
- NULL, 0, src->stride,
+ nullptr, 0, src->stride,
lz_data->data.bufs_head->buf.bytes,
sizeof(lz_data->data.bufs_head->buf));
@@ -1038,7 +1038,7 @@ bool image_encoders_compress_jpeg(ImageEncoders *enc, SpiceImage *dest,
stride = -src->stride;
}
jpeg_size = jpeg_encode(jpeg, enc->jpeg_quality, jpeg_in_type,
- src->x, src->y, NULL,
+ src->x, src->y, nullptr,
0, stride, jpeg_data->data.bufs_head->buf.bytes,
sizeof(jpeg_data->data.bufs_head->buf));
@@ -1074,7 +1074,7 @@ bool image_encoders_compress_jpeg(ImageEncoders *enc, SpiceImage *dest,
alpha_lz_size = lz_encode(lz, LZ_IMAGE_TYPE_XXXA, src->x, src->y,
!!(src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN),
- NULL, 0, src->stride,
+ nullptr, 0, src->stride,
lz_out_start_byte,
comp_head_left);
@@ -1194,7 +1194,7 @@ static GlzDrawableInstanceItem *add_glz_drawable_instance(RedGlzDrawable *glz_dr
ring_item_init(&ret->free_link);
ring_item_init(&ret->glz_link);
ring_add(&glz_drawable->instances, &ret->glz_link);
- ret->context = NULL;
+ ret->context = nullptr;
ret->glz_drawable = glz_drawable;
return ret;
@@ -1244,7 +1244,7 @@ bool image_encoders_compress_glz(ImageEncoders *enc,
glz_data->data.u.lines_data.reverse = 0;
glz_size = glz_encode(enc->glz, type, src->x, src->y,
- (src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN), NULL, 0,
+ (src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN), nullptr, 0,
src->stride, glz_data->data.bufs_head->buf.bytes,
sizeof(glz_data->data.bufs_head->buf),
glz_drawable_instance,
@@ -1255,9 +1255,9 @@ bool image_encoders_compress_glz(ImageEncoders *enc,
if (!enable_zlib_glz_wrap || (glz_size < MIN_GLZ_SIZE_FOR_ZLIB)) {
goto glz;
}
- if (enc->zlib == NULL) {
+ if (enc->zlib == nullptr) {
enc->zlib = zlib_encoder_create(&enc->zlib_data.usr, ZLIB_DEFAULT_COMPRESSION_LEVEL);
- if (enc->zlib == NULL) {
+ if (enc->zlib == nullptr) {
g_warning("creating zlib encoder failed");
goto glz;
}
diff --git a/server/inputs-channel-client.cpp b/server/inputs-channel-client.cpp
index 0c8ff0cf..9d3a9131 100644
--- a/server/inputs-channel-client.cpp
+++ b/server/inputs-channel-client.cpp
@@ -24,7 +24,7 @@ uint8_t *InputsChannelClient::alloc_recv_buf(uint16_t type, uint32_t size)
{
if (size > sizeof(recv_buf)) {
red_channel_warning(get_channel(), "error: too large incoming message");
- return NULL;
+ return nullptr;
}
return recv_buf;
diff --git a/server/inputs-channel.cpp b/server/inputs-channel.cpp
index 1e134f16..1e4d6dd9 100644
--- a/server/inputs-channel.cpp
+++ b/server/inputs-channel.cpp
@@ -570,16 +570,16 @@ int InputsChannel::set_tablet(SpiceTabletInstance *new_tablet)
bool InputsChannel::has_tablet() const
{
- return tablet != NULL;
+ return tablet != nullptr;
}
void InputsChannel::detach_tablet(SpiceTabletInstance *old_tablet)
{
- if (old_tablet != NULL && old_tablet == tablet) {
+ if (old_tablet != nullptr && old_tablet == tablet) {
spice_tablet_state_free(old_tablet->st);
- old_tablet->st = NULL;
+ old_tablet->st = nullptr;
}
- tablet = NULL;
+ tablet = nullptr;
}
bool InputsChannel::is_src_during_migrate() const
diff --git a/server/main-channel-client.cpp b/server/main-channel-client.cpp
index d1f031cc..73e0d56e 100644
--- a/server/main-channel-client.cpp
+++ b/server/main-channel-client.cpp
@@ -119,7 +119,7 @@ uint8_t *MainChannelClient::alloc_recv_buf(uint16_t type, uint32_t size)
if (size > sizeof(priv->recv_buf)) {
/* message too large, caller will log a message and close the connection */
- return NULL;
+ return nullptr;
}
return priv->recv_buf;
@@ -683,7 +683,7 @@ static void main_channel_fill_migrate_dst_info(MainChannel *main_channel,
dst_info->cert_subject_data = (uint8_t *)mig_dst->cert_subject;
} else {
dst_info->cert_subject_size = 0;
- dst_info->cert_subject_data = NULL;
+ dst_info->cert_subject_data = nullptr;
}
}
@@ -740,7 +740,7 @@ static void main_channel_marshall_migrate_switch(SpiceMarshaller *m, MainChannel
migrate.cert_subject_data = (uint8_t *)mig_target->cert_subject;
} else {
migrate.cert_subject_size = 0;
- migrate.cert_subject_data = NULL;
+ migrate.cert_subject_data = nullptr;
}
spice_marshall_msg_main_migrate_switch_host(m, &migrate);
}
diff --git a/server/main-channel.cpp b/server/main-channel.cpp
index 4abfd3bc..f6db2161 100644
--- a/server/main-channel.cpp
+++ b/server/main-channel.cpp
@@ -36,7 +36,7 @@ RedClient *MainChannel::get_client_by_link_id(uint32_t connection_id)
return rcc->get_client();
}
}
- return NULL;
+ return nullptr;
}
static void main_channel_push_channels(MainChannelClient *mcc)
@@ -116,7 +116,7 @@ static void main_channel_fill_mig_target(MainChannel *main_channel, RedsMigSpice
if (mig_target->cert_subject) {
main_channel->mig_target.cert_subject = g_strdup(mig_target->cert_subject);
} else {
- main_channel->mig_target.cert_subject = NULL;
+ main_channel->mig_target.cert_subject = nullptr;
}
main_channel->mig_target.port = mig_target->port;
main_channel->mig_target.sport = mig_target->sport;
diff --git a/server/pixmap-cache.cpp b/server/pixmap-cache.cpp
index 699f73a9..03ea80f9 100644
--- a/server/pixmap-cache.cpp
+++ b/server/pixmap-cache.cpp
@@ -93,7 +93,7 @@ static PixmapCache *pixmap_cache_new(RedClient *client, uint8_t id, int64_t size
auto cache = g_new0(PixmapCache, 1);
ring_item_init(&cache->base);
- pthread_mutex_init(&cache->lock, NULL);
+ pthread_mutex_init(&cache->lock, nullptr);
cache->id = id;
cache->refs = 1;
ring_init(&cache->lru);
@@ -106,7 +106,7 @@ static PixmapCache *pixmap_cache_new(RedClient *client, uint8_t id, int64_t size
PixmapCache *pixmap_cache_get(RedClient *client, uint8_t id, int64_t size)
{
- PixmapCache *ret = NULL;
+ PixmapCache *ret = nullptr;
RingItem *now;
pthread_mutex_lock(&cache_lock);
diff --git a/server/red-channel-client.cpp b/server/red-channel-client.cpp
index 635d1f0a..3ba0b4f0 100644
--- a/server/red-channel-client.cpp
+++ b/server/red-channel-client.cpp
@@ -202,7 +202,7 @@ static void full_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t
static uint16_t full_header_get_msg_type(SpiceDataHeaderOpaque *header);
static uint32_t full_header_get_msg_size(SpiceDataHeaderOpaque *header);
-static const SpiceDataHeaderOpaque full_header_wrapper = {NULL, sizeof(SpiceDataHeader),
+static const SpiceDataHeaderOpaque full_header_wrapper = {nullptr, sizeof(SpiceDataHeader),
full_header_set_msg_type,
full_header_set_msg_size,
full_header_set_msg_serial,
@@ -217,7 +217,7 @@ static void mini_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t
static uint16_t mini_header_get_msg_type(SpiceDataHeaderOpaque *header);
static uint32_t mini_header_get_msg_size(SpiceDataHeaderOpaque *header);
-static const SpiceDataHeaderOpaque mini_header_wrapper = {NULL, sizeof(SpiceMiniDataHeader),
+static const SpiceDataHeaderOpaque mini_header_wrapper = {nullptr, sizeof(SpiceMiniDataHeader),
mini_header_set_msg_type,
mini_header_set_msg_size,
mini_header_set_msg_serial,
@@ -334,10 +334,10 @@ RedChannelClientPrivate::RedChannelClientPrivate(RedChannel *init_channel,
RedChannelClientPrivate::~RedChannelClientPrivate()
{
red_timer_remove(latency_monitor.timer);
- latency_monitor.timer = NULL;
+ latency_monitor.timer = nullptr;
red_timer_remove(connectivity_monitor.timer);
- connectivity_monitor.timer = NULL;
+ connectivity_monitor.timer = nullptr;
red_stream_free(stream);
@@ -542,7 +542,7 @@ void RedChannelClient::msg_sent()
if (priv->urgent_marshaller_is_active()) {
priv->restore_main_sender();
- spice_assert(priv->send_data.header.data != NULL);
+ spice_assert(priv->send_data.header.data != nullptr);
begin_send_message();
} else {
if (priv->pipe.empty()) {
@@ -708,7 +708,7 @@ void RedChannelClient::start_connectivity_monitoring(uint32_t timeout_ms)
* channel-client even if there are no ongoing channel specific messages
* on this channel.
*/
- if (priv->latency_monitor.timer == NULL) {
+ if (priv->latency_monitor.timer == nullptr) {
priv->latency_monitor.timer =
core->timer_new(ping_timer, this);
priv->latency_monitor.roundtrip = -1;
@@ -719,7 +719,7 @@ void RedChannelClient::start_connectivity_monitoring(uint32_t timeout_ms)
if (!priv->client->during_migrate_at_target()) {
priv->start_ping_timer(PING_TEST_IDLE_NET_TIMEOUT_MS);
}
- if (priv->connectivity_monitor.timer == NULL) {
+ if (priv->connectivity_monitor.timer == nullptr) {
priv->connectivity_monitor.state = CONNECTIVITY_STATE_CONNECTED;
priv->connectivity_monitor.timer =
core->timer_new(connectivity_timer, this);
@@ -804,7 +804,7 @@ static void mini_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t
bool RedChannelClient::init()
{
- char *local_error = NULL;
+ char *local_error = nullptr;
SpiceCoreInterfaceInternal *core;
if (!priv->stream) {
@@ -851,7 +851,7 @@ cleanup:
local_error);
g_free(local_error);
}
- return local_error == NULL;
+ return local_error == nullptr;
}
void RedChannelClientPrivate::watch_update_mask(int event_mask)
@@ -912,10 +912,10 @@ void RedChannelClient::migrate()
{
priv->cancel_ping_timer();
red_timer_remove(priv->latency_monitor.timer);
- priv->latency_monitor.timer = NULL;
+ priv->latency_monitor.timer = nullptr;
red_timer_remove(priv->connectivity_monitor.timer);
- priv->connectivity_monitor.timer = NULL;
+ priv->connectivity_monitor.timer = nullptr;
pipe_add_type(RED_PIPE_ITEM_TYPE_MIGRATE);
}
@@ -924,7 +924,7 @@ void RedChannelClient::shutdown()
{
if (priv->stream && priv->stream->watch) {
red_watch_remove(priv->stream->watch);
- priv->stream->watch = NULL;
+ priv->stream->watch = nullptr;
::shutdown(priv->stream->socket, SHUT_RDWR);
}
}
@@ -1040,7 +1040,7 @@ void RedChannelClient::handle_incoming()
int ret_handle;
uint8_t *parsed;
size_t parsed_size;
- message_destructor_t parsed_free = NULL;
+ message_destructor_t parsed_free = nullptr;
RedChannel *channel = get_channel();
if (buffer->header_pos < buffer->header.header_size) {
@@ -1064,12 +1064,12 @@ void RedChannelClient::handle_incoming()
if (buffer->msg_pos < msg_size) {
if (!buffer->msg) {
buffer->msg = alloc_recv_buf(msg_type, msg_size);
- if (buffer->msg == NULL && priv->block_read) {
+ if (buffer->msg == nullptr && priv->block_read) {
// if we are blocked by flow control just return, message will be read
// when data will be available
return;
}
- if (buffer->msg == NULL) {
+ if (buffer->msg == nullptr) {
red_channel_warning(channel, "ERROR: channel refused to allocate buffer.");
disconnect();
return;
@@ -1081,7 +1081,7 @@ void RedChannelClient::handle_incoming()
msg_size - buffer->msg_pos);
if (bytes_read == -1) {
release_recv_buf(msg_type, msg_size, buffer->msg);
- buffer->msg = NULL;
+ buffer->msg = nullptr;
disconnect();
return;
}
@@ -1094,20 +1094,20 @@ void RedChannelClient::handle_incoming()
parsed = get_channel()->parse(buffer->msg, msg_size,
msg_type, &parsed_size, &parsed_free);
- if (parsed == NULL) {
+ if (parsed == nullptr) {
red_channel_warning(channel, "failed to parse message type %d", msg_type);
release_recv_buf(msg_type, msg_size, buffer->msg);
- buffer->msg = NULL;
+ buffer->msg = nullptr;
disconnect();
return;
}
ret_handle = handle_message(msg_type, parsed_size, parsed);
- if (parsed_free != NULL) {
+ if (parsed_free != nullptr) {
parsed_free(parsed);
}
buffer->msg_pos = 0;
release_recv_buf(msg_type, msg_size, buffer->msg);
- buffer->msg = NULL;
+ buffer->msg = nullptr;
buffer->header_pos = 0;
if (!ret_handle) {
@@ -1345,14 +1345,14 @@ void RedChannelClient::begin_send_message()
priv->send_data.header.set_msg_serial(&priv->send_data.header,
++priv->send_data.last_sent_serial);
priv->ack_data.messages_window++;
- priv->send_data.header.data = NULL; /* avoid writing to this until we have a new message */
+ priv->send_data.header.data = nullptr; /* avoid writing to this until we have a new message */
send();
}
SpiceMarshaller *RedChannelClient::switch_to_urgent_sender()
{
spice_assert(no_item_being_sent());
- spice_assert(priv->send_data.header.data != NULL);
+ spice_assert(priv->send_data.header.data != nullptr);
priv->send_data.main.header_data = priv->send_data.header.data;
priv->send_data.marshaller = priv->send_data.urgent.marshaller;
@@ -1484,7 +1484,7 @@ bool RedChannelClient::is_mini_header() const
bool RedChannelClient::is_connected() const
{
- return g_list_find(priv->channel->get_clients(), this) != NULL;
+ return g_list_find(priv->channel->get_clients(), this) != nullptr;
}
void RedChannelClientPrivate::clear_sent_item()
@@ -1531,10 +1531,10 @@ void RedChannelClient::disconnect()
shutdown();
red_timer_remove(priv->latency_monitor.timer);
- priv->latency_monitor.timer = NULL;
+ priv->latency_monitor.timer = nullptr;
red_timer_remove(priv->connectivity_monitor.timer);
- priv->connectivity_monitor.timer = NULL;
+ priv->connectivity_monitor.timer = nullptr;
channel->remove_client(this);
on_disconnect();
diff --git a/server/red-channel.cpp b/server/red-channel.cpp
index d4830c6a..9730c5a1 100644
--- a/server/red-channel.cpp
+++ b/server/red-channel.cpp
@@ -287,7 +287,7 @@ void RedChannel::pipes_add_empty_msg(int msg_type)
int RedChannel::is_connected()
{
- return priv->clients != NULL;
+ return priv->clients != nullptr;
}
const char *RedChannel::get_name() const
@@ -309,7 +309,7 @@ void RedChannel::remove_client(RedChannelClient *rcc)
(void*) priv->thread_id, (void*) pthread_self());
}
link = g_list_find(priv->clients, rcc);
- spice_return_if_fail(link != NULL);
+ spice_return_if_fail(link != nullptr);
priv->clients = g_list_delete_link(priv->clients, link);
// TODO: should we set rcc->channel to NULL???
@@ -434,7 +434,7 @@ int RedChannel::pipes_new_add(new_pipe_item_t creator, void *data)
RedChannelClient *rcc;
int num = 0, n = 0;
- spice_assert(creator != NULL);
+ spice_assert(creator != nullptr);
FOREACH_CLIENT(this, rcc) {
auto item = (*creator)(rcc, data, num++);
diff --git a/server/red-client.cpp b/server/red-client.cpp
index 06a55aaa..9a722b81 100644
--- a/server/red-client.cpp
+++ b/server/red-client.cpp
@@ -34,7 +34,7 @@ RedClient::RedClient(RedsState *init_reds, bool migrated):
reds(init_reds),
during_target_migrate(migrated)
{
- pthread_mutex_init(&lock, NULL);
+ pthread_mutex_init(&lock, nullptr);
thread_id = pthread_self();
}
@@ -136,7 +136,7 @@ RedChannelClient *RedClient::get_channel(int type, int id)
return rcc.get();
}
}
- return NULL;
+ return nullptr;
}
gboolean RedClient::add_channel(RedChannelClient *rcc, char **error)
diff --git a/server/red-parse-qxl.cpp b/server/red-parse-qxl.cpp
index ead0254b..9724401d 100644
--- a/server/red-parse-qxl.cpp
+++ b/server/red-parse-qxl.cpp
@@ -92,7 +92,7 @@ static uint8_t *red_linearize_chunk(RedDataChunk *head, size_t size, bool *free_
RedDataChunk *chunk;
uint32_t copy;
- if (head->next_chunk == NULL) {
+ if (head->next_chunk == nullptr) {
spice_assert(size <= head->data_size);
*free_chunk = false;
return head->data;
@@ -100,7 +100,7 @@ static uint8_t *red_linearize_chunk(RedDataChunk *head, size_t size, bool *free_
ptr = data = (uint8_t*) g_malloc(size);
*free_chunk = true;
- for (chunk = head; chunk != NULL && size > 0; chunk = chunk->next_chunk) {
+ for (chunk = head; chunk != nullptr && size > 0; chunk = chunk->next_chunk) {
copy = MIN(chunk->data_size, size);
memcpy(ptr, chunk->data, copy);
ptr += copy;
@@ -123,9 +123,9 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id,
red->data_size = qxl->data_size;
data_size += red->data_size;
red->data = qxl->data;
- red->prev_chunk = red->next_chunk = NULL;
+ red->prev_chunk = red->next_chunk = nullptr;
if (!memslot_validate_virt(slots, (intptr_t)red->data, memslot_id, red->data_size, group_id)) {
- red->data = NULL;
+ red->data = nullptr;
return INVALID_SIZE;
}
@@ -140,7 +140,7 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id,
memslot_id = memslot_get_id(slots, next_chunk);
qxl = (QXLDataChunk *)memslot_get_virt(slots, next_chunk, sizeof(*qxl), group_id);
- if (qxl == NULL) {
+ if (qxl == nullptr) {
goto error;
}
@@ -171,7 +171,7 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id,
goto error;
}
- red->next_chunk = NULL;
+ red->next_chunk = nullptr;
return data_size;
error:
@@ -181,8 +181,8 @@ error:
red = red_prev;
}
red->data_size = 0;
- red->next_chunk = NULL;
- red->data = NULL;
+ red->next_chunk = nullptr;
+ red->data = nullptr;
return INVALID_SIZE;
}
@@ -193,7 +193,7 @@ static size_t red_get_data_chunks(RedMemSlotInfo *slots, int group_id,
int memslot_id = memslot_get_id(slots, addr);
qxl = (QXLDataChunk *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
+ if (qxl == nullptr) {
return INVALID_SIZE;
}
return red_get_data_chunks_ptr(slots, group_id, memslot_id, red, qxl);
@@ -248,14 +248,14 @@ static SpicePath *red_get_path(RedMemSlotInfo *slots, int group_id,
uint32_t count;
qxl = (QXLPath *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
- return NULL;
+ if (qxl == nullptr) {
+ return nullptr;
}
size = red_get_data_chunks_ptr(slots, group_id,
memslot_get_id(slots, addr),
&chunks, &qxl->chunk);
if (size == INVALID_SIZE) {
- return NULL;
+ return nullptr;
}
data = red_linearize_chunk(&chunks, size, &free_data);
red_put_data_chunks(&chunks);
@@ -326,14 +326,14 @@ static SpiceClipRects *red_get_clip_rects(RedMemSlotInfo *slots, int group_id,
uint32_t num_rects;
qxl = (QXLClipRects *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
- return NULL;
+ if (qxl == nullptr) {
+ return nullptr;
}
size = red_get_data_chunks_ptr(slots, group_id,
memslot_get_id(slots, addr),
&chunks, &qxl->chunk);
if (size == INVALID_SIZE) {
- return NULL;
+ return nullptr;
}
data = red_linearize_chunk(&chunks, size, &free_data);
red_put_data_chunks(&chunks);
@@ -366,8 +366,8 @@ static SpiceChunks *red_get_image_data_flat(RedMemSlotInfo *slots, int group_id,
void *bitmap_virt;
bitmap_virt = memslot_get_virt(slots, addr, size, group_id);
- if (bitmap_virt == NULL) {
- return NULL;
+ if (bitmap_virt == nullptr) {
+ return nullptr;
}
data = spice_chunks_new(1);
@@ -384,14 +384,14 @@ static SpiceChunks *red_get_image_data_chunked(RedMemSlotInfo *slots, int group_
RedDataChunk *chunk;
int i;
- for (i = 0, chunk = head; chunk != NULL; chunk = chunk->next_chunk) {
+ for (i = 0, chunk = head; chunk != nullptr; chunk = chunk->next_chunk) {
i++;
}
data = spice_chunks_new(i);
data->data_size = 0;
for (i = 0, chunk = head;
- chunk != NULL && i < data->num_chunks;
+ chunk != nullptr && i < data->num_chunks;
chunk = chunk->next_chunk, i++) {
data->chunk[i].data = chunk->data;
data->chunk[i].len = chunk->data_size;
@@ -448,19 +448,19 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
{
RedDataChunk chunks;
QXLImage *qxl;
- SpiceImage *red = NULL;
- SpicePalette *rp = NULL;
+ SpiceImage *red = nullptr;
+ SpicePalette *rp = nullptr;
uint64_t bitmap_size, size;
uint8_t qxl_flags;
QXLPHYSICAL palette;
if (addr == 0) {
- return NULL;
+ return nullptr;
}
qxl = (QXLImage *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
- return NULL;
+ if (qxl == nullptr) {
+ return nullptr;
}
red = g_new0(SpiceImage, 1);
red->descriptor.id = qxl->descriptor.id;
@@ -503,7 +503,7 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
int i, num_ents;
qp = (QXLPalette *)memslot_get_virt(slots, palette,
sizeof(*qp), group_id);
- if (qp == NULL) {
+ if (qp == nullptr) {
goto error;
}
num_ents = qp->num_ents;
@@ -574,12 +574,12 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
error:
g_free(red);
g_free(rp);
- return NULL;
+ return nullptr;
}
static void red_put_image(SpiceImage *red)
{
- if (red == NULL)
+ if (red == nullptr)
return;
switch (red->descriptor.type) {
@@ -762,14 +762,14 @@ static bool get_transform(RedMemSlotInfo *slots,
QXLPHYSICAL qxl_transform,
SpiceTransform *dst_transform)
{
- const uint32_t *t = NULL;
+ const uint32_t *t = nullptr;
if (qxl_transform == 0)
return false;
t = (uint32_t *)memslot_get_virt(slots, qxl_transform, sizeof(*dst_transform), group_id);
- if (t == NULL)
+ if (t == nullptr)
return false;
memcpy(dst_transform, t, sizeof(*dst_transform));
@@ -791,7 +791,7 @@ static void red_get_composite_ptr(RedMemSlotInfo *slots, int group_id,
if (get_transform(slots, group_id, qxl->mask_transform, &red->mask_transform))
red->flags |= SPICE_COMPOSITE_HAS_MASK_TRANSFORM;
} else {
- red->mask_bitmap = NULL;
+ red->mask_bitmap = nullptr;
}
red->src_origin.x = qxl->src_origin.x;
red->src_origin.y = qxl->src_origin.y;
@@ -842,13 +842,13 @@ static bool red_get_stroke_ptr(RedMemSlotInfo *slots, int group_id,
spice_assert(qxl->attr.style);
buf = (uint8_t *)memslot_get_virt(slots, qxl->attr.style,
style_nseg * sizeof(QXLFIXED), group_id);
- if (buf == NULL) {
+ if (buf == nullptr) {
return false;
}
memcpy(red->attr.style, buf, style_nseg * sizeof(QXLFIXED));
} else {
red->attr.style_nseg = 0;
- red->attr.style = NULL;
+ red->attr.style = nullptr;
}
red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush, flags);
red->fore_mode = qxl->fore_mode;
@@ -882,14 +882,14 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id,
uint16_t qxl_flags, qxl_length;
qxl = (QXLString *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
- return NULL;
+ if (qxl == nullptr) {
+ return nullptr;
}
chunk_size = red_get_data_chunks_ptr(slots, group_id,
memslot_get_id(slots, addr),
&chunks, &qxl->chunk);
if (chunk_size == INVALID_SIZE) {
- return NULL;
+ return nullptr;
}
data = red_linearize_chunk(&chunks, chunk_size, &free_data);
red_put_data_chunks(&chunks);
@@ -1018,7 +1018,7 @@ static bool red_get_native_drawable(QXLInstance *qxl_instance, RedMemSlotInfo *s
int i;
qxl = (QXLDrawable *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
+ if (qxl == nullptr) {
return false;
}
red->qxl = qxl_instance;
@@ -1098,7 +1098,7 @@ static bool red_get_compat_drawable(QXLInstance *qxl_instance, RedMemSlotInfo *s
QXLCompatDrawable *qxl;
qxl = (QXLCompatDrawable *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
+ if (qxl == nullptr) {
return false;
}
red->qxl = qxl_instance;
@@ -1235,7 +1235,7 @@ static void red_put_drawable(RedDrawable *red)
red_put_whiteness(&red->u.whiteness);
break;
}
- if (red->qxl != NULL) {
+ if (red->qxl != nullptr) {
red_qxl_release_resource(red->qxl, red->release_info_ext);
}
}
@@ -1250,7 +1250,7 @@ RedDrawable *red_drawable_new(QXLInstance *qxl, RedMemSlotInfo *slots,
if (!red_get_drawable(qxl, slots, group_id, red, addr, flags)) {
red_drawable_unref(red);
- return NULL;
+ return nullptr;
}
return red;
@@ -1277,7 +1277,7 @@ static bool red_get_update_cmd(QXLInstance *qxl_instance, RedMemSlotInfo *slots,
QXLUpdateCmd *qxl;
qxl = (QXLUpdateCmd *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
+ if (qxl == nullptr) {
return false;
}
red->qxl = qxl_instance;
@@ -1292,7 +1292,7 @@ static bool red_get_update_cmd(QXLInstance *qxl_instance, RedMemSlotInfo *slots,
static void red_put_update_cmd(RedUpdateCmd *red)
{
- if (red->qxl != NULL) {
+ if (red->qxl != nullptr) {
red_qxl_release_resource(red->qxl, red->release_info_ext);
}
}
@@ -1308,7 +1308,7 @@ RedUpdateCmd *red_update_cmd_new(QXLInstance *qxl, RedMemSlotInfo *slots,
if (!red_get_update_cmd(qxl, slots, group_id, red, addr)) {
red_update_cmd_unref(red);
- return NULL;
+ return nullptr;
}
return red;
@@ -1344,7 +1344,7 @@ static bool red_get_message(QXLInstance *qxl_instance, RedMemSlotInfo *slots, in
* so we can just ignore it by default.
*/
qxl = (QXLMessage *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
+ if (qxl == nullptr) {
return false;
}
red->qxl = qxl_instance;
@@ -1355,7 +1355,7 @@ static bool red_get_message(QXLInstance *qxl_instance, RedMemSlotInfo *slots, in
len = memslot_max_size_virt(slots, ((intptr_t) qxl)+sizeof(*qxl), memslot_id, group_id);
len = MIN(len, 100000);
end = (uint8_t *)memchr(qxl->data, 0, len);
- if (end == NULL) {
+ if (end == nullptr) {
return false;
}
red->len = end - qxl->data;
@@ -1364,7 +1364,7 @@ static bool red_get_message(QXLInstance *qxl_instance, RedMemSlotInfo *slots, in
static void red_put_message(RedMessage *red)
{
- if (red->qxl != NULL) {
+ if (red->qxl != nullptr) {
red_qxl_release_resource(red->qxl, red->release_info_ext);
}
}
@@ -1380,7 +1380,7 @@ RedMessage *red_message_new(QXLInstance *qxl, RedMemSlotInfo *slots,
if (!red_get_message(qxl, slots, group_id, red, addr)) {
red_message_unref(red);
- return NULL;
+ return nullptr;
}
return red;
@@ -1451,7 +1451,7 @@ static bool red_get_surface_cmd(QXLInstance *qxl_instance, RedMemSlotInfo *slots
uint64_t size;
qxl = (QXLSurfaceCmd *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
+ if (qxl == nullptr) {
return false;
}
red->qxl = qxl_instance;
@@ -1477,7 +1477,7 @@ static bool red_get_surface_cmd(QXLInstance *qxl_instance, RedMemSlotInfo *slots
size = red->u.surface_create.height * abs(red->u.surface_create.stride);
red->u.surface_create.data =
(uint8_t*)memslot_get_virt(slots, qxl->u.surface_create.data, size, group_id);
- if (red->u.surface_create.data == NULL) {
+ if (red->u.surface_create.data == nullptr) {
return false;
}
break;
@@ -1503,7 +1503,7 @@ RedSurfaceCmd *red_surface_cmd_new(QXLInstance *qxl_instance, RedMemSlotInfo *sl
if (!red_get_surface_cmd(qxl_instance, slots, group_id, cmd, addr)) {
red_surface_cmd_unref(cmd);
- return NULL;
+ return nullptr;
}
return cmd;
@@ -1534,7 +1534,7 @@ static bool red_get_cursor(RedMemSlotInfo *slots, int group_id,
bool free_data;
qxl = (QXLCursor *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
+ if (qxl == nullptr) {
return false;
}
@@ -1580,7 +1580,7 @@ static bool red_get_cursor_cmd(QXLInstance *qxl_instance, RedMemSlotInfo *slots,
QXLCursorCmd *qxl;
qxl = (QXLCursorCmd *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id);
- if (qxl == NULL) {
+ if (qxl == nullptr) {
return false;
}
red->qxl = qxl_instance;
@@ -1615,7 +1615,7 @@ RedCursorCmd *red_cursor_cmd_new(QXLInstance *qxl, RedMemSlotInfo *slots,
if (!red_get_cursor_cmd(qxl, slots, group_id, cmd, addr)) {
red_cursor_cmd_unref(cmd);
- return NULL;
+ return nullptr;
}
return cmd;
diff --git a/server/red-qxl.cpp b/server/red-qxl.cpp
index 39b194b6..fa09f31b 100644
--- a/server/red-qxl.cpp
+++ b/server/red-qxl.cpp
@@ -410,7 +410,7 @@ SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLInstance *qxl)
return &qxl->st->scanout;
}
pthread_mutex_unlock(&qxl->st->scanout_mutex);
- return NULL;
+ return nullptr;
}
void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix *scanout)
@@ -428,7 +428,7 @@ void spice_qxl_gl_scanout(QXLInstance *qxl,
int y_0_top)
{
RedWorkerMessageGlScanout payload = { /* empty */ };
- spice_return_if_fail(qxl != NULL);
+ spice_return_if_fail(qxl != nullptr);
QXLState *qxl_state = qxl->st;
spice_return_if_fail(qxl_state->gl_draw_cookie == GL_DRAW_COOKIE_INVALID);
@@ -472,7 +472,7 @@ void spice_qxl_gl_draw_async(QXLInstance *qxl,
},
};
- spice_return_if_fail(qxl != NULL);
+ spice_return_if_fail(qxl != nullptr);
qxl_state = qxl->st;
if (qxl_state->scanout.drm_dma_buf_fd < 0) {
spice_warning("called spice_qxl_gl_draw_async without a buffer");
@@ -499,7 +499,7 @@ void spice_qxl_set_device_info(QXLInstance *instance,
uint32_t device_display_id_start,
uint32_t device_display_id_count)
{
- g_return_if_fail(device_address != NULL);
+ g_return_if_fail(device_address != nullptr);
size_t da_len = strnlen(device_address, MAX_DEVICE_ADDRESS_LEN);
if (da_len >= MAX_DEVICE_ADDRESS_LEN) {
@@ -565,12 +565,12 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
{
QXLState *qxl_state;
- spice_return_if_fail(qxl != NULL);
+ spice_return_if_fail(qxl != nullptr);
qxl_state = new QXLState();
qxl_state->reds = reds;
qxl_state->qxl = qxl;
- pthread_mutex_init(&qxl_state->scanout_mutex, NULL);
+ pthread_mutex_init(&qxl_state->scanout_mutex, nullptr);
qxl_state->scanout.drm_dma_buf_fd = -1;
qxl_state->gl_draw_cookie = GL_DRAW_COOKIE_INVALID;
qxl_state->dispatcher = red::make_shared<Dispatcher>(RED_WORKER_MESSAGE_COUNT);
@@ -585,7 +585,7 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
void red_qxl_destroy(QXLInstance *qxl)
{
- spice_return_if_fail(qxl->st != NULL && qxl->st->dispatcher);
+ spice_return_if_fail(qxl->st != nullptr && qxl->st->dispatcher);
QXLState *qxl_state = qxl->st;
@@ -594,7 +594,7 @@ void red_qxl_destroy(QXLInstance *qxl)
qxl_state->dispatcher->send_message(RED_WORKER_MESSAGE_CLOSE_WORKER, &message);
red_worker_free(qxl_state->worker);
/* this must be done after calling red_worker_free */
- qxl->st = NULL;
+ qxl->st = nullptr;
pthread_mutex_destroy(&qxl_state->scanout_mutex);
delete qxl_state;
}
@@ -606,7 +606,7 @@ Dispatcher *red_qxl_get_dispatcher(QXLInstance *qxl)
void red_qxl_clear_pending(QXLState *qxl_state, int pending)
{
- spice_return_if_fail(qxl_state != NULL);
+ spice_return_if_fail(qxl_state != nullptr);
clear_bit(pending, &qxl_state->pending);
}
diff --git a/server/red-replay-qxl.cpp b/server/red-replay-qxl.cpp
index 83ffa22f..bdb25a15 100644
--- a/server/red-replay-qxl.cpp
+++ b/server/red-replay-qxl.cpp
@@ -235,7 +235,7 @@ static replay_t read_binary(SpiceReplay *replay, const char *prefix, size_t *siz
return REPLAY_ERROR;
}
- if (*buf == NULL) {
+ if (*buf == nullptr) {
*buf = (uint8_t*) replay_malloc(replay, *size + base_size);
}
#if 0
@@ -315,7 +315,7 @@ static ssize_t red_replay_data_chunks(SpiceReplay *replay, const char *prefix,
data_size = cur->data_size;
cur->next_chunk = cur->prev_chunk = 0;
while (count_chunks-- > 0) {
- uint8_t *data = NULL;
+ uint8_t *data = nullptr;
if (read_binary(replay, prefix, &next_data_size, &data,
sizeof(QXLDataChunk)) == REPLAY_ERROR) {
return -1;
@@ -371,12 +371,12 @@ static void red_replay_rect_ptr(SpiceReplay *replay, const char *prefix, QXLRect
static QXLPath *red_replay_path(SpiceReplay *replay)
{
- QXLPath *qxl = NULL;
+ QXLPath *qxl = nullptr;
ssize_t data_size;
data_size = red_replay_data_chunks(replay, "path", (uint8_t**)&qxl, sizeof(QXLPath));
if (data_size < 0) {
- return NULL;
+ return nullptr;
}
qxl->data_size = data_size;
return qxl;
@@ -391,15 +391,15 @@ static void red_replay_path_free(SpiceReplay *replay, QXLPHYSICAL p)
static QXLClipRects *red_replay_clip_rects(SpiceReplay *replay)
{
- QXLClipRects *qxl = NULL;
+ QXLClipRects *qxl = nullptr;
unsigned int num_rects;
replay_fscanf(replay, "num_rects %u\n", &num_rects);
if (replay->error) {
- return NULL;
+ return nullptr;
}
if (red_replay_data_chunks(replay, "clip_rects", (uint8_t**)&qxl, sizeof(QXLClipRects)) < 0) {
- return NULL;
+ return nullptr;
}
qxl->num_rects = num_rects;
return qxl;
@@ -412,7 +412,7 @@ static void red_replay_clip_rects_free(SpiceReplay *replay, QXLClipRects *qxl)
static uint8_t *red_replay_image_data_flat(SpiceReplay *replay, size_t *size)
{
- uint8_t *data = NULL;
+ uint8_t *data = nullptr;
read_binary(replay, "image_data_flat", size, &data, 0);
return data;
@@ -420,7 +420,7 @@ static uint8_t *red_replay_image_data_flat(SpiceReplay *replay, size_t *size)
static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
{
- QXLImage* qxl = NULL, *data;
+ QXLImage* qxl = nullptr, *data;
size_t bitmap_size;
ssize_t size;
uint8_t qxl_flags;
@@ -430,10 +430,10 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
replay_fscanf(replay, "image %d\n", &has_image);
if (replay->error) {
- return NULL;
+ return nullptr;
}
if (!has_image) {
- return NULL;
+ return nullptr;
}
qxl = (QXLImage*)replay_malloc0(replay, sizeof(QXLImage));
@@ -443,7 +443,7 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
replay_fscanf(replay, "descriptor.width %d\n", &qxl->descriptor.width);
replay_fscanf(replay, "descriptor.height %d\n", &qxl->descriptor.height);
if (replay->error) {
- return NULL;
+ return nullptr;
}
switch (qxl->descriptor.type) {
@@ -461,7 +461,7 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
replay_fscanf(replay, "qp.num_ents %u\n", &num_ents);
if (replay->error) {
- return NULL;
+ return nullptr;
}
qp = (QXLPalette*) replay_malloc(replay, sizeof(QXLPalette) + num_ents * sizeof(qp->ents[0]));
qp->num_ents = num_ents;
@@ -478,19 +478,19 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
if (qxl_flags & QXL_BITMAP_DIRECT) {
qxl->bitmap.data = QXLPHYSICAL_FROM_PTR(red_replay_image_data_flat(replay, &bitmap_size));
} else {
- uint8_t *bitmap_data = NULL;
+ uint8_t *bitmap_data = nullptr;
size = red_replay_data_chunks(replay, "bitmap.data", &bitmap_data, 0);
qxl->bitmap.data = QXLPHYSICAL_FROM_PTR(bitmap_data);
if (size != bitmap_size) {
g_warning("bad image, %" G_GSIZE_FORMAT " != %" G_GSIZE_FORMAT, size, bitmap_size);
- return NULL;
+ return nullptr;
}
}
break;
case SPICE_IMAGE_TYPE_SURFACE:
replay_fscanf(replay, "surface_image.surface_id %d\n", &qxl->surface_image.surface_id);
if (replay->error) {
- return NULL;
+ return nullptr;
}
qxl->surface_image.surface_id = replay_id_get(replay, qxl->surface_image.surface_id);
break;
@@ -499,9 +499,9 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
// record, then reread into them. and use MPEG-4).
replay_fscanf(replay, "quic.data_size %d\n", &qxl->quic.data_size);
if (replay->error) {
- return NULL;
+ return nullptr;
}
- data = NULL;
+ data = nullptr;
size = red_replay_data_chunks(replay, "quic.data", (uint8_t**)&data,
sizeof(QXLImageDescriptor) + sizeof(QXLQUICData) +
sizeof(QXLDataChunk));
@@ -538,7 +538,7 @@ static void red_replay_image_free(SpiceReplay *replay, QXLPHYSICAL p, uint32_t f
red_replay_data_chunks_free(replay, qxl,
sizeof(QXLImageDescriptor) + sizeof(QXLQUICData) +
sizeof(QXLDataChunk));
- qxl = NULL;
+ qxl = nullptr;
break;
default:
spice_warn_if_reached();
@@ -725,7 +725,7 @@ static void red_replay_stroke_ptr(SpiceReplay *replay, QXLStroke *qxl, uint32_t
size_t size;
replay_fscanf(replay, "attr.style_nseg %d\n", &temp); qxl->attr.style_nseg = temp;
- uint8_t *data = NULL;
+ uint8_t *data = nullptr;
read_binary(replay, "style", &size, &data, 0);
qxl->attr.style = QXLPHYSICAL_FROM_PTR(data);
}
@@ -750,14 +750,14 @@ static QXLString *red_replay_string(SpiceReplay *replay)
uint16_t length;
uint16_t flags;
ssize_t chunk_size;
- QXLString *qxl = NULL;
+ QXLString *qxl = nullptr;
replay_fscanf(replay, "data_size %d\n", &data_size);
replay_fscanf(replay, "length %d\n", &temp); length = temp;
replay_fscanf(replay, "flags %d\n", &temp); flags = temp;
chunk_size = red_replay_data_chunks(replay, "string", (uint8_t**)&qxl, sizeof(QXLString));
if (chunk_size < 0) {
- return NULL;
+ return nullptr;
}
qxl->data_size = data_size;
qxl->length = length;
@@ -844,7 +844,7 @@ static void red_replay_clip_free(SpiceReplay *replay, QXLClip *qxl)
static uint8_t *red_replay_transform(SpiceReplay *replay)
{
- uint8_t *data = NULL;
+ uint8_t *data = nullptr;
size_t size;
read_binary(replay, "transform", &size, &data, 0);
@@ -896,14 +896,14 @@ static QXLDrawable *red_replay_native_drawable(SpiceReplay *replay, uint32_t fla
red_replay_rect_ptr(replay, "self_bitmap_area", &qxl->self_bitmap_area);
replay_fscanf(replay, "surface_id %d\n", &qxl->surface_id);
if (replay->error) {
- return NULL;
+ return nullptr;
}
qxl->surface_id = replay_id_get(replay, qxl->surface_id);
for (i = 0; i < 3; i++) {
replay_fscanf(replay, "surfaces_dest %d\n", &qxl->surfaces_dest[i]);
if (replay->error) {
- return NULL;
+ return nullptr;
}
qxl->surfaces_dest[i] = replay_id_get(replay, qxl->surfaces_dest[i]);
red_replay_rect_ptr(replay, "surfaces_rects", &qxl->surfaces_rects[i]);
@@ -911,7 +911,7 @@ static QXLDrawable *red_replay_native_drawable(SpiceReplay *replay, uint32_t fla
replay_fscanf(replay, "type %d\n", &temp); qxl->type = temp;
if (replay->error) {
- return NULL;
+ return nullptr;
}
switch (qxl->type) {
case QXL_DRAW_ALPHA_BLEND:
@@ -1036,7 +1036,7 @@ static QXLCompatDrawable *red_replay_compat_drawable(SpiceReplay *replay, uint32
replay_fscanf(replay, "type %d\n", &temp); qxl->type = temp;
if (replay->error) {
- return NULL;
+ return nullptr;
}
switch (qxl->type) {
case QXL_DRAW_ALPHA_BLEND:
@@ -1108,7 +1108,7 @@ static QXLUpdateCmd *red_replay_update_cmd(SpiceReplay *replay)
replay_fscanf(replay, "update_id %d\n", &qxl->update_id);
replay_fscanf(replay, "surface_id %d\n", &qxl->surface_id);
if (replay->error) {
- return NULL;
+ return nullptr;
}
qxl->surface_id = replay_id_get(replay, qxl->surface_id);
@@ -1117,7 +1117,7 @@ static QXLUpdateCmd *red_replay_update_cmd(SpiceReplay *replay)
static QXLMessage *red_replay_message(SpiceReplay *replay)
{
- QXLMessage *qxl = NULL;
+ QXLMessage *qxl = nullptr;
size_t size;
read_binary(replay, "message", &size, (uint8_t**)&qxl, sizeof(QXLMessage));
@@ -1136,7 +1136,7 @@ static QXLSurfaceCmd *red_replay_surface_cmd(SpiceReplay *replay)
replay_fscanf(replay, "type %d\n", &temp); qxl->type = temp;
replay_fscanf(replay, "flags %d\n", &qxl->flags);
if (replay->error) {
- return NULL;
+ return nullptr;
}
switch (qxl->type) {
@@ -1146,11 +1146,11 @@ static QXLSurfaceCmd *red_replay_surface_cmd(SpiceReplay *replay)
replay_fscanf(replay, "u.surface_create.height %d\n", &qxl->u.surface_create.height);
replay_fscanf(replay, "u.surface_create.stride %d\n", &qxl->u.surface_create.stride);
if (replay->error) {
- return NULL;
+ return nullptr;
}
size = qxl->u.surface_create.height * abs(qxl->u.surface_create.stride);
if ((qxl->flags & QXL_SURF_FLAG_KEEP_DATA) != 0) {
- uint8_t *data = NULL;
+ uint8_t *data = nullptr;
read_binary(replay, "data", &read_size, &data, 0);
qxl->u.surface_create.data = QXLPHYSICAL_FROM_PTR(data);
if (read_size != size) {
@@ -1181,7 +1181,7 @@ static void red_replay_surface_cmd_free(SpiceReplay *replay, QXLSurfaceCmd *qxl)
static QXLCursor *red_replay_cursor(SpiceReplay *replay)
{
int temp;
- QXLCursor cursor, *qxl = NULL;
+ QXLCursor cursor, *qxl = nullptr;
ssize_t data_size;
replay_fscanf(replay, "header.unique %" SCNu64 "\n", &cursor.header.unique);
@@ -1198,11 +1198,11 @@ static QXLCursor *red_replay_cursor(SpiceReplay *replay)
replay_fscanf(replay, "data_size %d\n", &temp);
if (replay->error) {
- return NULL;
+ return nullptr;
}
data_size = red_replay_data_chunks(replay, "cursor", (uint8_t**)&qxl, sizeof(QXLCursor));
if (data_size < 0) {
- return NULL;
+ return nullptr;
}
qxl->header = cursor.header;
qxl->data_size = data_size;
@@ -1217,7 +1217,7 @@ static QXLCursorCmd *red_replay_cursor_cmd(SpiceReplay *replay)
replay_fscanf(replay, "cursor_cmd\n");
replay_fscanf(replay, "type %d\n", &temp);
if (replay->error) {
- return NULL;
+ return nullptr;
}
qxl->type = temp;
switch (qxl->type) {
@@ -1254,7 +1254,7 @@ static void replay_handle_create_primary(QXLInstance *instance, SpiceReplay *rep
{
QXLDevSurfaceCreate surface = { 0, };
size_t size;
- uint8_t *mem = NULL;
+ uint8_t *mem = nullptr;
if (replay->created_primary) {
g_warning("WARNING: %d: original recording event not preceded by a destroy primary",
@@ -1291,7 +1291,7 @@ static void replay_handle_dev_input(QXLInstance *instance, SpiceReplay *replay,
replay->created_primary = FALSE;
spice_qxl_destroy_primary_surface(instance, 0);
g_free(replay->primary_mem);
- replay->primary_mem = NULL;
+ replay->primary_mem = nullptr;
break;
case RED_WORKER_MESSAGE_DESTROY_SURFACES:
replay->created_primary = FALSE;
@@ -1316,7 +1316,7 @@ static void replay_handle_dev_input(QXLInstance *instance, SpiceReplay *replay,
SPICE_GNUC_VISIBLE QXLCommandExt* spice_replay_next_cmd(SpiceReplay *replay,
QXLInstance *instance)
{
- QXLCommandExt* cmd = NULL;
+ QXLCommandExt* cmd = nullptr;
uint64_t timestamp;
int type;
int what = -1;
@@ -1373,7 +1373,7 @@ SPICE_GNUC_VISIBLE QXLCommandExt* spice_replay_next_cmd(SpiceReplay *replay,
* free the list of buffer allocated to avoid to free on next calls */
if (replay->allocated) {
g_list_free(replay->allocated);
- replay->allocated = NULL;
+ replay->allocated = nullptr;
}
replay->counter++;
@@ -1385,9 +1385,9 @@ error:
* buffers allocated to avoid leaks */
if (replay->allocated) {
g_list_free_full(replay->allocated, g_free);
- replay->allocated = NULL;
+ replay->allocated = nullptr;
}
- return NULL;
+ return nullptr;
}
SPICE_GNUC_VISIBLE void spice_replay_free_cmd(SpiceReplay *replay, QXLCommandExt *cmd)
@@ -1433,16 +1433,16 @@ SpiceReplay *spice_replay_new(FILE *file, int nsurfaces)
unsigned int version = 0;
SpiceReplay *replay;
- spice_return_val_if_fail(file != NULL, NULL);
+ spice_return_val_if_fail(file != nullptr, NULL);
if (fscanf(file, "SPICE_REPLAY %u\n", &version) == 1) {
if (version != 1) {
spice_warning("Replay file version unsupported");
- return NULL;
+ return nullptr;
}
} else {
spice_warning("This doesn't look like a valid replay file");
- return NULL;
+ return nullptr;
}
replay = g_new0(SpiceReplay, 1);
@@ -1450,13 +1450,13 @@ SpiceReplay *spice_replay_new(FILE *file, int nsurfaces)
replay->error = FALSE;
replay->fd = file;
replay->created_primary = FALSE;
- pthread_mutex_init(&replay->mutex, NULL);
- pthread_cond_init(&replay->cond, NULL);
+ pthread_mutex_init(&replay->mutex, nullptr);
+ pthread_cond_init(&replay->cond, nullptr);
replay->id_map = g_array_new(FALSE, FALSE, sizeof(uint32_t));
replay->id_map_inv = g_array_new(FALSE, FALSE, sizeof(uint32_t));
replay->id_free = g_array_new(FALSE, FALSE, sizeof(uint32_t));
replay->nsurfaces = nsurfaces;
- replay->allocated = NULL;
+ replay->allocated = nullptr;
/* reserve id 0 */
replay_id_new(replay, 0);
@@ -1466,7 +1466,7 @@ SpiceReplay *spice_replay_new(FILE *file, int nsurfaces)
SPICE_GNUC_VISIBLE void spice_replay_free(SpiceReplay *replay)
{
- spice_return_if_fail(replay != NULL);
+ spice_return_if_fail(replay != nullptr);
g_list_free_full(replay->allocated, g_free);
pthread_mutex_destroy(&replay->mutex);
diff --git a/server/red-stream-device.cpp b/server/red-stream-device.cpp
index ba0871cb..224187dc 100644
--- a/server/red-stream-device.cpp
+++ b/server/red-stream-device.cpp
@@ -203,7 +203,7 @@ StreamDevice::handle_msg_format()
int n = read(msg->buf + msg_pos, sizeof(StreamMsgFormat) - msg_pos);
if (n < 0) {
- return handle_msg_invalid(NULL);
+ return handle_msg_invalid(nullptr);
}
msg_pos += n;
@@ -293,7 +293,7 @@ StreamDevice::handle_msg_capabilities()
int n = read(msg->buf + msg_pos, hdr.size - msg_pos);
if (n < 0) {
- return handle_msg_invalid(NULL);
+ return handle_msg_invalid(nullptr);
}
msg_pos += n;
@@ -397,13 +397,13 @@ stream_msg_cursor_set_to_cursor_cmd(const StreamMsgCursorSet *msg, size_t msg_si
if (cursor->header.width > STREAM_MSG_CURSOR_SET_MAX_WIDTH ||
cursor->header.height > STREAM_MSG_CURSOR_SET_MAX_HEIGHT) {
g_free(cmd);
- return NULL;
+ return nullptr;
}
const unsigned int cursor_bits = get_cursor_type_bits(cursor->header.type);
if (cursor_bits == 0) {
g_free(cmd);
- return NULL;
+ return nullptr;
}
/* Check that enough data has been sent for the cursor.
@@ -413,7 +413,7 @@ stream_msg_cursor_set_to_cursor_cmd(const StreamMsgCursorSet *msg, size_t msg_si
size_required = SPICE_ALIGN(size_required * cursor_bits, 8) / 8u;
if (msg_size < sizeof(StreamMsgCursorSet) + size_required) {
g_free(cmd);
- return NULL;
+ return nullptr;
}
cursor->data_size = size_required;
cursor->data = (uint8_t*) g_memdup(msg->data, size_required);
@@ -454,7 +454,7 @@ StreamDevice::handle_msg_cursor_set()
// transform the message to a cursor command and process it
RedCursorCmd *cmd = stream_msg_cursor_set_to_cursor_cmd(&msg->cursor_set, msg_pos);
if (!cmd) {
- return handle_msg_invalid(NULL);
+ return handle_msg_invalid(nullptr);
}
cursor_channel->process_cmd(cmd);
@@ -595,7 +595,7 @@ StreamDevice::create_channel()
g_return_if_fail(id >= 0);
stream_channel = stream_channel_new(reds, id);
- cursor_channel = cursor_channel_new(reds, id, core, NULL);
+ cursor_channel = cursor_channel_new(reds, id, core, nullptr);
stream_channel->register_start_cb(stream_start, this);
stream_channel->register_queue_stat_cb(stream_queue_stat, this);
@@ -614,7 +614,7 @@ char_device_set_state(RedCharDevice *char_dev, int state)
{
SpiceCharDeviceInstance *sin;
sin = char_dev->get_device_instance();
- spice_assert(sin != NULL);
+ spice_assert(sin != nullptr);
SpiceCharDeviceInterface *sif = spice_char_device_get_interface(sin);
if (sif->state) {
diff --git a/server/red-stream.cpp b/server/red-stream.cpp
index df4ddbb2..fee45f30 100644
--- a/server/red-stream.cpp
+++ b/server/red-stream.cpp
@@ -212,7 +212,7 @@ static ssize_t stream_ssl_read_cb(RedStream *s, void *buf, size_t size)
void red_stream_remove_watch(RedStream* s)
{
red_watch_remove(s->watch);
- s->watch = NULL;
+ s->watch = nullptr;
}
#if HAVE_SASL
@@ -299,7 +299,7 @@ ssize_t red_stream_write(RedStream *s, const void *buf, size_t nbyte)
int red_stream_get_family(const RedStream *s)
{
- spice_return_val_if_fail(s != NULL, -1);
+ spice_return_val_if_fail(s != nullptr, -1);
if (s->socket == -1)
return -1;
@@ -309,7 +309,7 @@ int red_stream_get_family(const RedStream *s)
bool red_stream_is_plain_unix(const RedStream *s)
{
- spice_return_val_if_fail(s != NULL, false);
+ spice_return_val_if_fail(s != nullptr, false);
if (red_stream_get_family(s) != AF_UNIX) {
return false;
@@ -348,7 +348,7 @@ int red_stream_get_no_delay(RedStream *stream)
#ifndef _WIN32
int red_stream_send_msgfd(RedStream *stream, int fd)
{
- struct msghdr msgh = { 0, };
+ struct msghdr msgh = { nullptr, };
struct iovec iov;
int r;
@@ -396,7 +396,7 @@ ssize_t red_stream_writev(RedStream *s, const struct iovec *iov, int iovcnt)
int n;
ssize_t ret = 0;
- if (s->priv->writev != NULL && iovcnt > 1) {
+ if (s->priv->writev != nullptr && iovcnt > 1) {
return s->priv->writev(s, iov, iovcnt);
}
@@ -503,12 +503,12 @@ void red_stream_set_core_interface(RedStream *stream, SpiceCoreInterfaceInternal
bool red_stream_is_ssl(RedStream *stream)
{
- return (stream->priv->ssl != NULL);
+ return (stream->priv->ssl != nullptr);
}
static void red_stream_disable_writev(RedStream *stream)
{
- stream->priv->writev = NULL;
+ stream->priv->writev = nullptr;
}
RedStreamSslStatus red_stream_ssl_accept(RedStream *stream)
@@ -538,7 +538,7 @@ RedStreamSslStatus red_stream_ssl_accept(RedStream *stream)
red_dump_openssl_errors();
spice_warning("SSL_accept failed, error=%d", ssl_error);
SSL_free(stream->priv->ssl);
- stream->priv->ssl = NULL;
+ stream->priv->ssl = nullptr;
return RED_STREAM_SSL_STATUS_ERROR;
}
@@ -579,8 +579,8 @@ static inline void async_read_clear_handlers(RedStream *stream)
{
AsyncRead *async = &stream->priv->async_read;
red_stream_remove_watch(stream);
- async->now = NULL;
- async->end = NULL;
+ async->now = nullptr;
+ async->end = nullptr;
}
static void async_read_handler(G_GNUC_UNUSED int fd,
@@ -632,7 +632,7 @@ void red_stream_async_read(RedStream *stream,
{
AsyncRead *async = &stream->priv->async_read;
- g_return_if_fail(async->now == NULL && async->end == NULL);
+ g_return_if_fail(async->now == nullptr && async->end == nullptr);
if (size == 0) {
read_done_cb(opaque);
return;
diff --git a/server/red-worker.cpp b/server/red-worker.cpp
index b1ea5a6a..4d0a2361 100644
--- a/server/red-worker.cpp
+++ b/server/red-worker.cpp
@@ -94,7 +94,7 @@ static gboolean red_process_cursor_cmd(RedWorker *worker, const QXLCommandExt *e
cursor_cmd = red_cursor_cmd_new(worker->qxl, &worker->mem_slots,
ext->group_id, ext->cmd.data);
- if (cursor_cmd == NULL) {
+ if (cursor_cmd == nullptr) {
return FALSE;
}
@@ -152,7 +152,7 @@ static gboolean red_process_surface_cmd(RedWorker *worker, QXLCommandExt *ext, g
surface_cmd = red_surface_cmd_new(worker->qxl, &worker->mem_slots,
ext->group_id, ext->cmd.data);
- if (surface_cmd == NULL) {
+ if (surface_cmd == nullptr) {
return false;
}
display_channel_process_surface_cmd(worker->display_channel, surface_cmd, loadvm);
@@ -202,7 +202,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
ext_cmd.group_id, ext_cmd.cmd.data,
ext_cmd.flags); // returns with 1 ref
- if (red_drawable != NULL) {
+ if (red_drawable != nullptr) {
display_channel_process_draw(worker->display_channel, red_drawable,
worker->process_display_generation);
red_drawable_unref(red_drawable);
@@ -214,7 +214,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
update = red_update_cmd_new(worker->qxl, &worker->mem_slots,
ext_cmd.group_id, ext_cmd.cmd.data);
- if (update == NULL) {
+ if (update == nullptr) {
break;
}
if (!display_channel_validate_surface(worker->display_channel, update->surface_id)) {
@@ -231,7 +231,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
message = red_message_new(worker->qxl, &worker->mem_slots,
ext_cmd.group_id, ext_cmd.cmd.data);
- if (message == NULL) {
+ if (message == nullptr) {
break;
}
#ifdef DEBUG
@@ -333,7 +333,7 @@ static void handle_dev_update_async(void *opaque, void *payload)
{
auto worker = (RedWorker*) opaque;
auto msg = (RedWorkerMessageUpdateAsync*) payload;
- QXLRect *qxl_dirty_rects = NULL;
+ QXLRect *qxl_dirty_rects = nullptr;
uint32_t num_dirty_rects = 0;
spice_return_if_fail(red_qxl_is_running(worker->qxl));
@@ -362,7 +362,7 @@ static void handle_dev_update(void *opaque, void *payload)
display_channel_update(worker->display_channel,
msg->surface_id, msg->qxl_area, msg->clear_dirty_region,
&qxl_dirty_rects, &msg->num_dirty_rects);
- if (msg->qxl_dirty_rects == NULL) {
+ if (msg->qxl_dirty_rects == nullptr) {
g_free(qxl_dirty_rects);
}
}
@@ -419,7 +419,7 @@ static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id,
line_0 = (uint8_t*)memslot_get_virt(&worker->mem_slots, surface.mem,
surface.height * abs(surface.stride),
surface.group_id);
- if (line_0 == NULL) {
+ if (line_0 == nullptr) {
return;
}
if (worker->record) {
@@ -642,7 +642,7 @@ static void handle_dev_monitors_config_async(void *opaque, void *payload)
qxl_monitors_config_size(1),
msg->group_id);
- if (dev_monitors_config == NULL) {
+ if (dev_monitors_config == nullptr) {
/* TODO: raise guest bug (requires added QXL interface) */
goto async_complete;
}
@@ -665,7 +665,7 @@ static void handle_dev_monitors_config_async(void *opaque, void *payload)
(QXLMonitorsConfig*)memslot_get_virt(&worker->mem_slots, msg->monitors_config,
qxl_monitors_config_size(count),
msg->group_id);
- if (dev_monitors_config == NULL) {
+ if (dev_monitors_config == nullptr) {
/* TODO: raise guest bug (requires added QXL interface) */
goto async_complete;
}
@@ -1041,14 +1041,14 @@ RedWorker* red_worker_new(QXLInstance *qxl)
worker->driver_cap_monitors_config = false;
char worker_str[SPICE_STAT_NODE_NAME_MAX];
snprintf(worker_str, sizeof(worker_str), "display[%d]", worker->qxl->id & 0xff);
- stat_init_node(&worker->stat, reds, NULL, worker_str, TRUE);
+ stat_init_node(&worker->stat, reds, nullptr, worker_str, TRUE);
stat_init_counter(&worker->wakeup_counter, reds, &worker->stat, "wakeups", TRUE);
stat_init_counter(&worker->command_counter, reds, &worker->stat, "commands", TRUE);
stat_init_counter(&worker->full_loop_counter, reds, &worker->stat, "full_loops", TRUE);
stat_init_counter(&worker->total_loop_counter, reds, &worker->stat, "total_loops", TRUE);
worker->dispatch_watch = dispatcher->create_watch(&worker->core);
- spice_assert(worker->dispatch_watch != NULL);
+ spice_assert(worker->dispatch_watch != nullptr);
GSource *source = g_source_new(&worker_source_funcs, sizeof(RedWorkerSource));
SPICE_CONTAINEROF(source, RedWorkerSource, source)->worker = worker;
@@ -1101,9 +1101,9 @@ static void *red_worker_main(void *arg)
worker->loop = loop;
g_main_loop_run(loop);
g_main_loop_unref(loop);
- worker->loop = NULL;
+ worker->loop = nullptr;
- return NULL;
+ return nullptr;
}
bool red_worker_run(RedWorker *worker)
@@ -1124,11 +1124,11 @@ bool red_worker_run(RedWorker *worker)
sigdelset(&thread_sig_mask, SIGSEGV);
pthread_sigmask(SIG_SETMASK, &thread_sig_mask, &curr_sig_mask);
#endif
- if ((r = pthread_create(&worker->thread, NULL, red_worker_main, worker))) {
+ if ((r = pthread_create(&worker->thread, nullptr, red_worker_main, worker))) {
spice_error("create thread failed %d", r);
}
#ifndef _WIN32
- pthread_sigmask(SIG_SETMASK, &curr_sig_mask, NULL);
+ pthread_sigmask(SIG_SETMASK, &curr_sig_mask, nullptr);
#endif
#if !defined(__APPLE__)
pthread_setname_np(worker->thread, "SPICE Worker");
@@ -1150,12 +1150,12 @@ static void red_worker_close_channel(RedChannel *channel)
*/
void red_worker_free(RedWorker *worker)
{
- pthread_join(worker->thread, NULL);
+ pthread_join(worker->thread, nullptr);
red_worker_close_channel(worker->cursor_channel);
- worker->cursor_channel = NULL;
+ worker->cursor_channel = nullptr;
red_worker_close_channel(worker->display_channel);
- worker->display_channel = NULL;
+ worker->display_channel = nullptr;
if (worker->dispatch_watch) {
red_watch_remove(worker->dispatch_watch);
diff --git a/server/reds.cpp b/server/reds.cpp
index e48919bd..73cc7390 100644
--- a/server/reds.cpp
+++ b/server/reds.cpp
@@ -93,7 +93,7 @@ static void reds_set_video_codecs(RedsState *reds, GArray *video_codecs);
/* TODO while we can technically create more than one server in a process,
* the intended use is to support a single server per process */
-static GList *servers = NULL;
+static GList *servers = nullptr;
static pthread_mutex_t global_reds_lock = PTHREAD_MUTEX_INITIALIZER;
/* SPICE configuration set through the public spice_server_set_xxx APIS */
@@ -259,17 +259,17 @@ void reds_handle_channel_event(RedsState *reds, int event, SpiceChannelEventInfo
static void reds_link_free(RedLinkInfo *link)
{
red_stream_free(link->stream);
- link->stream = NULL;
+ link->stream = nullptr;
g_free(link->link_mess);
- link->link_mess = NULL;
+ link->link_mess = nullptr;
BN_free(link->tiTicketing.bn);
- link->tiTicketing.bn = NULL;
+ link->tiTicketing.bn = nullptr;
if (link->tiTicketing.rsa) {
RSA_free(link->tiTicketing.rsa);
- link->tiTicketing.rsa = NULL;
+ link->tiTicketing.rsa = nullptr;
}
g_free(link);
@@ -317,9 +317,9 @@ void reds_register_channel(RedsState *reds, RedChannel *channel)
uint32_t this_type = channel->type();
uint32_t this_id = channel->id();
if (spice_extra_checks) {
- g_assert(reds_find_channel(reds, this_type, this_id) == NULL);
+ g_assert(reds_find_channel(reds, this_type, this_id) == nullptr);
} else {
- g_warn_if_fail(reds_find_channel(reds, this_type, this_id) == NULL);
+ g_warn_if_fail(reds_find_channel(reds, this_type, this_id) == nullptr);
}
reds->channels.push_front(red::shared_ptr<RedChannel>(channel));
// create new channel in the client if possible
@@ -338,7 +338,7 @@ RedChannel *reds_find_channel(RedsState *reds, uint32_t type, uint32_t id)
return channel.get();
}
}
- return NULL;
+ return nullptr;
}
/* Search for first free channel id for a specific channel type.
@@ -430,7 +430,7 @@ static void reds_reset_vdp(RedsState *reds)
dev->priv->agent_attached = FALSE;
dev->stop();
dev->reset();
- dev->reset_dev_instance(NULL);
+ dev->reset_dev_instance(nullptr);
sif = spice_char_device_get_interface(reds->vdagent);
if (sif->state) {
@@ -449,7 +449,7 @@ static RedCharDeviceWriteBuffer *vdagent_new_write_buffer(RedCharDeviceVDIPort *
char_dev_buf = agent_dev->write_buffer_get_server(total_msg_size,
use_token);
if (!char_dev_buf) {
- return NULL; // no token was available
+ return nullptr; // no token was available
}
char_dev_buf->buf_used = total_msg_size;
@@ -537,7 +537,7 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
reds->agent_dev->priv->read_filter.result = AGENT_MSG_FILTER_DISCARD;
reds->agent_dev->priv->read_filter.discard_all = TRUE;
g_free(reds->agent_dev->priv->mig_data);
- reds->agent_dev->priv->mig_data = NULL;
+ reds->agent_dev->priv->mig_data = nullptr;
reds_mig_cleanup(reds);
}
@@ -626,7 +626,7 @@ static void reds_update_mouse_mode(RedsState *reds)
static void reds_update_agent_properties(RedsState *reds)
{
- if (!reds->agent_dev || reds->config == NULL) {
+ if (!reds->agent_dev || reds->config == nullptr) {
return;
}
/* copy & paste */
@@ -643,7 +643,7 @@ static void reds_agent_remove(RedsState *reds)
// part of the clients are during target migration.
reds_reset_vdp(reds);
- reds->vdagent = NULL;
+ reds->vdagent = nullptr;
reds_update_mouse_mode(reds);
if (reds_main_channel_connected(reds) &&
!reds->main_channel->is_waiting_for_migrate_data()) {
@@ -773,7 +773,7 @@ RedCharDeviceVDIPort::read_one_msg_from_device()
break;
}
auto dispatch_buf = std::move(priv->current_read_buf);
- priv->receive_pos = NULL;
+ priv->receive_pos = nullptr;
if (priv->message_receive_len == 0) {
priv->read_state = VDI_PORT_READ_STATE_READ_HEADER;
priv->receive_pos = (uint8_t *)&priv->vdi_chunk_header;
@@ -992,7 +992,7 @@ SpiceMsgChannels *reds_msg_channels_new(RedsState *reds)
{
SpiceMsgChannels* channels_info;
- spice_assert(reds != NULL);
+ spice_assert(reds != nullptr);
channels_info = (SpiceMsgChannels *)g_malloc(sizeof(SpiceMsgChannels)
+ reds->channels.size() * sizeof(SpiceChannelId));
@@ -1074,7 +1074,7 @@ uint8_t *reds_get_agent_data_buffer(RedsState *reds, MainChannelClient *mcc, siz
return (uint8_t*) g_malloc(size);
}
- spice_assert(dev->priv->recv_from_client_buf == NULL);
+ spice_assert(dev->priv->recv_from_client_buf == nullptr);
client = mcc->get_client();
dev->priv->recv_from_client_buf =
dev->write_buffer_get_client((RedCharDeviceClientOpaque *)client,
@@ -1082,7 +1082,7 @@ uint8_t *reds_get_agent_data_buffer(RedsState *reds, MainChannelClient *mcc, siz
/* check if buffer was allocated, as flow control is enabled for
* this device this is a normal condition */
if (!dev->priv->recv_from_client_buf) {
- return NULL;
+ return nullptr;
}
dev->priv->recv_from_client_buf_pushed = FALSE;
return dev->priv->recv_from_client_buf->buf + sizeof(VDIChunkHeader);
@@ -1103,7 +1103,7 @@ void reds_release_agent_data_buffer(RedsState *reds, uint8_t *buf)
RedCharDevice::write_buffer_release(dev,
&dev->priv->recv_from_client_buf);
}
- dev->priv->recv_from_client_buf = NULL;
+ dev->priv->recv_from_client_buf = nullptr;
dev->priv->recv_from_client_buf_pushed = FALSE;
}
@@ -1148,7 +1148,7 @@ static void reds_on_main_agent_monitors_config(RedsState *reds,
monitors_config = (VDAgentMonitorsConfig *)(cmc->buffer + sizeof(*msg_header));
if (agent_check_message(msg_header, (uint8_t *) monitors_config,
- NULL, 0) != AGENT_CHECK_NO_ERROR) {
+ nullptr, 0) != AGENT_CHECK_NO_ERROR) {
goto overflow;
}
spice_debug("monitors_config->num_of_monitors: %d", monitors_config->num_of_monitors);
@@ -1265,7 +1265,7 @@ void reds_on_main_channel_migrate(RedsState *reds, MainChannelClient *mcc)
spice_assert(agent_dev->priv->receive_len);
agent_dev->priv->message_receive_len += agent_dev->priv->receive_len;
agent_dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;
- agent_dev->priv->receive_pos = NULL;
+ agent_dev->priv->receive_pos = nullptr;
}
}
@@ -1395,7 +1395,7 @@ static int reds_agent_state_restore(RedsState *reds, SpiceMigrateDataMain *mig_d
} else {
agent_dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;
agent_dev->priv->current_read_buf.reset();
- agent_dev->priv->receive_pos = NULL;
+ agent_dev->priv->receive_pos = nullptr;
agent_dev->priv->read_filter.msg_data_to_read = mig_data->agent2client.msg_remaining;
agent_dev->priv->read_filter.result = (AgentMsgFilterResult) mig_data->agent2client.msg_filter_result;
}
@@ -1509,7 +1509,7 @@ static bool reds_send_link_ack(RedsState *reds, RedLinkInfo *link)
RedChannel *channel;
const RedChannelCapabilities *channel_caps;
BUF_MEM *bmBuf;
- BIO *bio = NULL;
+ BIO *bio = nullptr;
int ret = FALSE;
size_t hdr_size;
@@ -1559,7 +1559,7 @@ static bool reds_send_link_ack(RedsState *reds, RedLinkInfo *link)
if (RSA_generate_key_ex(link->tiTicketing.rsa,
SPICE_TICKET_KEY_PAIR_LENGTH,
link->tiTicketing.bn,
- NULL) != 1) {
+ nullptr) != 1) {
spice_warning("Failed to generate %d bits RSA key",
SPICE_TICKET_KEY_PAIR_LENGTH);
red_dump_openssl_errors();
@@ -1600,7 +1600,7 @@ static bool reds_send_link_ack(RedsState *reds, RedLinkInfo *link)
ret = TRUE;
end:
- if (bio != NULL)
+ if (bio != nullptr)
BIO_free(bio);
return ret;
}
@@ -1656,14 +1656,14 @@ static RedsMigTargetClient* reds_mig_target_client_find(RedsState *reds, RedClie
{
GList *l;
- for (l = reds->mig_target_clients; l != NULL; l = l->next) {
+ for (l = reds->mig_target_clients; l != nullptr; l = l->next) {
auto mig_client = (RedsMigTargetClient*) l->data;
if (mig_client->client == client) {
return mig_client;
}
}
- return NULL;
+ return nullptr;
}
static void reds_mig_target_client_add_pending_link(RedsMigTargetClient *client,
@@ -1712,7 +1712,7 @@ static RedClient *reds_get_client(RedsState *reds)
spice_assert(reds->clients.size() <= 1);
if (reds->clients.empty()) {
- return NULL;
+ return nullptr;
}
return *reds->clients.begin();
@@ -1744,13 +1744,13 @@ red_channel_capabilities_init_from_link_message(RedChannelCapabilities *caps,
const uint8_t *raw_caps = (const uint8_t *)link_mess + link_mess->caps_offset;
caps->num_common_caps = link_mess->num_common_caps;
- caps->common_caps = NULL;
+ caps->common_caps = nullptr;
if (caps->num_common_caps) {
caps->common_caps = (uint32_t*) g_memdup(raw_caps,
link_mess->num_common_caps * sizeof(uint32_t));
}
caps->num_caps = link_mess->num_channel_caps;
- caps->caps = NULL;
+ caps->caps = nullptr;
if (link_mess->num_channel_caps) {
caps->caps = (uint32_t*) g_memdup(raw_caps + link_mess->num_common_caps * sizeof(uint32_t),
link_mess->num_channel_caps * sizeof(uint32_t));
@@ -1797,7 +1797,7 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
reds_info_new_channel(link, connection_id);
stream = link->stream;
- link->stream = NULL;
+ link->stream = nullptr;
client = red_client_new(reds, mig_target);
reds->clients.push_front(client);
@@ -1889,7 +1889,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) {
+ for(item = mig_client->pending_links; item != nullptr; item = item->next) {
auto mig_link = (RedsMigPendingLink*) item->data;
RedChannel *channel;
@@ -1954,7 +1954,7 @@ void reds_on_client_semi_seamless_migrate_complete(RedsState *reds, RedClient *c
static void reds_handle_other_links(RedsState *reds, RedLinkInfo *link)
{
RedChannel *channel;
- RedClient *client = NULL;
+ RedClient *client = nullptr;
SpiceLinkMess *link_mess;
RedsMigTargetClient *mig_client;
@@ -1995,12 +1995,12 @@ static void reds_handle_other_links(RedsState *reds, RedLinkInfo *link)
if (client->during_migrate_at_target() && !reds->dst_do_seamless_migrate) {
spice_assert(mig_client);
reds_mig_target_client_add_pending_link(mig_client, link_mess, link->stream);
- link->link_mess = NULL;
+ link->link_mess = nullptr;
} else {
spice_assert(!mig_client);
reds_channel_do_link(channel, client, link_mess, link->stream);
}
- link->stream = NULL;
+ link->stream = nullptr;
}
static void reds_handle_link(RedLinkInfo *link)
@@ -2340,11 +2340,11 @@ static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)
RedLinkInfo *link;
if (!red_socket_set_non_blocking(socket, TRUE)) {
- return NULL;
+ return nullptr;
}
if (!red_socket_set_no_delay(socket, TRUE)) {
- return NULL;
+ return nullptr;
}
red_socket_set_keepalive(socket, TRUE, KEEPALIVE_TIMEOUT);
@@ -2370,8 +2370,8 @@ static RedLinkInfo *reds_init_client_ssl_connection(RedsState *reds, int socket)
RedStreamSslStatus ssl_status;
link = reds_init_client_connection(reds, socket);
- if (link == NULL) {
- return NULL;
+ if (link == nullptr) {
+ return nullptr;
}
ssl_status = red_stream_enable_ssl(link->stream, reds->ctx);
@@ -2399,7 +2399,7 @@ error:
* supposed to not close it if it fails */
link->stream->socket = -1;
reds_link_free(link);
- return NULL;
+ return nullptr;
}
static void reds_accept_ssl_connection(int fd, int event, void *data)
@@ -2408,7 +2408,7 @@ static void reds_accept_ssl_connection(int fd, int event, void *data)
RedLinkInfo *link;
int socket;
- if ((socket = accept(fd, NULL, 0)) == -1) {
+ if ((socket = accept(fd, nullptr, nullptr)) == -1) {
spice_warning("accept failed, %s", strerror(errno));
return;
}
@@ -2424,7 +2424,7 @@ static void reds_accept(int fd, int event, void *data)
auto reds = (RedsState*) data;
int socket;
- if ((socket = accept(fd, NULL, 0)) == -1) {
+ if ((socket = accept(fd, nullptr, nullptr)) == -1) {
spice_warning("accept failed, %s", strerror(errno));
return;
}
@@ -2507,14 +2507,14 @@ static int reds_init_socket(const char *addr, int portnr, int family)
ai.ai_family = family;
snprintf(port, sizeof(port), "%d", portnr);
- rc = getaddrinfo(strlen(addr) ? addr : NULL, port, &ai, &res);
+ rc = getaddrinfo(strlen(addr) ? addr : nullptr, port, &ai, &res);
if (rc != 0) {
spice_warning("getaddrinfo(%s,%s): %s", addr, port,
gai_strerror(rc));
return -1;
}
- for (e = res; e != NULL; e = e->ai_next) {
+ for (e = res; e != nullptr; e = e->ai_next) {
slisten = socket(e->ai_family, e->ai_socktype, e->ai_protocol);
if (slisten < 0) {
continue;
@@ -2590,13 +2590,13 @@ static void reds_cleanup_net(SpiceServer *reds)
if (reds->config->spice_listen_socket_fd != reds->listen_socket) {
socket_close(reds->listen_socket);
}
- reds->listen_watch = NULL;
+ reds->listen_watch = nullptr;
reds->listen_socket = -1;
}
if (reds->secure_listen_socket != -1) {
red_watch_remove(reds->secure_listen_watch);
socket_close(reds->secure_listen_socket);
- reds->secure_listen_watch = NULL;
+ reds->secure_listen_watch = nullptr;
reds->secure_listen_socket = -1;
}
}
@@ -2611,7 +2611,7 @@ static int reds_init_net(RedsState *reds)
reds->listen_watch = reds_core_watch_add(reds, reds->listen_socket,
SPICE_WATCH_EVENT_READ,
reds_accept, reds);
- if (reds->listen_watch == NULL) {
+ if (reds->listen_watch == nullptr) {
return -1;
}
}
@@ -2625,7 +2625,7 @@ static int reds_init_net(RedsState *reds)
reds->secure_listen_watch = reds_core_watch_add(reds, reds->secure_listen_socket,
SPICE_WATCH_EVENT_READ,
reds_accept_ssl_connection, reds);
- if (reds->secure_listen_watch == NULL) {
+ if (reds->secure_listen_watch == nullptr) {
return -1;
}
}
@@ -2635,7 +2635,7 @@ static int reds_init_net(RedsState *reds)
reds->listen_watch = reds_core_watch_add(reds, reds->listen_socket,
SPICE_WATCH_EVENT_READ,
reds_accept, reds);
- if (reds->listen_watch == NULL) {
+ if (reds->listen_watch == nullptr) {
return -1;
}
}
@@ -2644,18 +2644,18 @@ static int reds_init_net(RedsState *reds)
static int load_dh_params(SSL_CTX *ctx, char *file)
{
- DH *ret = 0;
+ DH *ret = nullptr;
BIO *bio;
- if ((bio = BIO_new_file(file, "r")) == NULL) {
+ if ((bio = BIO_new_file(file, "r")) == nullptr) {
spice_warning("Could not open DH file");
red_dump_openssl_errors();
return -1;
}
- ret = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
+ ret = PEM_read_bio_DHparams(bio, nullptr, nullptr, nullptr);
BIO_free(bio);
- if (ret == 0) {
+ if (ret == nullptr) {
spice_warning("Could not read DH params");
red_dump_openssl_errors();
return -1;
@@ -2799,7 +2799,7 @@ static int reds_init_ssl(RedsState *reds)
}
/* Load the CAs we trust*/
- return_code = SSL_CTX_load_verify_locations(reds->ctx, reds->config->ssl_parameters.ca_certificate_file, 0);
+ return_code = SSL_CTX_load_verify_locations(reds->ctx, reds->config->ssl_parameters.ca_certificate_file, nullptr);
if (return_code == 1) {
spice_debug("Loaded CA certificates from %s", reds->config->ssl_parameters.ca_certificate_file);
} else {
@@ -2836,7 +2836,7 @@ SPICE_DESTRUCTOR_FUNC(reds_exit)
GList *l;
pthread_mutex_lock(&global_reds_lock);
- for (l = servers; l != NULL; l = l->next) {
+ for (l = servers; l != nullptr; l = l->next) {
auto reds = (RedsState*) l->data;
reds_cleanup(reds);
}
@@ -2909,7 +2909,7 @@ static void reds_mig_release(RedServerConfig *config)
g_free(config->mig_spice->cert_subject);
g_free(config->mig_spice->host);
g_free(config->mig_spice);
- config->mig_spice = NULL;
+ config->mig_spice = nullptr;
}
}
@@ -3067,7 +3067,7 @@ attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstance *sin)
spice_assert(dev->priv->plug_generation == 1);
reds_agent_state_restore(reds, dev->priv->mig_data);
g_free(dev->priv->mig_data);
- dev->priv->mig_data = NULL;
+ dev->priv->mig_data = nullptr;
}
else {
spice_debug("waiting for migration data");
@@ -3101,7 +3101,7 @@ static const char *const spice_server_char_device_recognized_subtypes_list[] = {
SUBTYPE_SMARTCARD,
#endif
SUBTYPE_USBREDIR,
- NULL,
+ nullptr,
};
SPICE_GNUC_VISIBLE const char** spice_server_char_device_recognized_subtypes(void)
@@ -3116,7 +3116,7 @@ static void reds_add_char_device(RedsState *reds, const red::shared_ptr<RedCharD
static void reds_remove_char_device(RedsState *reds, RedCharDevice *dev)
{
- g_return_if_fail(reds != NULL);
+ g_return_if_fail(reds != nullptr);
auto &devs(reds->char_devices);
g_warn_if_fail(std::find(devs.begin(), devs.end(),
red::shared_ptr<RedCharDevice>(dev)) != devs.end());
@@ -3189,7 +3189,7 @@ static int spice_server_char_device_remove_interface(RedsState *reds, SpiceBaseI
g_return_val_if_fail(char_device == reds->vdagent, -1);
if (reds->vdagent) {
reds_agent_remove(reds);
- reds->agent_dev->reset_dev_instance(NULL);
+ reds->agent_dev->reset_dev_instance(nullptr);
}
}
@@ -3324,12 +3324,12 @@ SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
RedsState *reds;
const SpiceBaseInterface *base_interface;
- g_return_val_if_fail(sin != NULL, -1);
+ g_return_val_if_fail(sin != nullptr, -1);
base_interface = sin->sif;
if (strcmp(base_interface->type, SPICE_INTERFACE_TABLET) == 0) {
SpiceTabletInstance *tablet = SPICE_UPCAST(SpiceTabletInstance, sin);
- g_return_val_if_fail(tablet->st != NULL, -1);
+ g_return_val_if_fail(tablet->st != nullptr, -1);
reds = spice_tablet_state_get_server(tablet->st);
spice_debug("remove SPICE_INTERFACE_TABLET");
reds->inputs_channel->detach_tablet(tablet);
@@ -3342,14 +3342,14 @@ SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
snd_detach_record(SPICE_UPCAST(SpiceRecordInstance, sin));
} else if (strcmp(base_interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
SpiceCharDeviceInstance *char_device = SPICE_UPCAST(SpiceCharDeviceInstance, sin);
- g_return_val_if_fail(char_device->st != NULL, -1);
+ g_return_val_if_fail(char_device->st != nullptr, -1);
reds = char_device->st->get_server();
return spice_server_char_device_remove_interface(reds, sin);
} else if (strcmp(base_interface->type, SPICE_INTERFACE_QXL) == 0) {
QXLInstance *qxl;
qxl = SPICE_UPCAST(QXLInstance, sin);
- g_return_val_if_fail(qxl->st != NULL, -1);
+ g_return_val_if_fail(qxl->st != nullptr, -1);
reds = red_qxl_get_server(qxl->st);
reds->qxl_instances.remove(qxl); // XXX owning
red_qxl_destroy(qxl);
@@ -3374,7 +3374,7 @@ static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)
reds->agent_dev = red::make_shared<RedCharDeviceVDIPort>(reds);
reds_update_agent_properties(reds);
reds->main_dispatcher = red::make_shared<MainDispatcher>(reds);
- reds->mig_target_clients = NULL;
+ reds->mig_target_clients = nullptr;
reds->vm_running = TRUE; /* for backward compatibility */
if (!(reds->mig_timer = reds->core.timer_new(migrate_timeout, reds))) {
@@ -3412,7 +3412,7 @@ static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)
spice_buffer_free(&reds->client_monitors_config);
- reds->allow_multiple_clients = getenv(SPICE_DEBUG_ALLOW_MC_ENV) != NULL;
+ reds->allow_multiple_clients = getenv(SPICE_DEBUG_ALLOW_MC_ENV) != nullptr;
if (reds->allow_multiple_clients) {
spice_warning("spice: allowing multiple client connections");
}
@@ -3506,7 +3506,7 @@ static gboolean get_name_index(const EnumNames names[], const char *name, uint32
/* returns NULL if index is invalid. */
static const char *get_index_name(const EnumNames names[], uint32_t index)
{
- while (names->name != NULL && names->id != index) {
+ while (names->name != nullptr && names->id != index) {
names++;
}
@@ -3515,7 +3515,7 @@ static const char *get_index_name(const EnumNames names[], uint32_t index)
static const EnumNames renderer_names[] = {
{RED_RENDERER_SW, "sw"},
- {RED_RENDERER_INVALID, NULL},
+ {RED_RENDERER_INVALID, nullptr},
};
static gboolean reds_add_renderer(RedsState *reds, const char *name)
@@ -3533,7 +3533,7 @@ static gboolean reds_add_renderer(RedsState *reds, const char *name)
static const EnumNames video_encoder_names[] = {
{0, "spice"},
{1, "gstreamer"},
- {0, NULL},
+ {0, nullptr},
};
static const new_video_encoder_t video_encoder_procs[] = {
@@ -3541,7 +3541,7 @@ static const new_video_encoder_t video_encoder_procs[] = {
#if defined(HAVE_GSTREAMER_1_0) || defined(HAVE_GSTREAMER_0_10)
&gstreamer_encoder_new,
#else
- NULL,
+ nullptr,
#endif
};
@@ -3550,7 +3550,7 @@ static const EnumNames video_codec_names[] = {
{SPICE_VIDEO_CODEC_TYPE_VP8, "vp8"},
{SPICE_VIDEO_CODEC_TYPE_H264, "h264"},
{SPICE_VIDEO_CODEC_TYPE_VP9, "vp9"},
- {0, NULL},
+ {0, nullptr},
};
static const int video_codec_caps[] = {
@@ -3563,7 +3563,7 @@ static const int video_codec_caps[] = {
char *reds_get_video_codec_fullname(RedVideoCodec *codec)
{
int i;
- const char *encoder_name = NULL;
+ const char *encoder_name = nullptr;
const char *codec_name = get_index_name(video_codec_names, codec->type);
spice_assert(codec_name);
@@ -3591,14 +3591,14 @@ char *reds_get_video_codec_fullname(RedVideoCodec *codec)
static char* parse_next_video_codec(char *codecs, char **encoder, char **codec)
{
if (!codecs) {
- return NULL;
+ return nullptr;
}
codecs += strspn(codecs, ";");
if (!*codecs) {
- return NULL;
+ return nullptr;
}
int end_encoder, end_codec = -1;
- *encoder = *codec = NULL;
+ *encoder = *codec = nullptr;
if (sscanf(codecs, "%*[0-9a-zA-Z_]:%n%*[0-9a-zA-Z_];%n", &end_encoder, &end_codec) == 0
&& end_codec > 0) {
codecs[end_encoder - 1] = '\0';
@@ -3625,7 +3625,7 @@ static int reds_set_video_codecs_from_string(RedsState *reds, const char *codecs
GArray *video_codecs;
int invalid_codecs = 0;
- g_return_val_if_fail(codecs != NULL, -1);
+ g_return_val_if_fail(codecs != nullptr, -1);
if (strcmp(codecs, "auto") == 0) {
codecs = default_video_codecs;
@@ -3688,7 +3688,7 @@ SPICE_GNUC_VISIBLE int spice_server_init(SpiceServer *reds, SpiceCoreInterface *
reds_add_renderer(reds, default_renderer);
}
if (reds->config->video_codecs->len == 0) {
- reds_set_video_codecs_from_string(reds, default_video_codecs, NULL);
+ reds_set_video_codecs_from_string(reds, default_video_codecs, nullptr);
}
return ret;
}
@@ -3877,7 +3877,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *reds,
time_t now = spice_get_monotonic_time_ns() / NSEC_PER_SEC;
reds->config->taTicket.expiration_time = now + lifetime;
}
- if (passwd != NULL) {
+ if (passwd != nullptr) {
if (strlen(passwd) > SPICE_MAX_PASSWORD_LENGTH)
return -1;
g_strlcpy(reds->config->taTicket.password, passwd, sizeof(reds->config->taTicket.password));
@@ -3893,8 +3893,8 @@ SPICE_GNUC_VISIBLE int spice_server_set_tls(SpiceServer *s, int port,
const char *private_key_file, const char *key_passwd,
const char *dh_key_file, const char *ciphersuite)
{
- if (port == 0 || ca_cert_file == NULL || certs_file == NULL ||
- private_key_file == NULL) {
+ if (port == 0 || ca_cert_file == nullptr || certs_file == nullptr ||
+ private_key_file == nullptr) {
return -1;
}
if (port < 0 || port > 0xffff) {
@@ -3970,7 +3970,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_zlib_glz_compression(SpiceServer *s, spi
SPICE_GNUC_VISIBLE int spice_server_set_channel_security(SpiceServer *s, const char *channel, int security)
{
int type;
- if (channel == NULL) {
+ if (channel == nullptr) {
s->config->default_channel_security = security;
return 0;
}
@@ -4063,7 +4063,7 @@ static void reds_set_video_codecs(RedsState *reds, GArray *video_codecs)
/* The video_codecs array is immutable */
g_clear_pointer(&reds->config->video_codecs, g_array_unref);
- spice_return_if_fail(video_codecs != NULL);
+ spice_return_if_fail(video_codecs != nullptr);
reds->config->video_codecs = video_codecs;
}
@@ -4102,7 +4102,7 @@ static int reds_set_migration_dest_info(RedsState *reds,
int port, int secure_port,
const char* cert_subject)
{
- RedsMigSpice *spice_migration = NULL;
+ RedsMigSpice *spice_migration = nullptr;
reds_mig_release(reds->config);
if ((port == -1 && secure_port == -1) || !dest) {
@@ -4291,8 +4291,8 @@ SpiceWatch *reds_core_watch_add(RedsState *reds,
SpiceWatchFunc func,
void *opaque)
{
- g_return_val_if_fail(reds != NULL, NULL);
- g_return_val_if_fail(reds->core.watch_add != NULL, NULL);
+ g_return_val_if_fail(reds != nullptr, NULL);
+ g_return_val_if_fail(reds->core.watch_add != nullptr, NULL);
return reds->core.watch_add(&reds->core, fd, event_mask, func, opaque);
}
@@ -4302,8 +4302,8 @@ reds_core_timer_add_internal(RedsState *reds,
SpiceTimerFunc func,
void *opaque)
{
- g_return_val_if_fail(reds != NULL, NULL);
- g_return_val_if_fail(reds->core.timer_add != NULL, NULL);
+ g_return_val_if_fail(reds != nullptr, NULL);
+ g_return_val_if_fail(reds->core.timer_add != nullptr, NULL);
return reds->core.timer_add(&reds->core, func, opaque);
@@ -4345,7 +4345,7 @@ static gboolean reds_use_client_monitors_config(RedsState *reds)
}
FOREACH_QXL_INSTANCE(reds, qxl) {
- if (!red_qxl_client_monitors_config(qxl, NULL))
+ if (!red_qxl_client_monitors_config(qxl, nullptr))
return FALSE;
}
return TRUE;
@@ -4463,5 +4463,5 @@ RedRecord *reds_get_record(RedsState *reds)
return red_record_ref(reds->record);
}
- return NULL;
+ return nullptr;
}
diff --git a/server/sound.cpp b/server/sound.cpp
index 67e3b268..66743af5 100644
--- a/server/sound.cpp
+++ b/server/sound.cpp
@@ -230,8 +230,8 @@ static void snd_send(SndChannelClient * client);
static SndChannelClient *snd_channel_get_client(SndChannel *channel)
{
GList *clients = channel->get_clients();
- if (clients == NULL) {
- return NULL;
+ if (clients == nullptr) {
+ return nullptr;
}
return (SndChannelClient*) clients->data;
@@ -239,7 +239,7 @@ static SndChannelClient *snd_channel_get_client(SndChannel *channel)
static RedsState* snd_channel_get_server(SndChannelClient *client)
{
- g_return_val_if_fail(client != NULL, NULL);
+ g_return_val_if_fail(client != nullptr, NULL);
return client->get_channel()->get_server();
}
@@ -256,7 +256,7 @@ void PlaybackChannelClient::on_message_marshalled(uint8_t *, void *opaque)
if (client->in_progress) {
snd_playback_free_frame(client, client->in_progress);
- client->in_progress = NULL;
+ client->in_progress = nullptr;
if (client->pending_frame) {
client->command |= SND_PLAYBACK_PCM_MASK;
snd_send(client);
@@ -649,7 +649,7 @@ void PlaybackChannelClient::send_item(G_GNUC_UNUSED RedPipeItem *item)
if (command & SND_PLAYBACK_PCM_MASK) {
spice_assert(!in_progress && pending_frame);
in_progress = pending_frame;
- pending_frame = NULL;
+ pending_frame = nullptr;
command &= ~SND_PLAYBACK_PCM_MASK;
if (snd_playback_send_write(this)) {
break;
@@ -876,7 +876,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
spice_assert(!playback_client->in_progress);
snd_playback_free_frame(playback_client,
playback_client->pending_frame);
- playback_client->pending_frame = NULL;
+ playback_client->pending_frame = nullptr;
}
}
}
@@ -886,7 +886,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_get_buffer(SpicePlaybackInstance *
{
SndChannelClient *client = snd_channel_get_client(sin->st);
- *frame = NULL;
+ *frame = nullptr;
*num_samples = 0;
if (!client) {
return;
@@ -940,7 +940,7 @@ void snd_set_playback_latency(RedClient *client, uint32_t latency)
{
GList *l;
- for (l = snd_channels; l != NULL; l = l->next) {
+ for (l = snd_channels; l != nullptr; l = l->next) {
auto now = (SndChannel*) l->data;
SndChannelClient *scc = snd_channel_get_client(now);
if (now->type() == SPICE_CHANNEL_PLAYBACK && scc &&
@@ -977,7 +977,7 @@ PlaybackChannelClient::~PlaybackChannelClient()
// free frames, unref them
for (i = 0; i < NUM_AUDIO_FRAMES; ++i) {
- frames->items[i].client = NULL;
+ frames->items[i].client = nullptr;
}
if (--frames->refs == 0) {
g_free(frames);
@@ -1222,7 +1222,7 @@ SndChannel::~SndChannel()
remove_channel(this);
g_free(volume.volume);
- volume.volume = NULL;
+ volume.volume = nullptr;
}
PlaybackChannel::PlaybackChannel(RedsState *reds):
@@ -1276,7 +1276,7 @@ void snd_set_playback_compression(bool on)
{
GList *l;
- for (l = snd_channels; l != NULL; l = l->next) {
+ for (l = snd_channels; l != nullptr; l = l->next) {
auto now = (SndChannel*) l->data;
SndChannelClient *client = snd_channel_get_client(now);
if (now->type() == SPICE_CHANNEL_PLAYBACK && client) {
diff --git a/server/spicevmc.cpp b/server/spicevmc.cpp
index 483c6461..dd73a352 100644
--- a/server/spicevmc.cpp
+++ b/server/spicevmc.cpp
@@ -126,7 +126,7 @@ vmc_channel_client_create(RedChannel *channel, RedClient *client,
RedVmcChannel::RedVmcChannel(RedsState *reds, uint32_t type, uint32_t id):
RedChannel(reds, type, id, RedChannel::MigrateAll)
{
- init_stat_node(NULL, "spicevmc");
+ init_stat_node(nullptr, "spicevmc");
const RedStatNode *stat = get_stat_node();
stat_init_counter(&in_data, reds, stat, "in_data", TRUE);
stat_init_counter(&in_compressed, reds, stat, "in_compressed", TRUE);
@@ -313,7 +313,7 @@ void VmcChannelClient::on_disconnect()
}
}
- channel->rcc = NULL;
+ channel->rcc = nullptr;
sif = spice_char_device_get_interface(channel->chardev_sin);
if (sif->state) {
sif->state(channel->chardev_sin, 0);
@@ -403,7 +403,7 @@ bool VmcChannelClient::handle_message(uint16_t type, uint32_t size, void *msg)
stat_inc_counter(channel->in_data, size);
channel->recv_from_client_buf->buf_used = size;
channel->chardev->write_buffer_add(channel->recv_from_client_buf);
- channel->recv_from_client_buf = NULL;
+ channel->recv_from_client_buf = nullptr;
break;
case SPICE_MSGC_SPICEVMC_COMPRESSED_DATA:
return handle_compressed_msg(channel, this, (SpiceMsgCompressedData*)msg);
@@ -413,7 +413,7 @@ bool VmcChannelClient::handle_message(uint16_t type, uint32_t size, void *msg)
spice_warning("bad port event message size");
return FALSE;
}
- if (sif->base.minor_version >= 2 && sif->event != NULL)
+ if (sif->base.minor_version >= 2 && sif->event != nullptr)
sif->event(channel->chardev_sin, *(uint8_t*)msg);
break;
default:
@@ -442,7 +442,7 @@ uint8_t *VmcChannelClient::alloc_recv_buf(uint16_t type, uint32_t size)
true);
if (!channel->recv_from_client_buf) {
block_read();
- return NULL;
+ return nullptr;
}
return channel->recv_from_client_buf->buf;
}
@@ -638,7 +638,7 @@ void RedCharDeviceSpiceVmc::port_event(uint8_t event)
channel->port_opened = FALSE;
}
- if (channel->rcc == NULL) {
+ if (channel->rcc == nullptr) {
return;
}
@@ -659,7 +659,7 @@ RedCharDeviceSpiceVmc::~RedCharDeviceSpiceVmc()
{
if (channel) {
// prevent possible recursive calls
- channel->chardev = NULL;
+ channel->chardev = nullptr;
// close all current connections and drop the reference
channel->destroy();
diff --git a/server/stream-channel.cpp b/server/stream-channel.cpp
index abade377..bced4fd8 100644
--- a/server/stream-channel.cpp
+++ b/server/stream-channel.cpp
@@ -134,7 +134,7 @@ StreamChannelClient::fill_base(SpiceMarshaller *m, const StreamChannel *channel)
base.surface_id = PRIMARY_SURFACE_ID;
base.box = (SpiceRect) { 0, 0, channel->width, channel->height };
- base.clip = (SpiceClip) { SPICE_CLIP_TYPE_NONE, NULL };
+ base.clip = (SpiceClip) { SPICE_CLIP_TYPE_NONE, nullptr };
spice_marshall_DisplayBase(m, &base);
}
@@ -204,7 +204,7 @@ void StreamChannelClient::send_item(RedPipeItem *pipe_item)
SpiceFill fill;
fill.brush = (SpiceBrush) { SPICE_BRUSH_TYPE_SOLID, { .color = 0 } };
fill.rop_descriptor = SPICE_ROPD_OP_PUT;
- fill.mask = (SpiceQMask) { 0, { 0, 0 }, NULL };
+ fill.mask = (SpiceQMask) { 0, { 0, 0 }, nullptr };
SpiceMarshaller *brush_pat_out, *mask_bitmap_out;
spice_marshall_Fill(m, &fill, &brush_pat_out, &mask_bitmap_out);
break;
@@ -353,10 +353,10 @@ void StreamChannel::on_connect(RedClient *red_client, RedStream *stream,
} start_msg;
StreamMsgStartStop *const start = &start_msg.base;
- spice_return_if_fail(stream != NULL);
+ spice_return_if_fail(stream != nullptr);
client = stream_channel_client_new(this, red_client, stream, migration, caps);
- if (client == NULL) {
+ if (client == nullptr) {
return;
}
@@ -433,7 +433,7 @@ StreamChannel::change_format(const StreamMsgFormat *fmt)
item->stream_create.src_width = fmt->width;
item->stream_create.src_height = fmt->height;
item->stream_create.dest = (SpiceRect) { 0, 0, fmt->width, fmt->height };
- item->stream_create.clip = (SpiceClip) { SPICE_CLIP_TYPE_NONE, NULL };
+ item->stream_create.clip = (SpiceClip) { SPICE_CLIP_TYPE_NONE, nullptr };
pipes_add(std::move(item));
// activate stream report if possible
diff --git a/server/tests/test-channel.cpp b/server/tests/test-channel.cpp
index 42733718..036f4992 100644
--- a/server/tests/test-channel.cpp
+++ b/server/tests/test-channel.cpp
@@ -89,8 +89,8 @@ RedTestChannelClient::release_recv_buf(uint16_t type, uint32_t size, uint8_t *ms
*/
typedef SpiceWatch *watch_add_t(const SpiceCoreInterfaceInternal *iface,
int fd, int event_mask, SpiceWatchFunc func, void *opaque);
-static watch_add_t *old_watch_add = NULL;
-static SpiceWatchFunc old_watch_func = NULL;
+static watch_add_t *old_watch_add = nullptr;
+static SpiceWatchFunc old_watch_func = nullptr;
static int watch_called_countdown = 5;
@@ -229,7 +229,7 @@ static void channel_loop()
g_assert(main_channel);
MainChannelClient *mcc;
- mcc = main_channel_link(main_channel.get(), client, create_dummy_stream(server, NULL),
+ mcc = main_channel_link(main_channel.get(), client, create_dummy_stream(server, nullptr),
0, FALSE, &caps);
g_assert_nonnull(mcc);
diff --git a/server/tests/test-dispatcher.cpp b/server/tests/test-dispatcher.cpp
index 65e3f215..92488361 100644
--- a/server/tests/test-dispatcher.cpp
+++ b/server/tests/test-dispatcher.cpp
@@ -59,10 +59,10 @@ static void test_dispatcher_teardown(TestFixture *fixture, gconstpointer user_da
g_assert_nonnull(core);
red_watch_remove(watch);
- watch = NULL;
+ watch = nullptr;
dispatcher.reset();
basic_event_loop_destroy();
- core = NULL;
+ core = nullptr;
}
// test message to sent
@@ -96,12 +96,12 @@ static void *thread_proc(void *arg)
// repeat sending messages
for (unsigned n = 0; n < iterations; ++n) {
- Msg msg{n, NULL};
+ Msg msg{n, nullptr};
dispatcher->send_message_custom(msg_check, &msg, (n % 10) >= n_nack);
}
// one last sync to wait
- Msg msg{0, NULL};
+ Msg msg{0, nullptr};
dispatcher->send_message_custom(msg_end, &msg, true);
// measure time
@@ -110,21 +110,21 @@ static void *thread_proc(void *arg)
printf("With ACK/NACK %d/%d time spent %gus each over %u iterations\n",
10 - n_nack, n_nack,
cost / 1000.0 / iterations, iterations);
- return NULL;
+ return nullptr;
}
static void test_dispatcher(TestFixture *fixture, gconstpointer user_data)
{
pthread_t th;
- g_assert_cmpint(pthread_create(&th, NULL, thread_proc, (void *) user_data), ==, 0);
+ g_assert_cmpint(pthread_create(&th, nullptr, thread_proc, (void *) user_data), ==, 0);
// start all test
alarm(20);
basic_event_loop_mainloop();
alarm(0);
- pthread_join(th, NULL);
+ pthread_join(th, nullptr);
}
int main(int argc, char *argv[])
diff --git a/server/tests/test-display-base.cpp b/server/tests/test-display-base.cpp
index 62683500..81455998 100644
--- a/server/tests/test-display-base.cpp
+++ b/server/tests/test-display-base.cpp
@@ -100,7 +100,7 @@ static void child_exited(GPid pid, gint status, gpointer user_data)
static void regression_test()
{
GPid pid;
- GError *error = NULL;
+ GError *error = nullptr;
gboolean retval;
gchar **argv;
@@ -115,13 +115,13 @@ static void regression_test()
}
argv = g_strsplit("./regression-test.py", " ", -1);
- retval = g_spawn_async(NULL, argv, NULL, (GSpawnFlags) (G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD),
- NULL, NULL, &pid, &error);
+ retval = g_spawn_async(nullptr, argv, nullptr, (GSpawnFlags) (G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD),
+ nullptr, nullptr, &pid, &error);
g_strfreev(argv);
g_assert(retval);
GSource *source = g_child_watch_source_new(pid);
- g_source_set_callback(source, (GSourceFunc)(void*)child_exited, NULL, NULL);
+ g_source_set_callback(source, (GSourceFunc)(void*)child_exited, nullptr, nullptr);
guint id = g_source_attach(source, basic_event_loop_get_context());
g_assert(id != 0);
g_source_unref(source);
@@ -259,7 +259,7 @@ static SimpleSpiceUpdate *test_spice_create_update_solid(uint32_t surface_id, QX
*dst = solid_color;
}
- return test_spice_create_update_from_bitmap(surface_id, bbox, bitmap, 0, NULL);
+ return test_spice_create_update_from_bitmap(surface_id, bbox, bitmap, 0, nullptr);
}
static SimpleSpiceUpdate *test_spice_create_update_draw(Test *test, uint32_t surface_id, int t)
@@ -299,7 +299,7 @@ static SimpleSpiceUpdate *test_spice_create_update_draw(Test *test, uint32_t sur
bbox.left = left; bbox.top = top;
bbox.right = left + bw; bbox.bottom = top + bh;
- return test_spice_create_update_from_bitmap(surface_id, bbox, bitmap, 0, NULL);
+ return test_spice_create_update_from_bitmap(surface_id, bbox, bitmap, 0, nullptr);
}
static SimpleSpiceUpdate *test_spice_create_update_copy_bits(Test *test, uint32_t surface_id)
@@ -484,7 +484,7 @@ static int get_num_commands()
static struct QXLCommandExt *get_simple_command()
{
pthread_mutex_lock(&command_mutex);
- struct QXLCommandExt *ret = NULL;
+ struct QXLCommandExt *ret = nullptr;
if (get_num_commands() > 0) {
ret = commands[commands_start % COMMANDS_SIZE];
commands_start++;
@@ -537,7 +537,7 @@ static void produce_command(Test *test)
.right = (test->target_surface == 0 ? test->primary_width : test->width),
};
if (rect.right > 0 && rect.bottom > 0) {
- spice_qxl_update_area(&test->qxl_instance, test->target_surface, &rect, NULL, 0, 1);
+ spice_qxl_update_area(&test->qxl_instance, test->target_surface, &rect, nullptr, 0, 1);
}
break;
}
@@ -800,7 +800,7 @@ static QXLInterface display_sif = {
},
{ .attached_worker = attached_worker },
.set_compression_level = set_compression_level,
- .set_mm_time = NULL,
+ .set_mm_time = nullptr,
.get_init_info = get_init_info,
/* the callbacks below are called from spice server thread context */
@@ -811,8 +811,8 @@ static QXLInterface display_sif = {
.req_cursor_notification = req_cursor_notification,
.notify_update = notify_update,
.flush_resources = flush_resources,
- .async_complete = NULL,
- .update_area_complete = NULL,
+ .async_complete = nullptr,
+ .update_area_complete = nullptr,
.set_client_capabilities = set_client_capabilities,
.client_monitors_config = client_monitors_config,
};
@@ -900,9 +900,9 @@ static gboolean ignore_in_use_failures(const gchar *log_domain,
if ((log_level & G_LOG_LEVEL_WARNING) == 0) {
return true;
}
- if (strstr(message, "reds_init_socket: binding socket to ") == NULL && // bind failure
- strstr(message, "reds_init_socket: listen: ") == NULL && // listen failure
- strstr(message, "Failed to open SPICE sockets") == NULL) { // global
+ if (strstr(message, "reds_init_socket: binding socket to ") == nullptr && // bind failure
+ strstr(message, "reds_init_socket: listen: ") == nullptr && // listen failure
+ strstr(message, "Failed to open SPICE sockets") == nullptr) { // global
g_print("XXX [%s]\n", message);
return true;
}
@@ -926,7 +926,7 @@ Test* test_new(SpiceCoreInterface* core)
// some common initialization for all display tests
port = BASE_PORT;
- g_test_log_set_fatal_handler(ignore_in_use_failures, NULL);
+ g_test_log_set_fatal_handler(ignore_in_use_failures, nullptr);
for (port = BASE_PORT; port < BASE_PORT + 10; port++) {
SpiceServer* server = spice_server_new();
spice_server_set_noauth(server);
@@ -941,7 +941,7 @@ Test* test_new(SpiceCoreInterface* core)
g_assert_nonnull(test->server);
printf("TESTER: listening on port %d (unsecure)\n", port);
- g_test_log_set_fatal_handler(NULL, NULL);
+ g_test_log_set_fatal_handler(nullptr, nullptr);
cursor_init();
path_init(&path, 0, angle_parts);
@@ -977,7 +977,7 @@ void spice_test_config_parse_args(int argc, char **argv)
{
struct option options[] = {
{"automated-tests", no_argument, &has_automated_tests, 1},
- {NULL, 0, NULL, 0},
+ {nullptr, 0, nullptr, 0},
};
int option_index;
int val;
diff --git a/server/tests/test-stream-device.cpp b/server/tests/test-stream-device.cpp
index 15c2dfad..9f009f88 100644
--- a/server/tests/test-stream-device.cpp
+++ b/server/tests/test-stream-device.cpp
@@ -174,11 +174,11 @@ static void test_stream_device_teardown(TestFixture *fixture, gconstpointer user
g_assert_nonnull(test);
vmc_emu_destroy(vmc);
- vmc = NULL;
+ vmc = nullptr;
test_destroy(test);
- test = NULL;
+ test = nullptr;
basic_event_loop_destroy();
- core = NULL;
+ core = nullptr;
}
static void test_kick()
@@ -459,22 +459,22 @@ int main(int argc, char *argv[])
g_test_init(&argc, &argv, NULL);
test_add("/server/stream-device",
- test_stream_device, NULL);
+ test_stream_device, nullptr);
test_add("/server/stream-device-unfinished",
- test_stream_device_unfinished, NULL);
+ test_stream_device_unfinished, nullptr);
test_add("/server/stream-device-multiple",
- test_stream_device_multiple, NULL);
+ test_stream_device_multiple, nullptr);
test_add("/server/stream-device-format-after-data",
- test_stream_device_format_after_data, NULL);
+ test_stream_device_format_after_data, nullptr);
test_add("/server/stream-device-empty-capabilities",
test_stream_device_empty, GINT_TO_POINTER(STREAM_TYPE_CAPABILITIES));
test_add("/server/stream-device-empty-data",
test_stream_device_empty, GINT_TO_POINTER(STREAM_TYPE_DATA));
test_add("/server/stream-device-huge-data",
- test_stream_device_huge_data, NULL);
+ test_stream_device_huge_data, nullptr);
test_add("/server/stream-device-data-message",
- test_stream_device_data_message, NULL);
- test_add("/server/display-info", test_display_info, NULL);
+ test_stream_device_data_message, nullptr);
+ test_add("/server/display-info", test_display_info, nullptr);
return g_test_run();
}
diff --git a/server/tree.cpp b/server/tree.cpp
index d1073641..8567ae13 100644
--- a/server/tree.cpp
+++ b/server/tree.cpp
@@ -136,12 +136,12 @@ static void dump_item(TreeItem *item, void *data)
printf(" ");
}
printf(item_prefix, 0);
- show_red_drawable(drawable->red_drawable, NULL);
+ show_red_drawable(drawable->red_drawable, nullptr);
for (i = 0; i < di->level; i++) {
printf(" ");
}
printf("| ");
- show_draw_item(&drawable->tree_item, NULL);
+ show_draw_item(&drawable->tree_item, nullptr);
indent_str_len = MIN(max_indent, strlen(item_prefix) + di->level * 2);
memset(indent_str, ' ', indent_str_len);
indent_str[indent_str_len] = 0;
@@ -179,7 +179,7 @@ void tree_item_dump(TreeItem *item)
{
DumpItem di = { 0, };
- spice_return_if_fail(item != NULL);
+ spice_return_if_fail(item != nullptr);
tree_foreach(item, dump_item, &di);
}
@@ -188,15 +188,15 @@ void tree_item_dump(TreeItem *item)
* DrawItem represents the destination region for the operation */
Shadow* shadow_new(DrawItem *item, const SpicePoint *delta)
{
- spice_return_val_if_fail(item->shadow == NULL, NULL);
+ spice_return_val_if_fail(item->shadow == nullptr, NULL);
if (!delta->x && !delta->y) {
- return NULL;
+ return nullptr;
}
auto shadow = g_new(Shadow, 1);
shadow->base.type = TREE_ITEM_TYPE_SHADOW;
- shadow->base.container = NULL;
+ shadow->base.container = nullptr;
region_clone(&shadow->base.rgn, &item->base.rgn);
region_offset(&shadow->base.rgn, delta->x, delta->y);
ring_item_init(&shadow->base.siblings_link);
@@ -263,12 +263,12 @@ Shadow* tree_item_find_shadow(TreeItem *item)
while (item->type == TREE_ITEM_TYPE_CONTAINER) {
SPICE_VERIFY(SPICE_OFFSETOF(TreeItem, siblings_link) == 0);
if (!(item = (TreeItem *)ring_get_tail(&CONTAINER(item)->items))) {
- return NULL;
+ return nullptr;
}
}
if (item->type != TREE_ITEM_TYPE_DRAWABLE) {
- return NULL;
+ return nullptr;
}
return DRAW_ITEM(item)->shadow;
@@ -302,7 +302,7 @@ void draw_item_remove_shadow(DrawItem *item)
return;
}
shadow = item->shadow;
- item->shadow = NULL;
+ item->shadow = nullptr;
ring_remove(&shadow->base.siblings_link);
region_destroy(&shadow->base.rgn);
region_destroy(&shadow->on_hold);
diff --git a/server/video-stream.cpp b/server/video-stream.cpp
index 4c8dbc56..7c731f35 100644
--- a/server/video-stream.cpp
+++ b/server/video-stream.cpp
@@ -132,7 +132,7 @@ void display_channel_init_video_streams(DisplayChannel *display)
int i;
ring_init(&display->priv->streams);
- display->priv->free_streams = NULL;
+ display->priv->free_streams = nullptr;
for (i = 0; i < NUM_STREAMS; i++) {
VideoStream *stream = display_channel_get_nth_video_stream(display, i);
ring_item_init(&stream->link);
@@ -316,8 +316,8 @@ void video_stream_detach_drawable(VideoStream *stream)
{
spice_assert(stream->current && stream->current->stream);
spice_assert(stream->current->stream == stream);
- stream->current->stream = NULL;
- stream->current = NULL;
+ stream->current->stream = nullptr;
+ stream->current = nullptr;
}
static void before_reattach_stream(DisplayChannel *display,
@@ -361,7 +361,7 @@ static VideoStream *display_channel_stream_try_new(DisplayChannel *display)
{
VideoStream *stream;
if (!display->priv->free_streams) {
- return NULL;
+ return nullptr;
}
stream = display->priv->free_streams;
display->priv->free_streams = display->priv->free_streams->next;
@@ -521,7 +521,7 @@ void video_stream_trace_update(DisplayChannel *display, Drawable *drawable)
trace_end = trace + NUM_TRACE_ITEMS;
for (; trace < trace_end; trace++) {
if (is_next_stream_frame(drawable, trace->width, trace->height,
- &trace->dest_area, trace->time, NULL, FALSE)) {
+ &trace->dest_area, trace->time, nullptr, FALSE)) {
if (video_stream_add_frame(display, drawable,
trace->first_frame_time,
trace->frames_count,
@@ -606,11 +606,11 @@ static uint64_t get_initial_bit_rate(DisplayChannelClient *dcc, VideoStream *str
uint64_t bit_rate = 0;
env_bit_rate_str = getenv("SPICE_BIT_RATE");
- if (env_bit_rate_str != NULL) {
+ if (env_bit_rate_str != nullptr) {
double env_bit_rate;
errno = 0;
- env_bit_rate = strtod(env_bit_rate_str, NULL);
+ env_bit_rate = strtod(env_bit_rate_str, nullptr);
if (errno == 0 && env_bit_rate > 0) {
bit_rate = env_bit_rate * 1024 * 1024;
} else {
@@ -739,7 +739,7 @@ static VideoEncoder* dcc_create_video_encoder(DisplayChannelClient *dcc,
return mjpeg_encoder_new(SPICE_VIDEO_CODEC_TYPE_MJPEG, starting_bit_rate, cbs, bitmap_ref, bitmap_unref);
}
- return NULL;
+ return nullptr;
}
void dcc_create_stream(DisplayChannelClient *dcc, VideoStream *stream)
@@ -788,7 +788,7 @@ void video_stream_agent_stop(VideoStreamAgent *agent)
dcc_update_streams_max_latency(dcc, agent);
if (agent->video_encoder) {
agent->video_encoder->destroy(agent->video_encoder);
- agent->video_encoder = NULL;
+ agent->video_encoder = nullptr;
}
}
@@ -852,7 +852,7 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
region_extents(&agent->vis_region, &upgrade_area);
spice_debug("stream %d: upgrade by screenshot. has current %d. box ==>",
- stream_id, stream->current != NULL);
+ stream_id, stream->current != nullptr);
rect_debug(&upgrade_area);
if (update_area_limit) {
display_channel_draw_until(display, &upgrade_area, 0, update_area_limit);
@@ -932,7 +932,7 @@ void video_stream_detach_and_stop(DisplayChannel *display)
while ((stream_item = ring_get_head(&display->priv->streams))) {
VideoStream *stream = SPICE_CONTAINEROF(stream_item, VideoStream, link);
- detach_video_stream_gracefully(display, stream, NULL);
+ detach_video_stream_gracefully(display, stream, nullptr);
video_stream_stop(display, stream);
}
}
@@ -948,7 +948,7 @@ void video_stream_timeout(DisplayChannel *display)
VideoStream *stream = SPICE_CONTAINEROF(item, VideoStream, link);
item = ring_next(ring, item);
if (now >= (stream->last_time + RED_STREAM_TIMEOUT)) {
- detach_video_stream_gracefully(display, stream, NULL);
+ detach_video_stream_gracefully(display, stream, nullptr);
video_stream_stop(display, stream);
}
}
commit 24dfe33c065c4eb8a598674f569004e51ac18b2d
Author: Rosen Penev <rosenp at gmail.com>
Date: Mon Apr 12 06:43:38 2021 +0100
clang-tidy: use const reference for loop
Found with performance-for-range-copy
Avoids unnecessary copying when the loop does not modify the variable.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Acked-by: Frediano Ziglio <freddy77 at gmail.com>
diff --git a/server/reds.cpp b/server/reds.cpp
index 1bd36ac9..e48919bd 100644
--- a/server/reds.cpp
+++ b/server/reds.cpp
@@ -354,7 +354,7 @@ int reds_get_free_channel_id(RedsState *reds, uint32_t type)
// mark id used for the specific channel type
memset(used_ids, 0, sizeof(used_ids));
- for (const auto channel: reds->channels) {
+ for (const auto &channel: reds->channels) {
if (channel->type() == type && channel->id() < SPICE_N_ELEMENTS(used_ids)) {
used_ids[channel->id()] = true;
}
@@ -599,7 +599,7 @@ static void reds_update_mouse_mode(RedsState *reds)
int qxl_count = reds->qxl_instances.size();
int display_channel_count = 0;
- for (const auto channel: reds->channels) {
+ for (const auto &channel: reds->channels) {
if (channel->type() == SPICE_CHANNEL_DISPLAY) {
++display_channel_count;
}
@@ -972,7 +972,7 @@ static void reds_fill_channels(RedsState *reds, SpiceMsgChannels *channels_info)
{
int used_channels = 0;
- for (const auto channel: reds->channels) {
+ for (const auto &channel: reds->channels) {
if (reds->clients.size() > 1 &&
!channel_supports_multiple_clients(channel.get())) {
continue;
More information about the Spice-commits
mailing list