From patchwork Fri Oct 18 04:49:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 284415 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3F6342C03EA for ; Fri, 18 Oct 2013 15:49:58 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751140Ab3JREt4 (ORCPT ); Fri, 18 Oct 2013 00:49:56 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:30531 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111Ab3JREtz (ORCPT ); Fri, 18 Oct 2013 00:49:55 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r9I4npDt005753 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Oct 2013 04:49:52 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r9I4noNn019737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Oct 2013 04:49:51 GMT Received: from abhmt101.oracle.com (abhmt101.oracle.com [141.146.116.53]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r9I4noQI002363; Fri, 18 Oct 2013 04:49:50 GMT Received: from localhost (/67.160.151.179) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 17 Oct 2013 21:49:49 -0700 Subject: [PATCH 08/25] debugfs: fix various minor bogosity To: tytso@mit.edu, darrick.wong@oracle.com From: "Darrick J. Wong" Cc: Darren Hart , linux-ext4@vger.kernel.org, Robert Yang Date: Thu, 17 Oct 2013 21:49:48 -0700 Message-ID: <20131018044948.7339.56696.stgit@birch.djwong.org> In-Reply-To: <20131018044854.7339.48457.stgit@birch.djwong.org> References: <20131018044854.7339.48457.stgit@birch.djwong.org> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org We should really use the ext2fs memory allocator functions in copy_file(), and we really should return a value if there's allocation problems. Also fix up a minor bogosity in an error message. Cc: Robert Yang Cc: Darren Hart Signed-off-by: Darrick J. Wong --- debugfs/debugfs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 4f6108d..d3db356 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -1601,9 +1601,10 @@ static errcode_t copy_file(int fd, ext2_ino_t newfile, int bufsize, int make_hol if (retval) return retval; - if (!(buf = (char *) malloc(bufsize))){ - com_err("copy_file", errno, "can't allocate buffer\n"); - return; + retval = ext2fs_get_mem(bufsize, &buf); + if (retval) { + com_err("copy_file", retval, "can't allocate buffer\n"); + return retval; } /* This is used for checking whether the whole block is zero */ @@ -1654,7 +1655,7 @@ static errcode_t copy_file(int fd, ext2_ino_t newfile, int bufsize, int make_hol return retval; fail: - free(buf); + ext2fs_free_mem(&buf); ext2fs_free_mem(&zero_buf); (void) ext2fs_file_close(e2_file); return retval; @@ -2112,7 +2113,7 @@ void do_bmap(int argc, char *argv[]) errcode = ext2fs_bmap2(current_fs, ino, 0, 0, 0, blk, 0, &pblk); if (errcode) { - com_err("argv[0]", errcode, + com_err(argv[0], errcode, "while mapping logical block %llu\n", blk); return; }