From patchwork Tue Oct 23 09:11:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rock Lee X-Patchwork-Id: 1629491 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 7260DDF283 for ; Tue, 23 Oct 2012 09:12:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756886Ab2JWJMO (ORCPT ); Tue, 23 Oct 2012 05:12:14 -0400 Received: from m199-177.yeah.net ([123.58.177.199]:42850 "EHLO m199-177.yeah.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756859Ab2JWJMM (ORCPT ); Tue, 23 Oct 2012 05:12:12 -0400 Received: from mail-la0-f46.google.com (mail-la0-f46.google.com [209.85.215.46]) by m199-177.yeah.net (HMail) with ESMTPA id 0D2DB10041F for ; Tue, 23 Oct 2012 17:12:09 +0800 (CST) Received: by mail-la0-f46.google.com with SMTP id h6so2184039lag.19 for ; Tue, 23 Oct 2012 02:12:07 -0700 (PDT) Received: by 10.152.106.237 with SMTP id gx13mr10497385lab.46.1350983527366; Tue, 23 Oct 2012 02:12:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.36.73 with HTTP; Tue, 23 Oct 2012 02:11:27 -0700 (PDT) From: Rock Lee Date: Tue, 23 Oct 2012 17:11:27 +0800 Message-ID: Subject: [PATCH] [btrfs-progs] Modify parse_size to remove the strdup/free To: linux-btrfs@vger.kernel.org X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUhVTkxCQkJCQklITEtNS05PTFdZCQ4XHghZQVkoKz0kKzooKCQyNSQz Pjo*PilBS1VLQDYjJCI#KCQyNSQzPjo*PilBS1VLQCsvKSQiPigkMjUkMz46Pz4pQUtVS0A*IjU6 NjI4JDIrJDU0JDI1JDM#Oj8#KUFLVUtAMiskLzQ*OiIkODUvJEskSktLQUtVS0AyKyRKJDM0Likk ODUvJEskSktLQUtVS0AyKyROJDYyNS4vPiQ4NS8kSyRKS0FLVUtAMiskSiQ2MjUuLz4kODUvJEsk SktBS1VLQDIrJEhLJDYyNS4vPiQ4NS8kSyROS0FLVUtAKC45JD5BSlVOTkA9NSQoLjkkPjUsNCk* KCQzNzEkSktLSUtKQUtVSUNAPTUkPSk#PiQzNzEkS0xLTktPQUpVTE5ZBg++ X-HM-Sender-Digest: e1kSHx4VD1lBWUc6MS46CAw5FTo1IkoPTSssOhwPDkgKCixVSlVKSE5LQkNITklCTU5MVTMWGhIX VQESFhIXFDsYFB8eVg8JEhgQVRgUFkVZV1kMHhlZQR0aFwgeBg++ Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Since the function atoi(l) series stop at the first non numeric chars, So there's no need to strdup the original s and modify s[len-1] = '\0' Signed-off-by: Rock Lee --- mkfs.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/mkfs.c b/mkfs.c index 47f0c9c..663d73c 100644 --- a/mkfs.c +++ b/mkfs.c @@ -61,8 +61,6 @@ static u64 parse_size(char *s) u64 mult = 1; u64 ret; - s = strdup(s); - if (len && !isdigit(s[len - 1])) { c = tolower(s[len - 1]); switch (c) { @@ -78,10 +76,9 @@ static u64 parse_size(char *s) fprintf(stderr, "Unknown size descriptor %c\n", c); exit(1); } - s[len - 1] = '\0'; } + ret = atol(s) * mult; - free(s); return ret; }