[Spice-commits] server/dcc.cpp server/dcc-send.cpp server/display-channel.cpp

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 26 08:34:51 UTC 2021


 server/dcc-send.cpp        |    2 +-
 server/dcc.cpp             |    4 ++--
 server/display-channel.cpp |    8 ++++----
 3 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 55897eba0f62077d67deb229a9e80d6fa55c5ac6
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Fri May 28 06:53:53 2021 +0100

    Remove some constant usage, use size from arrays
    
    Makes more clear that we are scanning entire arrays or
    checking for some container boundaries.
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>

diff --git a/server/dcc-send.cpp b/server/dcc-send.cpp
index d8a737e2..f61faeab 100644
--- a/server/dcc-send.cpp
+++ b/server/dcc-send.cpp
@@ -1751,7 +1751,7 @@ static void display_channel_marshall_migrate_data_surfaces(DisplayChannelClient
 
     num_surfaces_created_ptr = spice_marshaller_reserve_space(m2, sizeof(uint32_t));
     num_surfaces_created = 0;
-    for (i = 0; i < NUM_SURFACES; i++) {
+    for (i = 0; i < dcc->priv->surface_client_created.size(); i++) {
         SpiceRect lossy_rect;
 
         if (!dcc->priv->surface_client_created[i]) {
diff --git a/server/dcc.cpp b/server/dcc.cpp
index 2a5159a8..094e0860 100644
--- a/server/dcc.cpp
+++ b/server/dcc.cpp
@@ -323,7 +323,7 @@ static void dcc_init_stream_agents(DisplayChannelClient *dcc)
     int i;
     DisplayChannel *display = DCC_TO_DC(dcc);
 
-    for (i = 0; i < NUM_STREAMS; i++) {
+    for (i = 0; i < dcc->priv->stream_agents.size(); i++) {
         VideoStreamAgent *agent = &dcc->priv->stream_agents[i];
         agent->stream = display_channel_get_nth_video_stream(display, i);
         region_init(&agent->vis_region);
@@ -832,7 +832,7 @@ static bool dcc_handle_stream_report(DisplayChannelClient *dcc,
 {
     VideoStreamAgent *agent;
 
-    if (report->stream_id >= NUM_STREAMS) {
+    if (report->stream_id >= dcc->priv->stream_agents.size()) {
         spice_warning("stream_report: invalid stream id %u",
                       report->stream_id);
         return FALSE;
diff --git a/server/display-channel.cpp b/server/display-channel.cpp
index f56db9d6..c3affb01 100644
--- a/server/display-channel.cpp
+++ b/server/display-channel.cpp
@@ -35,13 +35,13 @@ DisplayChannel::~DisplayChannel()
         for (drawable = priv->free_drawables; drawable; drawable = drawable->u.next) {
             ++count;
         }
-        spice_assert(count == NUM_DRAWABLES);
+        spice_assert(count == priv->drawables.size());
 
         count = 0;
         for (stream = priv->free_streams; stream; stream = stream->next) {
             ++count;
         }
-        spice_assert(count == NUM_STREAMS);
+        spice_assert(count == priv->streams_buf.size());
         spice_assert(ring_is_empty(&priv->streams));
 
         for (const auto &surface : priv->surfaces) {
@@ -1902,7 +1902,7 @@ void display_channel_draw(DisplayChannel *display, const SpiceRect *area, int su
 {
     RedSurface *surface;
 
-    spice_return_if_fail(surface_id >= 0 && surface_id < NUM_SURFACES);
+    spice_return_if_fail(surface_id >= 0 && surface_id < display->priv->surfaces.size());
     spice_return_if_fail(area);
     spice_return_if_fail(area->left >= 0 && area->top >= 0 &&
                          area->left < area->right && area->top < area->bottom);
@@ -2188,7 +2188,7 @@ DisplayChannel::DisplayChannel(RedsState *reds,
         image_surfaces_get,
     };
 
-    priv->n_surfaces = MIN(n_surfaces, NUM_SURFACES);
+    priv->n_surfaces = MIN(n_surfaces, priv->surfaces.size());
     priv->qxl = qxl;
 
     /* must be manually allocated here since g_type_class_add_private() only


More information about the Spice-commits mailing list