[PATCH] xfsprogs: merge the duplicated condition in xfs_mkfs.c/validate_ag_geometry

Wang Sheng-Hui
2015-05-28T07:07:30Z

Some conditions are duplicated. Merge them.

Signed-off-by: Wang Sheng-Hui <shhuiw@foxmail.com>
---
mkfs/xfs_mkfs.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index e2a052d..7ec2556 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -740,22 +740,6 @@ validate_ag_geometry(
__uint64_t agsize,
__uint64_t agcount)
{
- if (agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
- fprintf(stderr,
- _("agsize (%lld blocks) too small, need at least %lld blocks\n"),
- (long long)agsize,
- (long long)XFS_AG_MIN_BLOCKS(blocklog));
- usage();
- }
-
- if (agsize > XFS_AG_MAX_BLOCKS(blocklog)) {
- fprintf(stderr,
- _("agsize (%lld blocks) too big, maximum is %lld blocks\n"),
- (long long)agsize,
- (long long)XFS_AG_MAX_BLOCKS(blocklog));
- usage();
- }
-
if (agsize > dblocks) {
fprintf(stderr,
_("agsize (%lld blocks) too big, data area is %lld blocks\n"),
@@ -765,6 +749,10 @@ validate_ag_geometry(

if (agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
fprintf(stderr,
+ _("agsize (%lld blocks) too small, need at least %lld blocks\n"),
+ (long long)agsize,
+ (long long)XFS_AG_MIN_BLOCKS(blocklog));
+ fprintf(stderr,
_("too many allocation groups for size = %lld\n"),
(long long)agsize);
fprintf(stderr, _("need at most %lld allocation groups\n"),
@@ -775,6 +763,10 @@ validate_ag_geometry(

if (agsize > XFS_AG_MAX_BLOCKS(blocklog)) {
fprintf(stderr,
+ _("agsize (%lld blocks) too big, maximum is %lld blocks\n"),
+ (long long)agsize,
+ (long long)XFS_AG_MAX_BLOCKS(blocklog));
+ fprintf(stderr,
_("too few allocation groups for size = %lld\n"), (long long)agsize);
fprintf(stderr,
_("need at least %lld allocation groups\n"),
--
1.8.3.2