From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751476AbbLULC3 (ORCPT ); Mon, 21 Dec 2015 06:02:29 -0500 Received: from mga14.intel.com ([192.55.52.115]:57778 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751409AbbLULC2 (ORCPT ); Mon, 21 Dec 2015 06:02:28 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,459,1444719600"; d="scan'208";a="878141654" Date: Mon, 21 Dec 2015 19:01:22 +0800 From: kbuild test robot To: Mike Marshall Cc: kbuild-all@01.org, Martin Brandenburg , Yi Liu , linux-kernel@vger.kernel.org Subject: [PATCH] Orangefs: fix kzalloc-simple.cocci warnings Message-ID: <20151221110122.GA47014@athens> References: <201512211910.teuN6utM%fengguang.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201512211910.teuN6utM%fengguang.wu@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: fengguang.wu@intel.com X-SA-Exim-Scanned: No (on bee); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fs/orangefs/orangefs-debugfs.c:368:7-14: WARNING: kzalloc should be used for buf, instead of kmalloc/memset Use kzalloc rather than kmalloc followed by memset with 0 This considers some simple cases that are common and easy to validate Note in particular that there are no ...s in the rule, so all of the matched code has to be contiguous Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci Signed-off-by: Fengguang Wu --- orangefs-debugfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/fs/orangefs/orangefs-debugfs.c +++ b/fs/orangefs/orangefs-debugfs.c @@ -365,10 +365,9 @@ static ssize_t orangefs_debug_write(stru count = ORANGEFS_MAX_DEBUG_STRING_LEN + 1; } - buf = kmalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); + buf = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); if (!buf) goto out; - memset(buf, 0, ORANGEFS_MAX_DEBUG_STRING_LEN); if (copy_from_user(buf, ubuf, count - 1)) { gossip_debug(GOSSIP_DEBUGFS_DEBUG,