From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>,
Jeff Cody <jcody@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 2/4] block/gluster: drop intermediate ListElement struct
Date: Fri, 27 Jan 2017 10:00:27 +0000 [thread overview]
Message-ID: <20170127100029.11356-3-stefanha@redhat.com> (raw)
In-Reply-To: <20170127100029.11356-1-stefanha@redhat.com>
The "qemu/queue.h" data structures are used without intermediate list
node structs. They are designed to be embedded in the main struct.
Drop the unnecessary ListElement struct.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/gluster.c | 39 +++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/block/gluster.c b/block/gluster.c
index 516a1e1..171a323 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -56,19 +56,14 @@ typedef struct BDRVGlusterReopenState {
struct glfs_fd *fd;
} BDRVGlusterReopenState;
-
typedef struct GlfsPreopened {
char *volume;
glfs_t *fs;
int ref;
+ QLIST_ENTRY(GlfsPreopened) list;
} GlfsPreopened;
-typedef struct ListElement {
- QLIST_ENTRY(ListElement) list;
- GlfsPreopened saved;
-} ListElement;
-
-static QLIST_HEAD(glfs_list, ListElement) glfs_list;
+static QLIST_HEAD(glfs_list, GlfsPreopened) glfs_list;
static QemuOptsList qemu_gluster_create_opts = {
.name = "qemu-gluster-create-opts",
@@ -210,26 +205,26 @@ static QemuOptsList runtime_tcp_opts = {
static void glfs_set_preopened(const char *volume, glfs_t *fs)
{
- ListElement *entry = NULL;
+ GlfsPreopened *entry = NULL;
- entry = g_new(ListElement, 1);
+ entry = g_new(GlfsPreopened, 1);
- entry->saved.volume = g_strdup(volume);
+ entry->volume = g_strdup(volume);
- entry->saved.fs = fs;
- entry->saved.ref = 1;
+ entry->fs = fs;
+ entry->ref = 1;
QLIST_INSERT_HEAD(&glfs_list, entry, list);
}
static glfs_t *glfs_find_preopened(const char *volume)
{
- ListElement *entry = NULL;
+ GlfsPreopened *entry = NULL;
QLIST_FOREACH(entry, &glfs_list, list) {
- if (strcmp(entry->saved.volume, volume) == 0) {
- entry->saved.ref++;
- return entry->saved.fs;
+ if (strcmp(entry->volume, volume) == 0) {
+ entry->ref++;
+ return entry->fs;
}
}
@@ -238,23 +233,23 @@ static glfs_t *glfs_find_preopened(const char *volume)
static void glfs_clear_preopened(glfs_t *fs)
{
- ListElement *entry = NULL;
- ListElement *next;
+ GlfsPreopened *entry = NULL;
+ GlfsPreopened *next;
if (fs == NULL) {
return;
}
QLIST_FOREACH_SAFE(entry, &glfs_list, list, next) {
- if (entry->saved.fs == fs) {
- if (--entry->saved.ref) {
+ if (entry->fs == fs) {
+ if (--entry->ref) {
return;
}
QLIST_REMOVE(entry, list);
- glfs_fini(entry->saved.fs);
- g_free(entry->saved.volume);
+ glfs_fini(entry->fs);
+ g_free(entry->volume);
g_free(entry);
}
}
--
2.9.3
next prev parent reply other threads:[~2017-01-27 10:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-27 10:00 [Qemu-devel] [PATCH 0/4] block/gluster: cleanups for GlfsPreopened Stefan Hajnoczi
2017-01-27 10:00 ` [Qemu-devel] [PATCH 1/4] block/gluster: fix wrong indent in glfs_find_preopened() Stefan Hajnoczi
2017-01-27 10:00 ` Stefan Hajnoczi [this message]
2017-01-27 10:00 ` [Qemu-devel] [PATCH 3/4] block/gluster: use conventional names for GlfsPreopened functions Stefan Hajnoczi
2017-01-27 10:00 ` [Qemu-devel] [PATCH 4/4] block/gluster: add missing QLIST_HEAD_INITIALIZER() Stefan Hajnoczi
2017-01-27 14:23 ` [Qemu-devel] [PATCH 0/4] block/gluster: cleanups for GlfsPreopened Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170127100029.11356-3-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=jcody@redhat.com \
--cc=prasanna.kalever@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).