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