hw/9pfs/9p-synth: Replaced qemu_mutex_lock with QEMU_LOCK_GUARD
Replaced a call to qemu_mutex_lock and its respective call to qemu_mutex_unlock and used QEMU_LOCK_GUARD macro in their place. This simplifies the code by removing the call required to unlock and also eliminates goto paths. Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com> Acked-by: Greg Kurz <groug@kaod.org> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Message-Id: <20210311031538.5325-9-ma.mandourr@gmail.com> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
This commit is contained in:
parent
2615a5e433
commit
e4fd889f51
|
@ -79,11 +79,11 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
parent = &synth_root;
|
parent = &synth_root;
|
||||||
}
|
}
|
||||||
qemu_mutex_lock(&synth_mutex);
|
QEMU_LOCK_GUARD(&synth_mutex);
|
||||||
QLIST_FOREACH(tmp, &parent->child, sibling) {
|
QLIST_FOREACH(tmp, &parent->child, sibling) {
|
||||||
if (!strcmp(tmp->name, name)) {
|
if (!strcmp(tmp->name, name)) {
|
||||||
ret = EEXIST;
|
ret = EEXIST;
|
||||||
goto err_out;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Add the name */
|
/* Add the name */
|
||||||
|
@ -94,8 +94,6 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,
|
||||||
node->attr, node->attr->inode);
|
node->attr, node->attr->inode);
|
||||||
*result = node;
|
*result = node;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
err_out:
|
|
||||||
qemu_mutex_unlock(&synth_mutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +114,11 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
|
||||||
parent = &synth_root;
|
parent = &synth_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_mutex_lock(&synth_mutex);
|
QEMU_LOCK_GUARD(&synth_mutex);
|
||||||
QLIST_FOREACH(tmp, &parent->child, sibling) {
|
QLIST_FOREACH(tmp, &parent->child, sibling) {
|
||||||
if (!strcmp(tmp->name, name)) {
|
if (!strcmp(tmp->name, name)) {
|
||||||
ret = EEXIST;
|
ret = EEXIST;
|
||||||
goto err_out;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Add file type and remove write bits */
|
/* Add file type and remove write bits */
|
||||||
|
@ -136,8 +134,6 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
|
||||||
pstrcpy(node->name, sizeof(node->name), name);
|
pstrcpy(node->name, sizeof(node->name), name);
|
||||||
QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling);
|
QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
err_out:
|
|
||||||
qemu_mutex_unlock(&synth_mutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue