浏览代码

[PATCH] sysfs: kzalloc conversion

this converts fs/sysfs to kzalloc() usage.
compile tested with make allyesconfig

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Eric Sesterhenn 19 年之前
父节点
当前提交
58d49283b8
共有 2 个文件被更改,包括 2 次插入4 次删除
  1. 1 2
      fs/sysfs/file.c
  2. 1 2
      fs/sysfs/inode.c

+ 1 - 2
fs/sysfs/file.c

@@ -301,9 +301,8 @@ static int check_perm(struct inode * inode, struct file * file)
 	/* No error? Great, allocate a buffer for the file, and store it
 	/* No error? Great, allocate a buffer for the file, and store it
 	 * it in file->private_data for easy access.
 	 * it in file->private_data for easy access.
 	 */
 	 */
-	buffer = kmalloc(sizeof(struct sysfs_buffer),GFP_KERNEL);
+	buffer = kzalloc(sizeof(struct sysfs_buffer), GFP_KERNEL);
 	if (buffer) {
 	if (buffer) {
-		memset(buffer,0,sizeof(struct sysfs_buffer));
 		init_MUTEX(&buffer->sem);
 		init_MUTEX(&buffer->sem);
 		buffer->needs_read_fill = 1;
 		buffer->needs_read_fill = 1;
 		buffer->ops = ops;
 		buffer->ops = ops;

+ 1 - 2
fs/sysfs/inode.c

@@ -54,11 +54,10 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)
 
 
 	if (!sd_iattr) {
 	if (!sd_iattr) {
 		/* setting attributes for the first time, allocate now */
 		/* setting attributes for the first time, allocate now */
-		sd_iattr = kmalloc(sizeof(struct iattr), GFP_KERNEL);
+		sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL);
 		if (!sd_iattr)
 		if (!sd_iattr)
 			return -ENOMEM;
 			return -ENOMEM;
 		/* assign default attributes */
 		/* assign default attributes */
-		memset(sd_iattr, 0, sizeof(struct iattr));
 		sd_iattr->ia_mode = sd->s_mode;
 		sd_iattr->ia_mode = sd->s_mode;
 		sd_iattr->ia_uid = 0;
 		sd_iattr->ia_uid = 0;
 		sd_iattr->ia_gid = 0;
 		sd_iattr->ia_gid = 0;