From: Li Qiang <liq3ea@gmail.com>
To: peter.maydell@linaro.org, marcandre.lureau@redhat.com,
pbonzini@redhat.com
Cc: qemu-devel@nongnu.org, Li Qiang <liq3ea@gmail.com>
Subject: [Qemu-devel] [PATCH] util: check the return value of fcntl in qemu_set_{block, noblock}
Date: Wed, 12 Dec 2018 18:09:37 -0800 [thread overview]
Message-ID: <1544666977-4816-1-git-send-email-liq3ea@gmail.com> (raw)
Assert that the return value is not an error. This is like commit
7e6478e7d4f for qemu_set_cloexec.
Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
util/oslib-posix.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index c1bee2a581..4ce1ba9ca4 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -233,14 +233,18 @@ void qemu_set_block(int fd)
{
int f;
f = fcntl(fd, F_GETFL);
- fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
+ assert(f != -1);
+ f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
+ assert(f != -1);
}
void qemu_set_nonblock(int fd)
{
int f;
f = fcntl(fd, F_GETFL);
- fcntl(fd, F_SETFL, f | O_NONBLOCK);
+ assert(f != -1);
+ f = fcntl(fd, F_SETFL, f | O_NONBLOCK);
+ assert(f != -1);
}
int socket_set_fast_reuse(int fd)
--
2.11.0
next reply other threads:[~2018-12-13 2:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-13 2:09 Li Qiang [this message]
2018-12-13 6:57 ` [Qemu-devel] [PATCH] util: check the return value of fcntl in qemu_set_{block, noblock} no-reply
2018-12-13 9:31 ` Peter Maydell
2018-12-13 9:56 ` Li Qiang
2018-12-13 10:17 ` Daniel P. Berrangé
2018-12-13 10:38 ` Li Qiang
2018-12-13 10:19 ` Daniel P. Berrangé
2018-12-13 11:27 ` Peter Maydell
2018-12-13 12:28 ` Markus Armbruster
2018-12-13 12:39 ` Daniel P. Berrangé
2018-12-13 12:54 ` Peter Maydell
2018-12-13 14:40 ` Markus Armbruster
2018-12-13 14:43 ` 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=1544666977-4816-1-git-send-email-liq3ea@gmail.com \
--to=liq3ea@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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).