[PATCH] Orangefs: fix kzalloc-simple.cocci warnings

kbuild test robot
2015-12-21T11:02:29Z

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 <fengguang.wu@intel.com>
---

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,