diff options
author | Anand Jain <anand.jain@oracle.com> | 2015-10-10 22:30:56 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-11-02 09:35:03 +0100 |
commit | 3b879467b11ee727bba93969868beeefa72a097d (patch) | |
tree | 72e1412b66bdc24d013fa8fe84bb3bcb29c5a406 | |
parent | 8a9c9adbe5a96ceb34989e77ef407d48f488ccd0 (diff) |
btrfs-progs: move is_numerical() helper to utils and rename
Signed-off-by: Anand Jain <anand.jain@oracle.com>
[ moved to util.c and renamed ]
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | cmds-replace.c | 13 | ||||
-rw-r--r-- | utils.c | 11 | ||||
-rw-r--r-- | utils.h | 1 |
3 files changed, 13 insertions, 12 deletions
diff --git a/cmds-replace.c b/cmds-replace.c index 9596f2ab..375a4608 100644 --- a/cmds-replace.c +++ b/cmds-replace.c @@ -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; @@ -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; +} @@ -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, ...) { |