From patchwork Tue Sep 29 17:10:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "S. Fricke" X-Patchwork-Id: 7288721 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 30435BEEA4 for ; Tue, 29 Sep 2015 17:11:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4545220680 for ; Tue, 29 Sep 2015 17:11:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6CA3C20676 for ; Tue, 29 Sep 2015 17:11:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935090AbbI2RLT (ORCPT ); Tue, 29 Sep 2015 13:11:19 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:38041 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934406AbbI2RLG (ORCPT ); Tue, 29 Sep 2015 13:11:06 -0400 Received: by wiclk2 with SMTP id lk2so25983384wic.1 for ; Tue, 29 Sep 2015 10:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=65SHkWf4UrT8xtiy8penqq+IqKAI8QuwrNzelW4xMf8=; b=SAqr4wclhPF1K9Ef4wIyabs8swpmeNsxOsmLBLBkcdMSFixQjuobpjsf26cA07vBax vaoS8+tZtCTcI53lVo3Ey4bZFqhgVW3RaKJYa11ldaKKIX66xHVh4nIWNJiliRdNZ72n ajIwOY+TnHjzKvdOA9LtmaV92PLkTUxILu3o2o8x6tY05N34HB2RyV2mx5wWauIqrvih 37t3hvAJmWfItvERvoHWhNMEaVCMAZQK48dGFGX49BbdRBNcUgL/XIwGEWJD/4uMZA/g xEC4E4CengMVfyEAs7AUw4/7AcP+8bN5OnIIEKnmjkdaOB7KYbChHTbh4zORe/UzZlLc hMPA== X-Received: by 10.180.76.177 with SMTP id l17mr26806586wiw.16.1443546664969; Tue, 29 Sep 2015 10:11:04 -0700 (PDT) Received: from zwielicht.lan (ip5f5ba60a.dynamic.kabel-deutschland.de. [95.91.166.10]) by smtp.gmail.com with ESMTPSA id xt1sm24898618wjb.32.2015.09.29.10.11.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Sep 2015 10:11:03 -0700 (PDT) From: Silvio Fricke To: linux-btrfs@vger.kernel.org Cc: Silvio Fricke Subject: [PATCH 05/11] btrfs-progs: use calloc instead of malloc+memset for disk-io.c Date: Tue, 29 Sep 2015 19:10:40 +0200 Message-Id: <19237d46fea5d75d61062b1911544ed431f3daff.1443546001.git.silvio.fricke@gmail.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: References: 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 This patch is generated from a coccinelle semantic patch: identifier t; expression e; statement s; @@ -t = malloc(e); +t = calloc(1, e); ( if (!t) s | if (t == NULL) s | ) -memset(t, 0, e); Signed-off-by: Silvio Fricke --- disk-io.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/disk-io.c b/disk-io.c index 2469a84..f7e6c41 100644 --- a/disk-io.c +++ b/disk-io.c @@ -698,10 +698,9 @@ struct btrfs_root *btrfs_read_fs_root_no_cache(struct btrfs_fs_info *fs_info, u32 blocksize; int ret = 0; - root = malloc(sizeof(*root)); + root = calloc(1, sizeof(*root)); if (!root) return ERR_PTR(-ENOMEM); - memset(root, 0, sizeof(*root)); if (location->offset == (u64)-1) { ret = find_and_setup_root(tree_root, fs_info, location->objectid, root); @@ -829,12 +828,10 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr) { struct btrfs_fs_info *fs_info; - fs_info = malloc(sizeof(struct btrfs_fs_info)); + fs_info = calloc(1, sizeof(struct btrfs_fs_info)); if (!fs_info) return NULL; - memset(fs_info, 0, sizeof(struct btrfs_fs_info)); - 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));