]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qtail: clean up direct access to tqe_prev field
authorIgor Mammedov <imammedo@redhat.com>
Mon, 25 Jul 2016 12:47:12 +0000 (14:47 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 13 Sep 2016 17:08:41 +0000 (19:08 +0200)
instead of accessing tqe_prev field dircetly outside
of queue.h use macros to check if element is in list
and make sure that afer element is removed from list
tqe_prev field could be used to do the same check.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <1469450832-84343-1-git-send-email-imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
blockdev.c
exec.c
include/qemu/queue.h
net/filter.c

index 97062e33c3f7f702b851a138e80a423fed97e828..c3b05934d7d8317ea79cef9372a6d5dadd236f6f 100644 (file)
@@ -3907,7 +3907,7 @@ void qmp_x_blockdev_del(bool has_id, const char *id,
             goto out;
         }
 
-        if (!blk && !bs->monitor_list.tqe_prev) {
+        if (!blk && !QTAILQ_IN_USE(bs, monitor_list)) {
             error_setg(errp, "Node %s is not owned by the monitor",
                        bs->node_name);
             goto out;
diff --git a/exec.c b/exec.c
index 80398b038f9c71ba392a47a62f2e356857582818..ce3fb9ec8ef731a74cdf81f378110239ed51e129 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -617,7 +617,7 @@ void cpu_exec_exit(CPUState *cpu)
     CPUClass *cc = CPU_GET_CLASS(cpu);
 
     cpu_list_lock();
-    if (cpu->node.tqe_prev == NULL) {
+    if (!QTAILQ_IN_USE(cpu, node)) {
         /* there is nothing to undo since cpu_exec_init() hasn't been called */
         cpu_list_unlock();
         return;
@@ -626,7 +626,6 @@ void cpu_exec_exit(CPUState *cpu)
     assert(!(cpu_index_auto_assigned && cpu != QTAILQ_LAST(&cpus, CPUTailQ)));
 
     QTAILQ_REMOVE(&cpus, cpu, node);
-    cpu->node.tqe_prev = NULL;
     cpu->cpu_index = UNASSIGNED_CPU_INDEX;
     cpu_list_unlock();
 
index c2b6c8149ddf8e19ad573bd11b97bdf842b544d2..342073fb4d8deed1ff9505572d9a654e4a15ef14 100644 (file)
@@ -407,6 +407,7 @@ struct {                                                                \
         else                                                            \
                 (head)->tqh_last = (elm)->field.tqe_prev;               \
         *(elm)->field.tqe_prev = (elm)->field.tqe_next;                 \
+        (elm)->field.tqe_prev = NULL;                                   \
 } while (/*CONSTCOND*/0)
 
 #define QTAILQ_FOREACH(var, head, field)                                \
@@ -430,6 +431,7 @@ struct {                                                                \
 #define QTAILQ_EMPTY(head)               ((head)->tqh_first == NULL)
 #define QTAILQ_FIRST(head)               ((head)->tqh_first)
 #define QTAILQ_NEXT(elm, field)          ((elm)->field.tqe_next)
+#define QTAILQ_IN_USE(elm, field)        ((elm)->field.tqe_prev != NULL)
 
 #define QTAILQ_LAST(head, headname) \
         (*(((struct headname *)((head)->tqh_last))->tqh_last))
index 888fe6dd939a3dfeb0144bbb6ade028e3bd7953d..1dfd2caa235058b57c02e72b2fc8adbcba3f6cd3 100644 (file)
@@ -239,7 +239,7 @@ static void netfilter_finalize(Object *obj)
     }
 
     if (nf->netdev && !QTAILQ_EMPTY(&nf->netdev->filters) &&
-        nf->next.tqe_prev) {
+        QTAILQ_IN_USE(nf, next)) {
         QTAILQ_REMOVE(&nf->netdev->filters, nf, next);
     }
     g_free(nf->netdev_id);