[PATCH 17/19] mkfs: unit conversions are case insensitive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Solves the question "Should I use 10g or 10G?"

Signed-off-by: Jan Tulak <jtulak@xxxxxxxxxx>

---
CHANGES:
* use tolower instead of == 'p' || == 'P'
---
 mkfs/xfs_mkfs.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index a6334bc..a35c4a5 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3594,8 +3594,10 @@ cvtnum(
 {
 	long long	i;
 	char		*sp;
+	int		c;
 
 	i = strtoll(s, &sp, 0);
+	c = tolower(*sp);
 	if (i == 0 && sp == s)
 		return -1LL;
 	if (*sp == '\0')
@@ -3606,17 +3608,17 @@ cvtnum(
 	if (*sp == 's' && sp[1] == '\0')
 		return i * sectsize;
 
-	if (*sp == 'k' && sp[1] == '\0')
+	if (c == 'k' && sp[1] == '\0')
 		return 1024LL * i;
-	if (*sp == 'm' && sp[1] == '\0')
+	if (c == 'm' && sp[1] == '\0')
 		return 1024LL * 1024LL * i;
-	if (*sp == 'g' && sp[1] == '\0')
+	if (c == 'g' && sp[1] == '\0')
 		return 1024LL * 1024LL * 1024LL * i;
-	if (*sp == 't' && sp[1] == '\0')
+	if (c == 't' && sp[1] == '\0')
 		return 1024LL * 1024LL * 1024LL * 1024LL * i;
-	if (*sp == 'p' && sp[1] == '\0')
+	if (c == 'p' && sp[1] == '\0')
 		return 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * i;
-	if (*sp == 'e' && sp[1] == '\0')
+	if (c == 'e' && sp[1] == '\0')
 		return 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * i;
 	return -1LL;
 }
-- 
2.5.0

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux