From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, armbru@redhat.com, philmd@linaro.org,
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Subject: [PATCH] qemu-nbd: changes towards enabling -Wshadow=local
Date: Fri, 22 Sep 2023 15:50:20 -0500 [thread overview]
Message-ID: <20230922205019.2755352-2-eblake@redhat.com> (raw)
Address all compiler complaints from -Wshadow in qemu-nbd. Several
instances of 'int ret' became shadows when commit 4fbec260 added 'ret'
at a higher scope in main. More interesting was the 'void *ret'
capturing the result of a pthread; where we were conceptually doing
'(void*)(intptr_t)EXIT_FAILURE != NULL' which just feels wrong (even
though it happens to compile correctly), so it was worth a better
cleanup.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
I'm happy to let Markus collect this with the growing pile on
shadow-next, instead of going through my NBD tree.
qemu-nbd.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 30eeb6f3c75..9bc410c6c56 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -937,7 +937,6 @@ int main(int argc, char **argv)
g_autoptr(GError) err = NULL;
int stderr_fd[2];
pid_t pid;
- int ret;
if (!g_unix_open_pipe(stderr_fd, FD_CLOEXEC, &err)) {
error_report("Error setting up communication pipe: %s",
@@ -1170,7 +1169,6 @@ int main(int argc, char **argv)
if (opts.device) {
#if HAVE_NBD_DEVICE
- int ret;
ret = pthread_create(&client_thread, NULL, nbd_client_thread, &opts);
if (ret != 0) {
error_report("Failed to create client thread: %s", strerror(ret));
@@ -1217,9 +1215,10 @@ int main(int argc, char **argv)
qemu_opts_del(sn_opts);
if (opts.device) {
- void *ret;
- pthread_join(client_thread, &ret);
- exit(ret != NULL);
+ void *result;
+ pthread_join(client_thread, &result);
+ ret = (intptr_t)result;
+ exit(ret);
} else {
exit(EXIT_SUCCESS);
}
--
2.41.0
next reply other threads:[~2023-09-22 20:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-22 20:50 Eric Blake [this message]
2023-09-25 8:53 ` [PATCH] qemu-nbd: changes towards enabling -Wshadow=local Daniel P. Berrangé
2023-09-29 6:50 ` Markus Armbruster
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=20230922205019.2755352-2-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/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).