diff options
author | David Sterba <dsterba@suse.cz> | 2015-06-11 00:51:15 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-06-11 00:51:15 +0200 |
commit | 4ceffd0927360c83bec94606112b4e59cb7d2d73 (patch) | |
tree | e68e184aeca6626d4e1ed78c6ba79e1fb33a0956 | |
parent | c848046eb984fcbeeb78d681bf483aefbb35a013 (diff) |
btrfs-progs: print error within test_num_disk_vs_raid
The error string buffer passed as an argument is of a fixed size, though
we could print up to PATH_MAX + something bytes. Print the error message
directly.
Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r-- | mkfs.c | 7 | ||||
-rw-r--r-- | utils.c | 19 | ||||
-rw-r--r-- | utils.h | 2 |
3 files changed, 12 insertions, 16 deletions
@@ -1195,7 +1195,6 @@ int main(int ac, char **av) u64 source_dir_size = 0; int dev_cnt = 0; int saved_optind; - char estr[100]; char fs_uuid[BTRFS_UUID_UNPARSED_SIZE] = { 0 }; u64 features = BTRFS_MKFS_DEFAULT_FEATURES; struct mkfs_allocation allocation = { 0 }; @@ -1424,11 +1423,9 @@ int main(int ac, char **av) } } ret = test_num_disk_vs_raid(metadata_profile, data_profile, - dev_cnt, mixed, estr); - if (ret) { - fprintf(stderr, "Error: %s\n", estr); + dev_cnt, mixed); + if (ret) exit(1); - } /* if we are here that means all devs are good to btrfsify */ if (verbose) { @@ -2329,9 +2329,8 @@ static int group_profile_devs_min(u64 flag) } int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, - u64 dev_cnt, int mixed, char *estr) + u64 dev_cnt, int mixed) { - size_t sz = 100; u64 allowed = 0; switch (dev_cnt) { @@ -2350,21 +2349,21 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, if (dev_cnt > 1 && ((metadata_profile | data_profile) & BTRFS_BLOCK_GROUP_DUP)) { - snprintf(estr, sz, - "DUP is not allowed when FS has multiple devices\n"); + fprintf(stderr, + "ERROR: DUP is not allowed when FS has multiple devices\n"); return 1; } if (metadata_profile & ~allowed) { - snprintf(estr, sz, - "unable to create FS with metadata profile %s " + fprintf(stderr, + "ERROR: unable to create FS with metadata profile %s " "(have %llu devices but %d devices are required)\n", btrfs_group_profile_str(metadata_profile), dev_cnt, group_profile_devs_min(metadata_profile)); return 1; } if (data_profile & ~allowed) { - snprintf(estr, sz, - "unable to create FS with data profile %s " + fprintf(stderr, + "ERROR: unable to create FS with data profile %s " "(have %llu devices but %d devices are required)\n", btrfs_group_profile_str(data_profile), dev_cnt, group_profile_devs_min(data_profile)); @@ -2372,8 +2371,8 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, } if (!mixed && (data_profile & BTRFS_BLOCK_GROUP_DUP)) { - snprintf(estr, sz, - "dup for data is allowed only in mixed mode"); + fprintf(stderr, + "ERROR: DUP for data is allowed only in mixed mode"); return 1; } return 0; @@ -159,7 +159,7 @@ u64 btrfs_device_size(int fd, struct stat *st); int test_dev_for_mkfs(char *file, int force_overwrite); int get_label_mounted(const char *mount_path, char *labelp); int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, - u64 dev_cnt, int mixed, char *estr); + u64 dev_cnt, int mixed); int group_profile_max_safe_loss(u64 flags); int is_vol_small(char *file); int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, |