[Spice-devel] [PATCH vd_agent_linux 5/5] x11: Change check to make code scanners not giving warning

Frediano Ziglio fziglio at redhat.com
Wed Jul 24 08:21:32 UTC 2019


Some code scanners (both Coverity and clang one) report that
prev_sel/prev_cond could be unreferenced while NULL.
Change condition to make clear a NULL pointer is not used.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 src/vdagent/x11.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/vdagent/x11.c b/src/vdagent/x11.c
index 966ea62..6f83849 100644
--- a/src/vdagent/x11.c
+++ b/src/vdagent/x11.c
@@ -392,7 +392,7 @@ static void vdagent_x11_set_clipboard_owner(struct vdagent_x11 *x11,
                 once = 0;
             }
             vdagent_x11_send_selection_notify(x11, None, curr_sel);
-            if (curr_sel == x11->selection_req) {
+            if (prev_sel == NULL) {
                 x11->selection_req = next_sel;
                 free(x11->selection_req_data);
                 x11->selection_req_data = NULL;
@@ -400,7 +400,6 @@ static void vdagent_x11_set_clipboard_owner(struct vdagent_x11 *x11,
                 x11->selection_req_data_size = 0;
                 x11->selection_req_atom = None;
             } else {
-                // coverity[var_deref_op] if it is not the first there's a previous
                 prev_sel->next = next_sel;
             }
             free(curr_sel);
@@ -424,12 +423,11 @@ static void vdagent_x11_set_clipboard_owner(struct vdagent_x11 *x11,
             if (x11->vdagentd)
                 udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_DATA, selection,
                             VD_AGENT_CLIPBOARD_NONE, NULL, 0);
-            if (curr_conv == x11->conversion_req) {
+            if (prev_conv == NULL) {
                 x11->conversion_req = next_conv;
                 x11->clipboard_data_size = 0;
                 x11->expect_property_notify = 0;
             } else {
-                // coverity[var_deref_op] if it is not the first there's a previous
                 prev_conv->next = next_conv;
             }
             free(curr_conv);
-- 
2.20.1



More information about the Spice-devel mailing list