[vd_agent_linux,5/5] x11: Change check to make code scanners not giving warning

Submitted by Frediano Ziglio on July 24, 2019, 8:21 a.m.

Details

Message ID 20190724082132.6163-6-fziglio@redhat.com
State Accepted
Headers show
Series "Minor patches for analyzers tools" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 24, 2019, 8:21 a.m.
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@redhat.com>
---
 src/vdagent/x11.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

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);