Staging: unisys: Replace kmalloc/memset with kzalloc
authorAndreea-Cristina Bernat <bernat.ada@gmail.com>
Fri, 14 Mar 2014 02:20:06 +0000 (04:20 +0200)
committerPeter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Mon, 17 Mar 2014 01:20:10 +0000 (18:20 -0700)
This patch solves the Coccinelle warning: "kzalloc should be used instead of
kmalloc/memset".

Signed-off-by: Andreea-Cristina Bernat <bernat.ada@gmail.com>
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
drivers/staging/unisys/virthba/virthba.c
drivers/staging/unisys/virtpci/virtpci.c
drivers/staging/unisys/visorchipset/parser.c
drivers/staging/unisys/visorchipset/visorchipset_main.c
drivers/staging/unisys/visorutil/memregion_direct.c

index cac25325fbf0c24be0ffd76d46f72b4595770b1d..b82d0c0fd482d8ee61a5f529505d89a8f3d2ddfe 100644 (file)
@@ -1060,12 +1060,12 @@ virthba_slave_alloc(struct scsi_device *scsidev)
                    (vdisk->next->lun == scsidev->lun))
                        return 0;
        }
-       tmpvdisk = kmalloc(sizeof(struct virtdisk_info), GFP_ATOMIC);
+       tmpvdisk = kzalloc(sizeof(struct virtdisk_info), GFP_ATOMIC);
        if (!tmpvdisk) {        /* error allocating */
                LOGERR("Could not allocate memory for disk\n");
                return 0;
        }
-       memset(tmpvdisk, 0, sizeof(struct virtdisk_info));
+
        tmpvdisk->channel = scsidev->channel;
        tmpvdisk->id = scsidev->id;
        tmpvdisk->lun = scsidev->lun;
index 0c15932c2443a8284b189dc8f2f3136dacb27d66..6886293c347350e0381d5970c4663889c36bf894 100644 (file)
@@ -909,15 +909,13 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
        }
 
        /* add a Virtual Device */
-       virtpcidev = kmalloc(sizeof(struct virtpci_dev), GFP_ATOMIC);
+       virtpcidev = kzalloc(sizeof(struct virtpci_dev), GFP_ATOMIC);
        if (virtpcidev == NULL) {
                LOGERR("can't add device - malloc FALLED\n");
                POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                return 0;
        }
 
-       memset(virtpcidev, 0, sizeof(struct virtpci_dev));
-
        /* initialize stuff unique to virtpci_dev struct */
        virtpcidev->devtype = devtype;
        if (devtype == VIRTHBA_TYPE) {
index f52c407437c97d9b08524cef79f02ace3eba2ea2..de0a4c23ffafd9b636c2eb0783b645a7bdf1fd8c 100644 (file)
@@ -65,7 +65,7 @@ parser_init_guts(U64 addr, U32 bytes, BOOL isLocal,
                        *tryAgain = TRUE;
                RETPTR(NULL);
        }
-       ctx = kmalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
+       ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
        if (ctx == NULL) {
                ERRDRV("%s (%s:%d) - failed to allocate %d bytes",
                       __func__, __FILE__, __LINE__, allocbytes);
@@ -73,7 +73,7 @@ parser_init_guts(U64 addr, U32 bytes, BOOL isLocal,
                        *tryAgain = TRUE;
                RETPTR(NULL);
        }
-       memset(ctx, 0, allocbytes);
+
        ctx->allocbytes = allocbytes;
        ctx->param_bytes = bytes;
        ctx->curr = NULL;
index 400cb035a016eec765e1c985bc155780446078dd..2a9e30cdebe0465960365c075bb9beddf5a18314 100644 (file)
@@ -1081,16 +1081,15 @@ bus_create(CONTROLVM_MESSAGE *inmsg)
                                 POSTCODE_SEVERITY_ERR);
                RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE);
        }
-       pBusInfo = kmalloc(sizeof(VISORCHIPSET_BUS_INFO), GFP_KERNEL);
+       pBusInfo = kzalloc(sizeof(VISORCHIPSET_BUS_INFO), GFP_KERNEL);
        if (pBusInfo == NULL) {
-               LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kmalloc failed",
+               LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed",
                       busNo);
                POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo,
                                 POSTCODE_SEVERITY_ERR);
                RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED);
        }
 
-       memset(pBusInfo, 0, sizeof(VISORCHIPSET_BUS_INFO));
        INIT_LIST_HEAD(&pBusInfo->entry);
        pBusInfo->busNo = busNo;
        pBusInfo->devNo = cmd->createBus.deviceCount;
@@ -1231,7 +1230,7 @@ my_device_create(CONTROLVM_MESSAGE *inmsg)
                                 POSTCODE_SEVERITY_ERR);
                RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID);
        }
-       pDevInfo = kmalloc(sizeof(VISORCHIPSET_DEVICE_INFO), GFP_KERNEL);
+       pDevInfo = kzalloc(sizeof(VISORCHIPSET_DEVICE_INFO), GFP_KERNEL);
        if (pDevInfo == NULL) {
                LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed",
                     busNo, devNo);
@@ -1239,7 +1238,7 @@ my_device_create(CONTROLVM_MESSAGE *inmsg)
                                 POSTCODE_SEVERITY_ERR);
                RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED);
        }
-       memset(pDevInfo, 0, sizeof(VISORCHIPSET_DEVICE_INFO));
+
        INIT_LIST_HEAD(&pDevInfo->entry);
        pDevInfo->busNo = busNo;
        pDevInfo->devNo = devNo;
index 1c674f18ffda72b95978e3a63df56f5d4a205157..82c651d27396407d93435d27e21ef7c9932287fa 100644 (file)
@@ -85,12 +85,12 @@ visor_memregion_create_overlapped(MEMREGION *parent, ulong offset, ulong nbytes)
                       __func__, offset, nbytes);
                return NULL;
        }
-       memregion = kmalloc(sizeof(MEMREGION), GFP_KERNEL|__GFP_NORETRY);
+       memregion = kzalloc(sizeof(MEMREGION), GFP_KERNEL|__GFP_NORETRY);
        if (memregion == NULL) {
                ERRDRV("%s allocation failed", __func__);
                return NULL;
        }
-       memset(memregion, 0, sizeof(MEMREGION));
+
        memregion->physaddr = parent->physaddr + offset;
        memregion->nbytes = nbytes;
        memregion->mapped = ((u8 *) (parent->mapped)) + offset;