[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/9] util/compatfd.c: Replaced a malloc with GLib's g_try_malloc
From: |
Mahmoud Mandour |
Subject: |
[PATCH 6/9] util/compatfd.c: Replaced a malloc with GLib's g_try_malloc |
Date: |
Sat, 13 Mar 2021 18:36:50 +0200 |
Replaced a malloc() call and its respective free() call with
GLib's g_try_malloc() and g_free(). Also, did slight styling
changes that were producing errors using the checkpatch.pl
script.
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
---
util/compatfd.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/util/compatfd.c b/util/compatfd.c
index ee47dd8089..834ddd0573 100644
--- a/util/compatfd.c
+++ b/util/compatfd.c
@@ -20,8 +20,7 @@
#include <sys/syscall.h>
#endif
-struct sigfd_compat_info
-{
+struct sigfd_compat_info {
sigset_t mask;
int fd;
};
@@ -53,8 +52,9 @@ static void *sigwait_compat(void *opaque)
len = write(info->fd, (char *)&buffer + offset,
sizeof(buffer) - offset);
- if (len == -1 && errno == EINTR)
+ if (len == -1 && errno == EINTR) {
continue;
+ }
if (len <= 0) {
return NULL;
@@ -72,14 +72,14 @@ static int qemu_signalfd_compat(const sigset_t *mask)
QemuThread thread;
int fds[2];
- info = malloc(sizeof(*info));
+ info = g_try_malloc(sizeof(*info));
if (info == NULL) {
errno = ENOMEM;
return -1;
}
if (pipe(fds) == -1) {
- free(info);
+ g_free(info);
return -1;
}
--
2.25.1
- [PATCH 0/9] Replacing malloc and the like with GLib's variants, Mahmoud Mandour, 2021/03/13
- [PATCH 1/9] bsd-user/elfload.c: Replaced calls to malloc/free with GLib variants, Mahmoud Mandour, 2021/03/13
- [PATCH 2/9] hw/audio/fmopl.c: Fixing some style errors., Mahmoud Mandour, 2021/03/13
- [PATCH 8/9] tools/virtiofsd/fuse_opt.c: Replaced a malloc with GLib's g_try_malloc, Mahmoud Mandour, 2021/03/13
- [PATCH 6/9] util/compatfd.c: Replaced a malloc with GLib's g_try_malloc,
Mahmoud Mandour <=
- [PATCH 5/9] target/xtensa: Replaced malloc/free with GLib's variants., Mahmoud Mandour, 2021/03/13
- [PATCH 3/9] hw/audio/fmopl.c: Replaced calls to malloc with GLib's variants, Mahmoud Mandour, 2021/03/13
- [PATCH 7/9] tools/virtiofsd/buffer.c: replaced a calloc call with GLib's g_try_new0, Mahmoud Mandour, 2021/03/13
- [PATCH 4/9] pc-bios/s390-ccw/netmain.c: Changed a malloc/free to GLib's variants, Mahmoud Mandour, 2021/03/13
- [PATCH 9/9] tools/virtiofsd: Replacing malloc-like calls with GLib's variants, Mahmoud Mandour, 2021/03/13
- Re: [PATCH 0/9] Replacing malloc and the like with GLib's variants, no-reply, 2021/03/13