staging: unisys: kmalloc/memset to kzalloc conversation
authorSilvio F <silvio.fricke@gmail.com>
Tue, 18 Mar 2014 21:13:10 +0000 (22:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Mar 2014 23:22:27 +0000 (16:22 -0700)
This patch solves the Coccinelle warning: "kzalloc should be used
instead of kmalloc/memset"

This patch is a fixup for

linux-next: 97a84f1203786985856a0d4b49b1d7cc387238ce
"Staging: unisys: Replace kmalloc/memset with kzalloc"

The ALLOC_CMDRSP #define is after transformation to kzalloc only a
rename for kzalloc and was completly removed.

Signed-off-by: Silvio F <silvio.fricke@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/include/uisutils.h
drivers/staging/unisys/virthba/virthba.c
drivers/staging/unisys/virtpci/virtpci.c
drivers/staging/unisys/visorutil/memregion_direct.c
drivers/staging/unisys/visorutil/periodic_work.c

index 81b5d9baea5c5df3732fb997860bbf2c3d22407f..effd8935e81b1d87bcd5e077c196c80e4c1f2d23 100644 (file)
@@ -189,13 +189,6 @@ struct chaninfo {
        schedule_timeout((x)*HZ); \
 }
 
-#define ALLOC_CMDRSP(cmdrsp) { \
-       cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); \
-       if (cmdrsp != NULL) { \
-               memset(cmdrsp, 0, SIZEOF_CMDRSP); \
-       } \
-}
-
 /* This is a hack until we fix IOVM to initialize the channel header
  * correctly at DEVICE_CREATE time, INSTEAD OF waiting until
  * DEVICE_CONFIGURE time.
index 8aefaa8d36bf17ff14da787e6673aa69aa484269..817b11dfa19c28823cd53793e93273a34cadc08b 100644 (file)
@@ -402,9 +402,8 @@ process_disk_notify(struct Scsi_Host *shost, struct uiscmdrsp *cmdrsp)
        struct diskaddremove *dar;
        unsigned long flags;
 
-       dar = kmalloc(sizeof(struct diskaddremove), GFP_ATOMIC);
+       dar = kzalloc(sizeof(struct diskaddremove), GFP_ATOMIC);
        if (dar) {
-               memset(dar, 0, sizeof(struct diskaddremove));
                dar->add = cmdrsp->disknotify.add;
                dar->shost = shost;
                dar->channel = cmdrsp->disknotify.channel;
@@ -697,7 +696,7 @@ forward_vdiskmgmt_command(VDISK_MGMT_TYPES vdiskcmdtype,
                return FAILED;
        }
 
-       ALLOC_CMDRSP(cmdrsp);
+       cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
        if (cmdrsp == NULL) {
                LOGERR("kmalloc of cmdrsp failed.\n");
                return FAILED;  /* reject */
@@ -759,7 +758,7 @@ forward_taskmgmt_command(TASK_MGMT_TYPES tasktype, struct scsi_device *scsidev)
                return FAILED;
        }
 
-       ALLOC_CMDRSP(cmdrsp);
+       cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
        if (cmdrsp == NULL) {
                LOGERR("kmalloc of cmdrsp failed.\n");
                return FAILED;  /* reject */
@@ -930,7 +929,7 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
                return SCSI_MLQUEUE_DEVICE_BUSY;
        }
 
-       ALLOC_CMDRSP(cmdrsp);
+       cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
        if (cmdrsp == NULL) {
                LOGERR("kmalloc of cmdrsp failed.\n");
                return 1;       /* reject the command */
index 1b646328839e788f68963892b36d305d576027ea..8e34650b00b5c2e9c7938e6f6343a54850a15f08 100644 (file)
@@ -254,13 +254,12 @@ static int add_vbus(struct add_vbus_guestpart *addparams)
 {
        int ret;
        struct device *vbus;
-       vbus = kmalloc(sizeof(struct device), GFP_ATOMIC);
+       vbus = kzalloc(sizeof(struct device), GFP_ATOMIC);
 
        POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        if (!vbus)
                return 0;
 
-       memset(vbus, 0, sizeof(struct device));
        dev_set_name(vbus, "vbus%d", addparams->busNo);
        vbus->release = virtpci_bus_release;
        vbus->parent = &virtpci_rootbus_device; /* root bus is parent */
index 82c651d27396407d93435d27e21ef7c9932287fa..b9b61e8a8e71972d96485a0a325f215466d8e1f6 100644 (file)
@@ -41,13 +41,12 @@ MEMREGION *
 visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes)
 {
        MEMREGION *rc = NULL;
-       MEMREGION *memregion = kmalloc(sizeof(MEMREGION),
-                                      GFP_KERNEL|__GFP_NORETRY);
+       MEMREGION *memregion = kzalloc(sizeof(MEMREGION),
+                                      GFP_KERNEL | __GFP_NORETRY);
        if (memregion == NULL) {
                ERRDRV("visor_memregion_create allocation failed");
                return NULL;
        }
-       memset(memregion, 0, sizeof(MEMREGION));
        memregion->physaddr = physaddr;
        memregion->nbytes = nbytes;
        memregion->overlapped = FALSE;
index cc1c678a3b03fd6cf07f1e171a2a66067db19b5f..fb1e894ebdc14b2b8f52d99ebacb3d6134193cbc 100644 (file)
@@ -56,13 +56,12 @@ PERIODIC_WORK *visor_periodic_work_create(ulong jiffy_interval,
                                          void *workfuncarg,
                                          const char *devnam)
 {
-       PERIODIC_WORK *periodic_work = kmalloc(sizeof(PERIODIC_WORK),
-                                              GFP_KERNEL|__GFP_NORETRY);
+       PERIODIC_WORK *periodic_work = kzalloc(sizeof(PERIODIC_WORK),
+                                              GFP_KERNEL | __GFP_NORETRY);
        if (periodic_work == NULL) {
                ERRDRV("periodic_work allocation failed ");
                return NULL;
        }
-       memset(periodic_work, '\0', sizeof(PERIODIC_WORK));
        rwlock_init(&periodic_work->lock);
        periodic_work->jiffy_interval = jiffy_interval;
        periodic_work->workqueue = workqueue;