Changed the allocations of some local variables to GLib's allocation
functions, such as g_try_malloc0(), and annotated those variables
as g_autofree. Subsequently, I was able to remove the calls to free().
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <
20210420154643.58439-7-ma.mandourr@gmail.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
struct lo_data *lo = lo_data(req);
struct lo_dirp *d = NULL;
struct lo_inode *dinode;
struct lo_data *lo = lo_data(req);
struct lo_dirp *d = NULL;
struct lo_inode *dinode;
+ g_autofree char *buf = NULL;
char *p;
size_t rem = size;
int err = EBADF;
char *p;
size_t rem = size;
int err = EBADF;
+ buf = g_try_malloc0(size);
if (!buf) {
goto error;
}
if (!buf) {
goto error;
}
} else {
fuse_reply_buf(req, buf, size - rem);
}
} else {
fuse_reply_buf(req, buf, size - rem);
}
}
static void lo_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
}
static void lo_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
size_t size)
{
struct lo_data *lo = lo_data(req);
size_t size)
{
struct lo_data *lo = lo_data(req);
+ g_autofree char *value = NULL;
char procname[64];
const char *name;
char *mapped_name;
char procname[64];
const char *name;
char *mapped_name;
ino, name, size);
if (size) {
ino, name, size);
if (size) {
+ value = g_try_malloc(size);
if (!value) {
goto out_err;
}
if (!value) {
goto out_err;
}
fuse_reply_xattr(req, ret);
}
out_free:
fuse_reply_xattr(req, ret);
}
out_free:
if (fd >= 0) {
close(fd);
}
if (fd >= 0) {
close(fd);
}
static void lo_listxattr(fuse_req_t req, fuse_ino_t ino, size_t size)
{
struct lo_data *lo = lo_data(req);
static void lo_listxattr(fuse_req_t req, fuse_ino_t ino, size_t size)
{
struct lo_data *lo = lo_data(req);
+ g_autofree char *value = NULL;
char procname[64];
struct lo_inode *inode;
ssize_t ret;
char procname[64];
struct lo_inode *inode;
ssize_t ret;
+ value = g_try_malloc(size);
if (!value) {
goto out_err;
}
if (!value) {
goto out_err;
}
fuse_reply_xattr(req, ret);
}
out_free:
fuse_reply_xattr(req, ret);
}
out_free:
if (fd >= 0) {
close(fd);
}
if (fd >= 0) {
close(fd);
}