[Spice-commits] 5 commits - server/char-device.cpp server/cursor-channel.cpp server/dispatcher.cpp server/red-channel-client.cpp server/red-channel.cpp server/red-replay-qxl.cpp server/reds.cpp server/sound.cpp server/spicevmc.cpp server/stream-channel.cpp server/tests
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Apr 9 07:27:30 UTC 2021
server/char-device.cpp | 6 ++----
server/cursor-channel.cpp | 6 ++----
server/dispatcher.cpp | 4 +---
server/red-channel-client.cpp | 4 +---
server/red-channel.cpp | 4 +---
server/red-replay-qxl.cpp | 2 +-
server/reds.cpp | 24 ++++++++++++------------
server/sound.cpp | 24 ++++++++++++------------
server/spicevmc.cpp | 26 +++++++++++++-------------
server/stream-channel.cpp | 10 +++++-----
server/tests/test-channel.cpp | 4 ++--
11 files changed, 52 insertions(+), 62 deletions(-)
New commits:
commit 04e885b2911caef3dd1c9535d5997e114513a494
Author: Rosen Penev <rosenp at gmail.com>
Date: Mon Oct 5 03:15:51 2020 -0700
clang-tidy: test for empty instead of size
Found with readability-container-size-empty
This has the potential for extra performance as it's not checking for
every single element.
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 9aac92dc..225b3366 100644
--- a/server/char-device.cpp
+++ b/server/char-device.cpp
@@ -317,7 +317,7 @@ red_char_device_send_to_client_tokens_absorb(RedCharDevice *dev,
}
dev_client->num_send_tokens += tokens;
- if (dev_client->send_queue.size()) {
+ if (!dev_client->send_queue.empty()) {
spice_assert(dev_client->num_send_tokens == tokens);
red_char_device_client_send_queue_push(dev_client);
}
commit 23bd93bfb47b2dedb8ed70f54887f32df0fb4977
Author: Rosen Penev <rosenp at gmail.com>
Date: Mon Oct 5 02:54:03 2020 -0700
clang-tidy: use bool literals
Found with modernize-use-bool-literals
Avoids implicit conversions.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Acked-by: Frediano Ziglio <freddy77 at gmail.com>
diff --git a/server/red-replay-qxl.cpp b/server/red-replay-qxl.cpp
index c87a79c8..d0b608f4 100644
--- a/server/red-replay-qxl.cpp
+++ b/server/red-replay-qxl.cpp
@@ -148,7 +148,7 @@ static uint32_t replay_id_new(SpiceReplay *replay, uint32_t id)
uint32_t *map;
pthread_mutex_lock(&replay->mutex);
- while (1) {
+ while (true) {
if (replay->id_free->len > 0) {
new_id = g_array_index(replay->id_free, uint32_t, 0);
g_array_remove_index_fast(replay->id_free, 0);
commit 68b0f3029d9846f1eaeaee80f2b84d255daa924a
Author: Rosen Penev <rosenp at gmail.com>
Date: Mon Oct 5 02:49:51 2020 -0700
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 319fd32c..8cec7bbc 100644
--- a/server/reds.cpp
+++ b/server/reds.cpp
@@ -333,7 +333,7 @@ void reds_unregister_channel(RedsState *reds, RedChannel *channel)
RedChannel *reds_find_channel(RedsState *reds, uint32_t type, uint32_t id)
{
- for (auto channel: reds->channels) {
+ for (const auto& channel: reds->channels) {
if (channel->type() == type && channel->id() == id) {
return channel.get();
}
@@ -810,7 +810,7 @@ void reds_marshall_device_display_info(RedsState *reds, SpiceMarshaller *m)
}
// add the stream devices to the message
- for (auto dev: reds->char_devices) {
+ for (const auto& dev: reds->char_devices) {
auto stream_dev = dynamic_cast<StreamDevice*>(dev.get());
if (stream_dev) {
const StreamDeviceDisplayInfo *info = stream_dev->get_device_display_info();
@@ -1728,7 +1728,7 @@ static void reds_late_initialization(RedsState *reds)
}
// create stream channels for streaming devices
- for (auto dev: reds->char_devices) {
+ for (const auto& dev: reds->char_devices) {
auto stream_dev = dynamic_cast<StreamDevice*>(dev.get());
if (stream_dev) {
stream_dev->create_channel();
@@ -4244,7 +4244,7 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_switch(SpiceServer *reds)
SPICE_GNUC_VISIBLE void spice_server_vm_start(SpiceServer *reds)
{
reds->vm_running = TRUE;
- for (auto dev: reds->char_devices) {
+ for (const auto& dev: reds->char_devices) {
dev->start();
}
reds_on_vm_start(reds);
@@ -4253,7 +4253,7 @@ SPICE_GNUC_VISIBLE void spice_server_vm_start(SpiceServer *reds)
SPICE_GNUC_VISIBLE void spice_server_vm_stop(SpiceServer *reds)
{
reds->vm_running = FALSE;
- for (auto dev: reds->char_devices) {
+ for (const auto& dev: reds->char_devices) {
dev->stop();
}
reds_on_vm_stop(reds);
commit e353f1a065fbc7d84e0b405c4497af87594d977b
Author: Rosen Penev <rosenp at gmail.com>
Date: Mon Oct 5 02:36:23 2020 -0700
clang-tidy: use default
Found with modernize-use-equals-default
default allows extra optimization compared to an empty con/destructor.
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 bf3fafcf..9aac92dc 100644
--- a/server/char-device.cpp
+++ b/server/char-device.cpp
@@ -627,9 +627,7 @@ RedCharDeviceClient::RedCharDeviceClient(RedCharDevice *init_dev,
}
}
-RedCharDeviceClient::~RedCharDeviceClient()
-{
-}
+RedCharDeviceClient::~RedCharDeviceClient() = default;
bool RedCharDevice::client_add(RedCharDeviceClientOpaque *client,
int do_flow_control,
diff --git a/server/cursor-channel.cpp b/server/cursor-channel.cpp
index cd498485..8944e221 100644
--- a/server/cursor-channel.cpp
+++ b/server/cursor-channel.cpp
@@ -291,9 +291,7 @@ void CursorChannel::on_connect(RedClient *client, RedStream *stream, int migrati
cursor_channel_init_client(this, ccc);
}
-CursorChannel::~CursorChannel()
-{
-}
+CursorChannel::~CursorChannel() = default;
CursorChannel::CursorChannel(RedsState *reds, uint32_t id,
SpiceCoreInterfaceInternal *core, Dispatcher *dispatcher):
diff --git a/server/dispatcher.cpp b/server/dispatcher.cpp
index 1163681c..34f2d251 100644
--- a/server/dispatcher.cpp
+++ b/server/dispatcher.cpp
@@ -74,9 +74,7 @@ DispatcherPrivate::~DispatcherPrivate()
g_free(payload);
}
-Dispatcher::~Dispatcher()
-{
-}
+Dispatcher::~Dispatcher() = default;
Dispatcher::Dispatcher(uint32_t max_message_type):
priv(new DispatcherPrivate(max_message_type))
diff --git a/server/red-channel-client.cpp b/server/red-channel-client.cpp
index 48271a9d..961c7bd5 100644
--- a/server/red-channel-client.cpp
+++ b/server/red-channel-client.cpp
@@ -355,9 +355,7 @@ RedChannelClientPrivate::~RedChannelClientPrivate()
/* This even empty is better to by declared here to make sure
* we call the right delete for priv field
*/
-RedChannelClient::~RedChannelClient()
-{
-}
+RedChannelClient::~RedChannelClient() = default;
RedChannelClient::RedChannelClient(RedChannel *channel,
RedClient *client,
diff --git a/server/red-channel.cpp b/server/red-channel.cpp
index c06f29e5..282d304a 100644
--- a/server/red-channel.cpp
+++ b/server/red-channel.cpp
@@ -129,9 +129,7 @@ RedChannel::RedChannel(RedsState *reds, uint32_t type, uint32_t id, CreationFlag
set_common_cap(SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
}
-RedChannel::~RedChannel()
-{
-}
+RedChannel::~RedChannel() = default;
uint32_t RedChannel::id() const
{
commit f64e61e44df8ed03f44c1f7ca55ce9fc1460911a
Author: Rosen Penev <rosenp at gmail.com>
Date: Mon Oct 5 02:32:41 2020 -0700
clang-tidy: use override and remove virtual
Found with modernize-use-override
This can be useful as compilers can generate a compile time error when:
The base class implementation function signature changes.
The user has not created the override with the correct
signature.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Acked-by: Frediano Ziglio <freddy77 at gmail.com>
diff --git a/server/cursor-channel.cpp b/server/cursor-channel.cpp
index 691c304d..cd498485 100644
--- a/server/cursor-channel.cpp
+++ b/server/cursor-channel.cpp
@@ -27,7 +27,7 @@
struct RedCursorPipeItem: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_CURSOR> {
explicit RedCursorPipeItem(RedCursorCmd *cmd);
- ~RedCursorPipeItem();
+ ~RedCursorPipeItem() override;
RedCursorCmd *red_cursor;
};
diff --git a/server/reds.cpp b/server/reds.cpp
index 3ae0216a..319fd32c 100644
--- a/server/reds.cpp
+++ b/server/reds.cpp
@@ -155,7 +155,7 @@ struct ChannelSecurityOptions {
};
struct RedVDIReadBuf final: public RedAgentDataPipeItem {
- ~RedVDIReadBuf();
+ ~RedVDIReadBuf() override;
RedCharDeviceVDIPort *dev;
};
@@ -209,13 +209,13 @@ struct RedCharDeviceVDIPort: public RedCharDevice
{
explicit RedCharDeviceVDIPort(RedsState *reds);
RedCharDeviceVDIPort();
- ~RedCharDeviceVDIPort();
+ ~RedCharDeviceVDIPort() override;
- virtual RedPipeItemPtr read_one_msg_from_device() override;
- virtual void send_msg_to_client(RedPipeItem *msg, RedCharDeviceClientOpaque *opaque) override;
- virtual void send_tokens_to_client(RedCharDeviceClientOpaque *opaque, uint32_t tokens) override;
- virtual void remove_client(RedCharDeviceClientOpaque *opaque) override;
- virtual void on_free_self_token() override;
+ RedPipeItemPtr read_one_msg_from_device() override;
+ void send_msg_to_client(RedPipeItem *msg, RedCharDeviceClientOpaque *opaque) override;
+ void send_tokens_to_client(RedCharDeviceClientOpaque *opaque, uint32_t tokens) override;
+ void remove_client(RedCharDeviceClientOpaque *opaque) override;
+ void on_free_self_token() override;
RedCharDeviceVDIPortPrivate priv[1];
};
diff --git a/server/sound.cpp b/server/sound.cpp
index 322171a2..4c636872 100644
--- a/server/sound.cpp
+++ b/server/sound.cpp
@@ -106,10 +106,10 @@ public:
inline SndChannel* get_channel();
- virtual bool config_socket() override;
- virtual uint8_t *alloc_recv_buf(uint16_t type, uint32_t size) override;
- virtual void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override;
- virtual void migrate() override;
+ bool config_socket() override;
+ uint8_t *alloc_recv_buf(uint16_t type, uint32_t size) override;
+ void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override;
+ void migrate() override;
private:
/* we don't expect very big messages so don't allocate too much
@@ -139,13 +139,13 @@ struct AudioFrameContainer
class PlaybackChannelClient final: public SndChannelClient
{
protected:
- ~PlaybackChannelClient();
+ ~PlaybackChannelClient() override;
public:
PlaybackChannelClient(PlaybackChannel *channel,
RedClient *client,
RedStream *stream,
RedChannelCapabilities *caps);
- virtual bool init() override;
+ bool init() override;
AudioFrameContainer *frames = nullptr;
AudioFrame *free_frames = nullptr;
@@ -158,7 +158,7 @@ public:
static void on_message_marshalled(uint8_t *data, void *opaque);
protected:
- virtual void send_item(RedPipeItem *item) override;
+ void send_item(RedPipeItem *item) override;
};
struct SpiceVolumeState {
@@ -171,7 +171,7 @@ struct SpiceVolumeState {
struct SndChannel: public RedChannel
{
using RedChannel::RedChannel;
- ~SndChannel();
+ ~SndChannel() override;
void set_peer_common();
bool active;
SpiceVolumeState volume;
@@ -202,10 +202,10 @@ struct RecordChannel final: public SndChannel
class RecordChannelClient final: public SndChannelClient
{
protected:
- ~RecordChannelClient();
+ ~RecordChannelClient() override;
public:
using SndChannelClient::SndChannelClient;
- virtual bool init() override;
+ bool init() override;
uint32_t samples[RECORD_SAMPLES_SIZE];
uint32_t write_pos = 0;
@@ -216,8 +216,8 @@ public:
SndCodec codec = nullptr;
uint8_t decode_buf[SND_CODEC_MAX_FRAME_BYTES];
protected:
- virtual bool handle_message(uint16_t type, uint32_t size, void *message) override;
- virtual void send_item(RedPipeItem *item) override;
+ bool handle_message(uint16_t type, uint32_t size, void *message) override;
+ void send_item(RedPipeItem *item) override;
};
diff --git a/server/spicevmc.cpp b/server/spicevmc.cpp
index 43604f08..2e83d788 100644
--- a/server/spicevmc.cpp
+++ b/server/spicevmc.cpp
@@ -63,12 +63,12 @@ struct RedVmcPipeItem: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_SPICEVMC_DATA> {
struct RedCharDeviceSpiceVmc: public RedCharDevice
{
RedCharDeviceSpiceVmc(SpiceCharDeviceInstance *sin, RedsState *reds, RedVmcChannel *channel);
- ~RedCharDeviceSpiceVmc();
+ ~RedCharDeviceSpiceVmc() override;
- virtual RedPipeItemPtr read_one_msg_from_device() override;
- virtual void remove_client(RedCharDeviceClientOpaque *opaque) override;
- virtual void on_free_self_token() override;
- virtual void port_event(uint8_t event) override;
+ RedPipeItemPtr read_one_msg_from_device() override;
+ void remove_client(RedCharDeviceClientOpaque *opaque) override;
+ void on_free_self_token() override;
+ void port_event(uint8_t event) override;
red::shared_ptr<RedVmcChannel> channel;
};
@@ -78,7 +78,7 @@ static void spicevmc_red_channel_queue_data(RedVmcChannel *channel, red::shared_
struct RedVmcChannel: public RedChannel
{
RedVmcChannel(RedsState *reds, uint32_t type, uint32_t id);
- ~RedVmcChannel();
+ ~RedVmcChannel() override;
void on_connect(RedClient *client, RedStream *stream, int migration,
RedChannelCapabilities *caps) override;
@@ -108,13 +108,13 @@ public:
return static_cast<RedVmcChannel*>(RedChannelClient::get_channel());
}
protected:
- virtual uint8_t *alloc_recv_buf(uint16_t type, uint32_t size) override;
- virtual void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override;
- virtual void on_disconnect() override;
- virtual bool handle_message(uint16_t type, uint32_t size, void *msg) override;
- virtual void send_item(RedPipeItem *item) override;
- virtual bool handle_migrate_data(uint32_t size, void *message) override;
- virtual void handle_migrate_flush_mark() override;
+ uint8_t *alloc_recv_buf(uint16_t type, uint32_t size) override;
+ void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override;
+ void on_disconnect() override;
+ bool handle_message(uint16_t type, uint32_t size, void *msg) override;
+ void send_item(RedPipeItem *item) override;
+ bool handle_migrate_data(uint32_t size, void *message) override;
+ void handle_migrate_flush_mark() override;
};
static VmcChannelClient *
diff --git a/server/stream-channel.cpp b/server/stream-channel.cpp
index 08285bf6..9b04eddb 100644
--- a/server/stream-channel.cpp
+++ b/server/stream-channel.cpp
@@ -33,7 +33,7 @@
class StreamChannelClient final: public CommonGraphicsChannelClient
{
protected:
- ~StreamChannelClient();
+ ~StreamChannelClient() override;
public:
using CommonGraphicsChannelClient::CommonGraphicsChannelClient;
@@ -51,9 +51,9 @@ private:
bool handle_preferred_video_codec_type(SpiceMsgcDisplayPreferredVideoCodecType *msg);
void marshall_monitors_config(StreamChannel *channel, SpiceMarshaller *m);
void fill_base(SpiceMarshaller *m, const StreamChannel *channel);
- virtual void on_disconnect() override;
- virtual bool handle_message(uint16_t type, uint32_t size, void *msg) override;
- virtual void send_item(RedPipeItem *pipe_item) override;
+ void on_disconnect() override;
+ bool handle_message(uint16_t type, uint32_t size, void *msg) override;
+ void send_item(RedPipeItem *pipe_item) override;
};
enum {
@@ -72,7 +72,7 @@ struct StreamCreateItem: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_STREAM_CREATE>
};
struct StreamDataItem: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_STREAM_DATA> {
- ~StreamDataItem();
+ ~StreamDataItem() override;
StreamChannel *channel;
// NOTE: this must be the last field in the structure
diff --git a/server/tests/test-channel.cpp b/server/tests/test-channel.cpp
index e9163cd1..037677e3 100644
--- a/server/tests/test-channel.cpp
+++ b/server/tests/test-channel.cpp
@@ -44,8 +44,8 @@ struct RedTestChannel final: public RedChannel
class RedTestChannelClient final: public RedChannelClient
{
using RedChannelClient::RedChannelClient;
- virtual uint8_t * alloc_recv_buf(uint16_t type, uint32_t size) override;
- virtual void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override;
+ uint8_t * alloc_recv_buf(uint16_t type, uint32_t size) override;
+ void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override;
};
void
More information about the Spice-commits
mailing list