From patchwork Mon Sep 14 06:08:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 7173141 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 ACCEDBEEC1 for ; Mon, 14 Sep 2015 06:08:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A44DA2068D for ; Mon, 14 Sep 2015 06:08:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C243E20665 for ; Mon, 14 Sep 2015 06:08:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751437AbbINGIa (ORCPT ); Mon, 14 Sep 2015 02:08:30 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33477 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751030AbbINGI3 (ORCPT ); Mon, 14 Sep 2015 02:08:29 -0400 Received: by pacex6 with SMTP id ex6so134429544pac.0 for ; Sun, 13 Sep 2015 23:08:29 -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=brutdzchhH1XgDpSTsyB30GHsLZ3uLOLlMrkjqSpygE=; b=nC7Noorp4pImNg7cFYNLNHWNQ9YnQe1Wh4R3Q9Khp6RTOiX7gq/qf3m3uXyJIwCYZ/ bFAGhnn9++Pjjyv0VSsel2fXox3o5RsPElfK3rsqeoFZuB6095l7T1Elqn649duvR0n0 1/lcq9rx/RirAJ1REAuXdMJ6Z9dsTrV5rGvZ7qqUl/1mnZVvxNqQqm8w1EI33ibGKztx k9dPhLwpvjo6VjYdLYehthxIjoLU9KbIUdck/8GTYoILJRcm2Q8SQmqKZl2xGh3gLIlo km0i18VNThkaT1a7HoqnygV0x8lZ0bd8jtwzWP/KFJ6Ut1PwVb7wNL94Nu4lZ4qfrrkQ yMlQ== X-Gm-Message-State: ALoCoQlMb5usnpJAY6vpsV9B3QNT9UmxKzAx3z5rv41Knwk+ZVeEM5bjY6yKkrXafu6abX4BZ3Gm X-Received: by 10.66.124.198 with SMTP id mk6mr30686300pab.114.1442210909275; Sun, 13 Sep 2015 23:08:29 -0700 (PDT) Received: from mew.localdomain (c-76-22-74-63.hsd1.wa.comcast.net. [76.22.74.63]) by smtp.gmail.com with ESMTPSA id wk6sm13760897pab.30.2015.09.13.23.08.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Sep 2015 23:08:28 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: Omar Sandoval Subject: [PATCH v3 1/3] btrfs-progs: use calloc instead of malloc+memset for tree roots Date: Sun, 13 Sep 2015 23:08:22 -0700 Message-Id: <0ed7db75e4bebd2b538d7c48c9f43c05c9b14f46.1442210847.git.osandov@osandov.com> X-Mailer: git-send-email 2.5.2 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);