From patchwork Mon Aug 27 04:40:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 180119 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 8183D2C00F6 for ; Mon, 27 Aug 2012 14:40:20 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751117Ab2H0EkS (ORCPT ); Mon, 27 Aug 2012 00:40:18 -0400 Received: from mail-qc0-f174.google.com ([209.85.216.174]:62738 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750771Ab2H0EkR (ORCPT ); Mon, 27 Aug 2012 00:40:17 -0400 Received: by qcro28 with SMTP id o28so2314343qcr.19 for ; Sun, 26 Aug 2012 21:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=aNfSHGL16r2bT2aS2Ie6EJ4mlIbd0vdNpGaZVslqi+0=; b=wiNi9NoLdg23DtG4XqLCGF5GRLcZs2NVRVmMVw9Lml1xAn5mU/vCkVUORTibrqkjx5 HeVdJF+k2mkRm8sGLI34wAE9vD9yd0v+A9qn5zmFMCpb3SNvuMX/E6rZMKcmotFXF4vI h02w/+uHvHDTkIbALYlGJT+bUexgQvmlC2mKwRQIEiMLEmEWZ2G757+68EtR0Ju2YJ1a iOz6Q5TPDOGEpI2BsIm9+/KvpQeCZjA+OabxekvOxYhC1hUTDoFujEsnOIWpa1b5DpjW 4oplr91FRqAGxvot1T23DHtPQGCw46LUfmB0+QDNU3YLL6RCq5klN46hGVwuu8oQexMc ZaIA== MIME-Version: 1.0 Received: by 10.229.106.84 with SMTP id w20mr6529504qco.1.1346042416866; Sun, 26 Aug 2012 21:40:16 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Sun, 26 Aug 2012 21:40:16 -0700 (PDT) Date: Mon, 27 Aug 2012 12:40:16 +0800 Message-ID: Subject: [PATCH] ext4: use kmem_cache_zalloc instead of kmem_cache_alloc/memset From: Wei Yongjun To: tytso@mit.edu, adilger.kernel@dilger.ca Cc: yongjun_wei@trendmicro.com.cn, linux-ext4@vger.kernel.org Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Wei Yongjun Using kmem_cache_zalloc() instead of kmem_cache_alloc() and memset(). spatch with a semantic match is used to found this problem. (http://coccinelle.lip6.fr/) Signed-off-by: Wei Yongjun --- fs/ext4/mballoc.c | 3 +-- 1 file changed, 1 insertion(+), 2 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/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 8eae947..6bc21a2 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2195,12 +2195,11 @@ int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group, sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)]; i = group & (EXT4_DESC_PER_BLOCK(sb) - 1); - meta_group_info[i] = kmem_cache_alloc(cachep, GFP_KERNEL); + meta_group_info[i] = kmem_cache_zalloc(cachep, GFP_KERNEL); if (meta_group_info[i] == NULL) { ext4_msg(sb, KERN_ERR, "can't allocate buddy mem"); goto exit_group_info; } - memset(meta_group_info[i], 0, kmem_cache_size(cachep)); set_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &(meta_group_info[i]->bb_state));