From patchwork Sat Oct 10 14:30:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 7366671 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D3E1CBEEA4 for ; Sat, 10 Oct 2015 14:32:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4FEF120857 for ; Sat, 10 Oct 2015 14:32:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5FD63208DC for ; Sat, 10 Oct 2015 14:32:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751795AbbJJOb0 (ORCPT ); Sat, 10 Oct 2015 10:31:26 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:24819 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751270AbbJJObZ (ORCPT ); Sat, 10 Oct 2015 10:31:25 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t9AEVMXW030268 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 10 Oct 2015 14:31:22 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t9AEVMPN016115 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 10 Oct 2015 14:31:22 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t9AEVL2H007528; Sat, 10 Oct 2015 14:31:22 GMT Received: from localhost.localdomain (/42.60.253.93) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 10 Oct 2015 07:31:21 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH RESEND V2 1/3] btrfs-progs: Create is_numerical() helper function Date: Sat, 10 Oct 2015 22:30:56 +0800 Message-Id: <1444487458-2988-2-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1444487458-2988-1-git-send-email-anand.jain@oracle.com> References: <1444487458-2988-1-git-send-email-anand.jain@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is done by moving existing is_numerical() to utils-lib.c Signed-off-by: Anand Jain --- V2: Subject updated from btrfs-progs: move is_numerical to utils-lib.h and make it non static cmds-replace.c | 11 ----------- utils-lib.c | 11 +++++++++++ utils.h | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cmds-replace.c b/cmds-replace.c index 9ab8438..86162b6 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) { diff --git a/utils-lib.c b/utils-lib.c index 79ef35e..9ac0b7b 100644 --- a/utils-lib.c +++ b/utils-lib.c @@ -38,3 +38,14 @@ u64 arg_strtou64(const char *str) } return value; } + +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; +} diff --git a/utils.h b/utils.h index 192f3d1..0a2130d 100644 --- a/utils.h +++ b/utils.h @@ -269,5 +269,6 @@ 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 is_numerical(const char *str); #endif