From: Mahmoud Mandour <ma.mandourr@gmail.com>
To: qemu-devel@nongnu.org
Cc: Mahmoud Mandour <ma.mandourr@gmail.com>
Subject: [PATCH 2/2] util/compatfd.c: Replaced a malloc call with g_malloc.
Date: Mon, 15 Mar 2021 12:58:14 +0200 [thread overview]
Message-ID: <20210315105814.5188-3-ma.mandourr@gmail.com> (raw)
In-Reply-To: <20210315105814.5188-1-ma.mandourr@gmail.com>
Replaced a call to malloc() and its respective call to free()
with g_malloc() and g_free().
g_malloc() is preferred more than g_try_* functions, which
return NULL on error, when the size of the requested
allocation is small. This is because allocating few
bytes should not be a problem in a healthy system.
Otherwise, the system is already in a critical state.
Subsequently, removed NULL-checking after g_malloc().
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
---
util/compatfd.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/util/compatfd.c b/util/compatfd.c
index 174f394533..a8ec525c6c 100644
--- a/util/compatfd.c
+++ b/util/compatfd.c
@@ -72,14 +72,10 @@ static int qemu_signalfd_compat(const sigset_t *mask)
QemuThread thread;
int fds[2];
- info = malloc(sizeof(*info));
- if (info == NULL) {
- errno = ENOMEM;
- return -1;
- }
+ info = g_malloc(sizeof(*info));
if (pipe(fds) == -1) {
- free(info);
+ g_free(info);
return -1;
}
--
2.25.1
next prev parent reply other threads:[~2021-03-15 11:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 10:58 [PATCH 0/2] util/compatfd.c: Fixed styling and replaced malloc Mahmoud Mandour
2021-03-15 10:58 ` [PATCH 1/2] util/compatfd.c: Fixed style issues Mahmoud Mandour
2021-03-15 14:51 ` Thomas Huth
2021-03-15 10:58 ` Mahmoud Mandour [this message]
2021-03-15 11:13 ` [PATCH 2/2] util/compatfd.c: Replaced a malloc call with g_malloc Philippe Mathieu-Daudé
2021-03-15 11:30 ` Mahmoud Mandour
2021-03-15 14:25 ` Markus Armbruster
2021-03-15 14:53 ` Thomas Huth
2021-03-15 15:13 ` Philippe Mathieu-Daudé
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=20210315105814.5188-3-ma.mandourr@gmail.com \
--to=ma.mandourr@gmail.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).