[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/58] qtail: clean up direct access to tqe_prev fiel
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 01/58] qtail: clean up direct access to tqe_prev field |
Date: |
Tue, 13 Sep 2016 19:15:32 +0200 |
From: Igor Mammedov <address@hidden>
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 <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
blockdev.c | 2 +-
exec.c | 3 +--
include/qemu/queue.h | 2 ++
net/filter.c | 2 +-
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 97062e3..c3b0593 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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 80398b0..ce3fb9e 100644
--- 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();
diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index c2b6c81..342073f 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -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))
diff --git a/net/filter.c b/net/filter.c
index 888fe6d..1dfd2ca 100644
--- a/net/filter.c
+++ b/net/filter.c
@@ -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);
--
1.8.3.1
- [Qemu-devel] [PULL 00/58] First round of misc patches for QEMU 2.8, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 01/58] qtail: clean up direct access to tqe_prev field,
Paolo Bonzini <=
- [Qemu-devel] [PULL 04/58] tcg: Pass last_tb by value to tb_find_fast(), Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 03/58] util: fix some coding style issue, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 05/58] tcg: Prepare safe tb_jmp_cache lookup out of tb_lock, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 08/58] tcg: set up tb->page_addr before insertion, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 02/58] util/qemu-sockets: revert Yoda Conditions to normal, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 07/58] tcg: Prepare TB invalidation for lockless TB lookup, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 11/58] tcg: Merge tb_find_slow() and tb_find_fast(), Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 09/58] tcg: cpu-exec: remove tb_lock from the hot-path, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 12/58] tcg: rename tb_find_physical(), Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 06/58] tcg: Prepare safe access to tb_flushed out of tb_lock, Paolo Bonzini, 2016/09/13