From patchwork Tue Sep 1 19:22:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 7106541 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 4D412BEEC1 for ; Tue, 1 Sep 2015 19:23:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 46F1F2058A for ; Tue, 1 Sep 2015 19:23:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 562F020551 for ; Tue, 1 Sep 2015 19:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753457AbbIATWz (ORCPT ); Tue, 1 Sep 2015 15:22:55 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:35173 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751924AbbIATWy (ORCPT ); Tue, 1 Sep 2015 15:22:54 -0400 Received: by pacfv12 with SMTP id fv12so5088147pac.2 for ; Tue, 01 Sep 2015 12:22:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aXPFRAUk2GQIC6uX12Q11bbhbUqzFBGS5hvTquuRMuA=; b=hLaSn3J5vnvp3esEnPFLsuXp3St+urpKuz83lv8SgksTkMtJhVXsh+XkwOduYiZ9jt Rw8e7gxpD6LSyQvcAHW8R83jwoAlLXgdBxu8a/WFTF3mcbh6Q8dNRrm2nG+XvxBUfXc4 fP1ZhowDF3+Uk/yphwu1rTF1kG4YyPU0LIwEvCuH2NoZDUpQ3d+7m6i25yIQW5Ot1Z0z A3ur1zo//qMfeUw5ngKMmSk9Ou57SSzEVUNL0hnE8U9nNi8wpOFM1crwaLQs6h7zf2Mi HkraAbS2kEVg5IZXwTHOObTDOz31Sfo40PeDtmThFnkAIsd8sMd4nlYVXgKivIAB6EL0 QW9Q== X-Gm-Message-State: ALoCoQmtR3xWg9Eeh6p8V54RcQ815mRUlKts5Qi3vzI2ptjc7/UjkuS5CmrqpmzCwz15ue+x6Pv4 X-Received: by 10.66.131.81 with SMTP id ok17mr48187498pab.150.1441135373954; Tue, 01 Sep 2015 12:22:53 -0700 (PDT) Received: from huxley.thefacebook.com ([199.201.64.129]) by smtp.gmail.com with ESMTPSA id b9sm10684395pdl.47.2015.09.01.12.22.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Sep 2015 12:22:53 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: Omar Sandoval Subject: [PATCH 1/3] btrfs-progs: use calloc instead of malloc+memset for tree roots Date: Tue, 1 Sep 2015 12:22:44 -0700 Message-Id: X-Mailer: git-send-email 2.5.1 In-Reply-To: References: 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=ham 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 From: Omar Sandoval Signed-off-by: Omar Sandoval --- disk-io.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/disk-io.c b/disk-io.c index 1d4889322411..8496aded31c4 100644 --- a/disk-io.c +++ b/disk-io.c @@ -833,13 +833,13 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr) memset(fs_info, 0, sizeof(struct btrfs_fs_info)); - fs_info->tree_root = malloc(sizeof(struct btrfs_root)); - fs_info->extent_root = malloc(sizeof(struct btrfs_root)); - fs_info->chunk_root = malloc(sizeof(struct btrfs_root)); - fs_info->dev_root = malloc(sizeof(struct btrfs_root)); - fs_info->csum_root = malloc(sizeof(struct btrfs_root)); - fs_info->quota_root = malloc(sizeof(struct btrfs_root)); - fs_info->super_copy = malloc(BTRFS_SUPER_INFO_SIZE); + fs_info->tree_root = calloc(1, sizeof(struct btrfs_root)); + fs_info->extent_root = calloc(1, sizeof(struct btrfs_root)); + fs_info->chunk_root = calloc(1, sizeof(struct btrfs_root)); + fs_info->dev_root = calloc(1, sizeof(struct btrfs_root)); + fs_info->csum_root = calloc(1, sizeof(struct btrfs_root)); + fs_info->quota_root = calloc(1, sizeof(struct btrfs_root)); + fs_info->super_copy = calloc(1, BTRFS_SUPER_INFO_SIZE); if (!fs_info->tree_root || !fs_info->extent_root || !fs_info->chunk_root || !fs_info->dev_root || @@ -847,14 +847,6 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr) !fs_info->super_copy) goto free_all; - memset(fs_info->super_copy, 0, BTRFS_SUPER_INFO_SIZE); - memset(fs_info->tree_root, 0, sizeof(struct btrfs_root)); - memset(fs_info->extent_root, 0, sizeof(struct btrfs_root)); - memset(fs_info->chunk_root, 0, sizeof(struct btrfs_root)); - memset(fs_info->dev_root, 0, sizeof(struct btrfs_root)); - memset(fs_info->csum_root, 0, sizeof(struct btrfs_root)); - memset(fs_info->quota_root, 0, sizeof(struct btrfs_root)); - extent_io_tree_init(&fs_info->extent_cache); extent_io_tree_init(&fs_info->free_space_cache); extent_io_tree_init(&fs_info->block_group_cache);