summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-11-06 17:09:17 +0100
committerDavid Sterba <dsterba@suse.com>2015-11-13 18:24:17 +0100
commitb13197d68f659e9f52fff0506a0fd5b1e557f7d7 (patch)
tree45f2782df10019700948974dc1c1ddeaa9612fc4
parentee07dc99d19fd58f8ffba336779c282ad75597b0 (diff)
btrfs-progs: use on-stack buffer for dev_to_fsid
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--cmds-filesystem.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index c6ed388e..25317fa9 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -510,18 +510,13 @@ out:
static int dev_to_fsid(char *dev, __u8 *fsid)
{
struct btrfs_super_block *disk_super;
- char *buf;
+ char buf[BTRFS_SUPER_INFO_SIZE];
int ret;
int fd;
- buf = malloc(4096);
- if (!buf)
- return -ENOMEM;
-
fd = open(dev, O_RDONLY);
if (fd < 0) {
ret = -errno;
- free(buf);
return ret;
}
@@ -536,7 +531,6 @@ static int dev_to_fsid(char *dev, __u8 *fsid)
out:
close(fd);
- free(buf);
return ret;
}