From patchwork Tue Sep 29 17:10:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "S. Fricke" X-Patchwork-Id: 7288691 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 246D9BEEA4 for ; Tue, 29 Sep 2015 17:11:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 532E1205C7 for ; Tue, 29 Sep 2015 17:11:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73C0C20591 for ; Tue, 29 Sep 2015 17:11:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934674AbbI2RLJ (ORCPT ); Tue, 29 Sep 2015 13:11:09 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:33874 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933971AbbI2RLB (ORCPT ); Tue, 29 Sep 2015 13:11:01 -0400 Received: by wicfx3 with SMTP id fx3so160622828wic.1 for ; Tue, 29 Sep 2015 10:11:00 -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=nE8FTND7m40gnMN5VMIJYmiWt9EgCWUzS3TtSStqBNw=; b=0LVmGk7LEL719bDwNeo3ydYqTCo/p3XZtDlA38fd96C6Ws5xU6PtMcBQryHCPjnxhy TMFDSvzC7/7kblgr4q299HYtgEsu/mhnDAhgzFggSzdaH+EIlkMOA9pjpG3t4WGzujGq /0eiu3NZJwhnn/uZA/yCyO39MfvIcIBDWZYdbXW8qKglLpG8XseAEa+5dn5/MzeIZQna 2E9MD9F3OYJUs46euu+JvEzokJfGOJxjDZbmw5wcj1AMH2LHZzLCa7VBeePLq97iI9nC Zwy0MeePbSeewjZTzSbRnjH+zAxXOYBY6xxA3DxvXRD1bSSoThYUZV6SKfqbV9Y1JwDa QoQw== X-Received: by 10.180.186.195 with SMTP id fm3mr27765039wic.1.1443546660528; Tue, 29 Sep 2015 10:11:00 -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.10.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Sep 2015 10:10:59 -0700 (PDT) From: Silvio Fricke To: linux-btrfs@vger.kernel.org Cc: Silvio Fricke Subject: [PATCH 02/11] btrfs-progs: use calloc instead of malloc+memset for btrfs-list.c Date: Tue, 29 Sep 2015 19:10:37 +0200 Message-Id: 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 --- btrfs-list.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/btrfs-list.c b/btrfs-list.c index d54de61..7529e11 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -226,13 +226,12 @@ struct btrfs_list_comparer_set *btrfs_list_alloc_comparer_set(void) size = sizeof(struct btrfs_list_comparer_set) + BTRFS_LIST_NCOMPS_INCREASE * sizeof(struct btrfs_list_comparer); - set = malloc(size); + set = calloc(1, size); if (!set) { fprintf(stderr, "memory allocation failed\n"); exit(1); } - memset(set, 0, size); set->total = BTRFS_LIST_NCOMPS_INCREASE; return set; @@ -474,12 +473,11 @@ static int add_root(struct root_lookup *root_lookup, if (!ret) return 0; - ri = malloc(sizeof(*ri)); + ri = calloc(1, sizeof(*ri)); if (!ri) { printf("memory allocation failed\n"); exit(1); } - memset(ri, 0, sizeof(*ri)); ri->root_id = root_id; if (name && name_len > 0) { @@ -1208,13 +1206,12 @@ struct btrfs_list_filter_set *btrfs_list_alloc_filter_set(void) size = sizeof(struct btrfs_list_filter_set) + BTRFS_LIST_NFILTERS_INCREASE * sizeof(struct btrfs_list_filter); - set = malloc(size); + set = calloc(1, size); if (!set) { fprintf(stderr, "memory allocation failed\n"); exit(1); } - memset(set, 0, size); set->total = BTRFS_LIST_NFILTERS_INCREASE; return set;