[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/12] virtiofsd/fuse_virtio.c: Changed allocations of locals to G
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 12/12] virtiofsd/fuse_virtio.c: Changed allocations of locals to GLib |
Date: |
Thu, 6 May 2021 19:56:41 +0100 |
From: Mahmoud Mandour <ma.mandourr@gmail.com>
Replaced the allocation of local variables from malloc() to
GLib allocation functions.
In one instance, dropped the usage to an assert after a malloc()
call and used g_malloc() instead.
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210420154643.58439-8-ma.mandourr@gmail.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
tools/virtiofsd/fuse_virtio.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
index 828f0fa590..1170f375a5 100644
--- a/tools/virtiofsd/fuse_virtio.c
+++ b/tools/virtiofsd/fuse_virtio.c
@@ -511,8 +511,7 @@ static void fv_queue_worker(gpointer data, gpointer
user_data)
* They're spread over multiple descriptors in a scatter/gather set
* and we can't trust the guest to keep them still; so copy in/out.
*/
- fbuf.mem = malloc(se->bufsize);
- assert(fbuf.mem);
+ fbuf.mem = g_malloc(se->bufsize);
fuse_mutex_init(&req->ch.lock);
req->ch.fd = -1;
@@ -564,8 +563,8 @@ static void fv_queue_worker(gpointer data, gpointer
user_data)
memcpy(fbuf.mem, &inh, sizeof(struct fuse_in_header));
/* Allocate the bufv, with space for the rest of the iov */
- pbufv = malloc(sizeof(struct fuse_bufvec) +
- sizeof(struct fuse_buf) * out_num);
+ pbufv = g_try_malloc(sizeof(struct fuse_bufvec) +
+ sizeof(struct fuse_buf) * out_num);
if (!pbufv) {
fuse_log(FUSE_LOG_ERR, "%s: pbufv malloc failed\n",
__func__);
@@ -622,7 +621,7 @@ static void fv_queue_worker(gpointer data, gpointer
user_data)
out:
if (allocated_bufv) {
- free(pbufv);
+ g_free(pbufv);
}
/* If the request has no reply, still recycle the virtqueue element */
@@ -641,7 +640,7 @@ out:
}
pthread_mutex_destroy(&req->ch.lock);
- free(fbuf.mem);
+ g_free(fbuf.mem);
free(req);
}
--
2.31.1
- [PULL 01/12] virtiofsd: Fix side-effect in assert(), (continued)
- [PULL 01/12] virtiofsd: Fix side-effect in assert(), Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 02/12] virtiofsd: Allow use "-o xattrmap" without "-o xattr", Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 04/12] virtiofs: Fixup printf args, Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 05/12] virtiofsd: Don't assume header layout, Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 03/12] virtiofsd: Add help for -o xattr-mapping, Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 06/12] virtiofsd: Changed allocations of fuse_req to GLib functions, Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 07/12] virtiofsd: Changed allocations of iovec to GLib's functions, Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 08/12] virtiofsd: Changed allocations of fuse_session to GLib's functions, Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 11/12] virtiofsd/passthrough_ll.c: Changed local allocations to GLib functions, Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 12/12] virtiofsd/fuse_virtio.c: Changed allocations of locals to GLib,
Dr. David Alan Gilbert (git) <=
- [PULL 10/12] virtiofsd: Changed allocations of fv_VuDev & its internals to GLib functions, Dr. David Alan Gilbert (git), 2021/05/06
- [PULL 09/12] virtiofsd: Changed allocation of lo_map_elems to GLib's functions, Dr. David Alan Gilbert (git), 2021/05/06
- Re: [PULL 00/12] virtiofs queue, Peter Maydell, 2021/05/11