btrfs-progs: move is_numerical() helper to utils and rename
authorAnand Jain <anand.jain@oracle.com>
Sat, 10 Oct 2015 14:30:56 +0000 (22:30 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 2 Nov 2015 08:35:03 +0000 (09:35 +0100)
Signed-off-by: Anand Jain <anand.jain@oracle.com>
[ moved to util.c and renamed ]
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-replace.c
utils.c
utils.h

index 9596f2a..375a460 100644 (file)
@@ -65,17 +65,6 @@ static const char * const replace_cmd_group_usage[] = {
        NULL
 };
 
-static int is_numerical(const char *str)
-{
-       if (!(*str >= '0' && *str <= '9'))
-               return 0;
-       while (*str >= '0' && *str <= '9')
-               str++;
-       if (*str != '\0')
-               return 0;
-       return 1;
-}
-
 static int dev_replace_cancel_fd = -1;
 static void dev_replace_sigint_handler(int signal)
 {
@@ -214,7 +203,7 @@ static int cmd_replace_start(int argc, char **argv)
                goto leave_with_error;
        }
 
-       if (is_numerical(srcdev)) {
+       if (string_is_numerical(srcdev)) {
                struct btrfs_ioctl_fs_info_args fi_args;
                struct btrfs_ioctl_dev_info_args *di_args = NULL;
 
diff --git a/utils.c b/utils.c
index 6f5df23..39ca927 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -3077,3 +3077,14 @@ unsigned int get_unit_mode_from_arg(int *argc, char *argv[], int df_mode)
 
        return unit_mode;
 }
+
+int string_is_numerical(const char *str)
+{
+       if (!(*str >= '0' && *str <= '9'))
+               return 0;
+       while (*str >= '0' && *str <= '9')
+               str++;
+       if (*str != '\0')
+               return 0;
+       return 1;
+}
diff --git a/utils.h b/utils.h
index 1dc12ec..9961ec7 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -270,6 +270,7 @@ const char *get_argv0_buf(void);
        "-t|--tbytes        show sizes in TiB, or TB with --si"
 
 unsigned int get_unit_mode_from_arg(int *argc, char *argv[], int df_mode);
+int string_is_numerical(const char *str);
 
 static inline void warning(const char *fmt, ...)
 {