[Spice-commits] 6 commits - src/channel-display.c src/channel-display-gst.c src/spice-util.c src/usb-backend.c src/usb-device-widget.c src/usbutil.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 30 12:38:18 UTC 2020


 src/channel-display-gst.c |    4 ++--
 src/channel-display.c     |    2 +-
 src/spice-util.c          |    2 +-
 src/usb-backend.c         |    3 +++
 src/usb-device-widget.c   |    4 +++-
 src/usbutil.c             |    7 +++++++
 6 files changed, 17 insertions(+), 5 deletions(-)

New commits:
commit 1068e4d0e39f3d8f3390102863a02eaed7ee81b1
Author: Uri Lublin <uril at redhat.com>
Date:   Mon Nov 23 15:38:43 2020 +0200

    spice-utils: allocate ctx after g_return_val_if_fail
    
    Fix the following issue:
      Error: RESOURCE_LEAK
      src/spice-util.c:235: alloc_fn: Storage is returned
             from allocation function "whc_new".
      src/spice-util.c:235: var_assign: Assigning: "ctx" =
             storage returned from "whc_new(instance_obj, gobject)".
      src/spice-util.c:237: leaked_storage: Variable "ctx"
             going out of scope leaks the storage it points to.
    
      235|       WeakHandlerCtx *ctx = whc_new (instance_obj, gobject);
      236|
      237|->     g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0);
      238|       g_return_val_if_fail (detailed_signal != NULL, 0);
      239|       g_return_val_if_fail (c_handler != NULL, 0);
    
    Signed-off-by: Uri Lublin <uril at redhat.com>

diff --git a/src/spice-util.c b/src/spice-util.c
index 1e49982..d0c56ba 100644
--- a/src/spice-util.c
+++ b/src/spice-util.c
@@ -231,7 +231,6 @@ gulong spice_g_signal_connect_object (gpointer instance,
                                       GConnectFlags connect_flags)
 {
     GObject *instance_obj = G_OBJECT (instance);
-    WeakHandlerCtx *ctx = whc_new (instance_obj, gobject);
 
     g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0);
     g_return_val_if_fail (detailed_signal != NULL, 0);
@@ -240,6 +239,7 @@ gulong spice_g_signal_connect_object (gpointer instance,
     g_return_val_if_fail (
                           (connect_flags & ~(G_CONNECT_AFTER|G_CONNECT_SWAPPED)) == 0, 0);
 
+    WeakHandlerCtx *ctx = whc_new (instance_obj, gobject);
     if (connect_flags & G_CONNECT_SWAPPED)
         ctx->closure = g_cclosure_new_object_swap (c_handler, gobject);
     else
commit 35f6926328cd415f6ba24efe49c3f990e44a8948
Author: Uri Lublin <uril at redhat.com>
Date:   Sun Nov 22 16:21:00 2020 +0200

    usb-backend: create_emulated_device: assert address < 32
    
    This may fix the following static analyzer issue:
      src/usb-backend.c:1507: large_shift: In expression "1 << address", left
      shifting by more than 31 bits has undefined behavior.
      The shift amount, "address", is 32.
    
    Signed-off-by: Uri Lublin <uril at redhat.com>

diff --git a/src/usb-backend.c b/src/usb-backend.c
index 857488e..c76d576 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -1482,6 +1482,9 @@ spice_usb_backend_create_emulated_device(SpiceUsbBackend *be,
         }
     }
 
+    // for static analyzers: it is already checked above
+    g_assert(address < 32);
+
     dev = g_new0(SpiceUsbDevice, 1);
     dev->device_info.bus = BUS_NUMBER_FOR_EMULATED_USB;
     dev->device_info.address = address;
commit df47365c32711bae5dfa163f8eba7b0f741326d6
Author: Uri Lublin <uril at redhat.com>
Date:   Thu Nov 19 19:30:54 2020 +0200

    mark_false_event_id is guint, assign 0 to it not FALSE
    
    Signed-off-by: Uri Lublin <uril at redhat.com>

