9pfs: code cleanup

* Use lock-guard design pattern instead of manual lock/unlock.
 -----BEGIN PGP SIGNATURE-----
 
 iQJLBAABCgA1FiEEltjREM96+AhPiFkBNMK1h2Wkc5UFAmBQjSUXHHFlbXVfb3Nz
 QGNydWRlYnl0ZS5jb20ACgkQNMK1h2Wkc5WhWA/+N0Y8kXCjqhBqREORpQz896xj
 2NDoQBDZd/Lojqdaw3EXPYX1c7fJmT76WaMcSoyDJOVvvWgdPM/3O00JKqw0p/tC
 InmnbFybogWIy5APZW6dED5P7IMhbrnBiYIbt7x99QiZFdnhunq3gYi3YX77zKPu
 yVXxQuwYNMpq5Q9MhIZOLz8VVcmKacp84nKfDbfkkWaWqeDjMFdd8jz7IzyzjPl6
 relNgvc9nH4xUKofhfovVu+rxuLCZmdeAzCRCk9Lid6Ajp/rhhTaN9qm3LTzhnU9
 lCESR3ft2UgyJlzjOdv1rNRJplOo5V+t5x2Cd5kT4JlpBOHz8+vLFBZtHjYxc8CB
 2kFADANPeuRag/QjAMdOOlq6XDsCwTBZZEGtaNOpndL5zLnAVuUFO3EXLMuCezII
 laPtkgu+ZUMK9x6/097QgPhsKuTpmjrKXRyv3iuaVrXvlfF+uFr09q1rMB1sp5uC
 gCTCNJ2iqpN9zoeUwEnHUr/O4QdTZQCgJO/3UkYEkQaDwB0q/offW8k9G9KJXF3B
 9fluC1YpEasV1GQcyOWCP5NUBCvWx5KqT9h7W4YphnUnzSxyPsMA6tBQmEZYFQN9
 4ImLb6D1o0Q2W8PS6QnV8If52fTPebTQ2p4JFxVpd7XzPaADaqSyozBCnMwQYJf4
 t+VN5UtGsO4f7rZZd3o=
 =wOjr
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cschoenebeck/tags/pull-9p-20210316' into staging

9pfs: code cleanup

* Use lock-guard design pattern instead of manual lock/unlock.

# gpg: Signature made Tue 16 Mar 2021 10:49:09 GMT
# gpg:                using RSA key 96D8D110CF7AF8084F88590134C2B58765A47395
# gpg:                issuer "qemu_oss@crudebyte.com"
# gpg: Good signature from "Christian Schoenebeck <qemu_oss@crudebyte.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: ECAB 1A45 4014 1413 BA38  4926 30DB 47C3 A012 D5F4
#      Subkey fingerprint: 96D8 D110 CF7A F808 4F88  5901 34C2 B587 65A4 7395

* remotes/cschoenebeck/tags/pull-9p-20210316:
  hw/9pfs/9p-synth: Replaced qemu_mutex_lock with QEMU_LOCK_GUARD

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2021-03-17 18:28:03 +00:00
commit 69259911f9

View File

@ -79,11 +79,11 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,
if (!parent) {
parent = &synth_root;
}
qemu_mutex_lock(&synth_mutex);
QEMU_LOCK_GUARD(&synth_mutex);
QLIST_FOREACH(tmp, &parent->child, sibling) {
if (!strcmp(tmp->name, name)) {
ret = EEXIST;
goto err_out;
return ret;
}
}
/* Add the name */
@ -94,8 +94,6 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,
node->attr, node->attr->inode);
*result = node;
ret = 0;
err_out:
qemu_mutex_unlock(&synth_mutex);
return ret;
}
@ -116,11 +114,11 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
parent = &synth_root;
}
qemu_mutex_lock(&synth_mutex);
QEMU_LOCK_GUARD(&synth_mutex);
QLIST_FOREACH(tmp, &parent->child, sibling) {
if (!strcmp(tmp->name, name)) {
ret = EEXIST;
goto err_out;
return ret;
}
}
/* 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);
QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling);
ret = 0;
err_out:
qemu_mutex_unlock(&synth_mutex);
return ret;
}