diff --git a/src/channel-display.c b/src/channel-display.c
index 023baa1..f52ef12 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -1971,7 +1971,7 @@ static void display_handle_surface_create(SpiceChannel *channel, SpiceMsgIn *in)
         create_canvas(channel, surface);
         if (c->mark_false_event_id != 0) {
             g_source_remove(c->mark_false_event_id);
-            c->mark_false_event_id = FALSE;
+            c->mark_false_event_id = 0;
         }
     } else {
         surface->primary = false;
commit bb4999f6e450aa1b1270ade7113966869fc4ed27
Author: Uri Lublin <uril at redhat.com>
Date:   Wed Nov 11 20:34:09 2020 +0200

    sink_event_probe: do not keep duration in a variable
    
    If not ENABLE_RECORDER, then duration is assigned a value
    but is never used - as the compiler optimizes it out.
    
    Fixes the following clang warning:
      src/channel-display-gst.c:443:21: warning: Value stored to
      'duration' during its initialization is never read
    
    Signed-off-by: Uri Lublin <uril at redhat.com>

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index c58a90f..36db3a3 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -439,7 +439,6 @@ sink_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointer data)
         if (l) {
             SpiceGstFrame *gstframe = l->data;
             const SpiceFrame *frame = gstframe->encoded_frame;
-            int64_t duration = g_get_monotonic_time() - frame->creation_time;
             /* Note that queue_len (the length of the queue prior to adding
              * this frame) is crucial to correctly interpret the decoding time:
              * - Less than MAX_DECODED_FRAMES means nothing blocked the
@@ -450,7 +449,8 @@ sink_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointer data)
             record(frames_stats,
                    "frame mm_time %u size %u creation time %" PRId64
                    " decoded time %" PRId64 " queue %u before %u",
-                   frame->mm_time, frame->size, frame->creation_time, duration,
+                   frame->mm_time, frame->size, frame->creation_time,
+                   g_get_monotonic_time() - frame->creation_time,
                    decoder->decoding_queue->length, gstframe->queue_len);
 
             if (!decoder->appsink) {
commit 032ca202f839fe1c49cddfd2b0459f9fecc23c86
Author: Uri Lublin <uril at redhat.com>
Date:   Wed Nov 11 20:03:57 2020 +0200

    spice_usbutil_parse_usbids: verify at least one vendor and product
    
    Fixes the following clang warning:
      src/usbutil.c:148:52: warning: Use of zero-allocated memory
      ...
    
       product_info[product_count].product_id = id;
                                              ^
       146|               while (isspace(line[0]))
       147|                   line++;
       148|->             product_info[product_count].product_id = id;
       149|               snprintf(product_info[product_count].name,
       150|                        PRODUCT_NAME_LEN, "%s", line);
    
    Signed-off-by: Uri Lublin <uril at redhat.com>

diff --git a/src/usbutil.c b/src/usbutil.c
index 7d7f38a..f29302b 100644
--- a/src/usbutil.c
+++ b/src/usbutil.c
@@ -113,6 +113,13 @@ static gboolean spice_usbutil_parse_usbids(gchar *path)
         usbids_vendor_count++;
     }
 
+    if (usbids_vendor_info == 0 || product_count == 0) {
+        usbids_vendor_count = -1;
+        g_strfreev(lines);
+        g_free(contents);
+        return FALSE;
+    }
+
     usbids_vendor_info = g_new(usb_vendor_info, usbids_vendor_count);
     product_info = g_new(usb_product_info, product_count);
 
commit 20eebc549da508c82e139120b577b047c76964c3
Author: Uri Lublin <uril at redhat.com>
Date:   Wed Nov 11 14:12:19 2020 +0200

    empty_cd_clicked_cb: g_free basename
    
    Fix the following static analyzer warning:
      src/usb-device-widget.c:224: leaked_storage: Failing to save or free
      storage allocated by "g_path_get_basename(filename)" leaks it.
    
    Signed-off-by: Uri Lublin <uril at redhat.com>

diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index 257e9e1..0ff4e52 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -220,8 +220,10 @@ empty_cd_clicked_cb(GtkToggleButton *toggle, gpointer user_data)
 
         rc = spice_usb_device_manager_create_shared_cd_device(priv->manager, filename, &err);
         if (!rc && err != NULL) {
+            const gchar *basename = g_path_get_basename(filename);
             gchar *err_msg = g_strdup_printf(_("shared CD %s, %s"),
-                                             g_path_get_basename(filename), err->message);
+                                             basename, err->message);
+            g_free((gpointer)basename);
 
             SPICE_DEBUG("Failed to create %s", err_msg);
             spice_usb_device_widget_add_err_msg(self, err_msg);


More information about the Spice-commits mailing list