mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Silvio F <silvio.fricke@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: daeseok.youn@gmail.com, silvio.fricke@gmail.com, silvio@port1024.net
Subject: [PATCH] staging: unisys: kmalloc/memset to kzalloc conversation
Date: Tue, 18 Mar 2014 21:07:51 +0100	[thread overview]
Message-ID: <1395173271-13190-2-git-send-email-silvio.fricke@gmail.com> (raw)
In-Reply-To: <1395173271-13190-1-git-send-email-silvio.fricke@gmail.com>

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"

Signed-off-by: Silvio F <silvio.fricke@gmail.com>
---
 drivers/staging/unisys/include/uisutils.h           | 5 +----
 drivers/staging/unisys/virthba/virthba.c            | 3 +--
 drivers/staging/unisys/virtpci/virtpci.c            | 3 +--
 drivers/staging/unisys/visorutil/memregion_direct.c | 5 ++---
 drivers/staging/unisys/visorutil/periodic_work.c    | 5 ++---
 5 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h
index 81b5d9b..0dd9c80 100644
--- a/drivers/staging/unisys/include/uisutils.h
+++ b/drivers/staging/unisys/include/uisutils.h
@@ -190,10 +190,7 @@ struct chaninfo {
 }
 
 #define ALLOC_CMDRSP(cmdrsp) { \
-	cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); \
-	if (cmdrsp != NULL) { \
-		memset(cmdrsp, 0, SIZEOF_CMDRSP); \
-	} \
+	cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC); \
 }
 
 /* This is a hack until we fix IOVM to initialize the channel header
diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c
index 8aefaa8..d99a38d 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -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;
diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c
index 1b64632..8e34650 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -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 */
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 82c651d..b9b61e8 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -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;
diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c
index cc1c678..fb1e894 100644
--- a/drivers/staging/unisys/visorutil/periodic_work.c
+++ b/drivers/staging/unisys/visorutil/periodic_work.c
@@ -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;
-- 
1.9.0


  reply	other threads:[~2014-03-18 20:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-12 10:37 [PATCH] staging: unisys: use kzalloc instead of kmalloc/memset 0 Daeseok Youn
2014-03-17 21:41 ` Greg KH
2014-03-18  0:26   ` DaeSeok Youn
2014-03-18  0:37     ` Greg KH
2014-03-18  8:11       ` DaeSeok Youn
2014-03-19  0:03         ` DaeSeok Youn
2014-03-19  0:58           ` Greg KH
2014-03-19  1:04             ` DaeSeok Youn
2014-03-19  2:31               ` Greg KH
2014-03-19  4:32                 ` DaeSeok Youn
2014-03-18 13:00     ` Ken Cox
2014-03-19  0:09       ` DaeSeok Youn
2014-03-19  0:58         ` Greg KH
2014-03-18 20:07 ` [patch][wip] staging: unisys: kmalloc/memset move to kzalloc Silvio F
2014-03-18 20:07   ` Silvio F [this message]
2014-03-18 20:17     ` [PATCH] staging: unisys: kmalloc/memset to kzalloc conversation Joe Perches
2014-03-18 20:41       ` Greg KH
2014-03-18 20:41     ` Greg KH
2014-03-18 20:46       ` Silvio F.
2014-03-18 21:13 ` [patch][wip] staging: unisys: kmalloc/memset move to kzalloc Silvio F
2014-03-18 21:13   ` [PATCH] staging: unisys: kmalloc/memset to kzalloc conversation Silvio F

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395173271-13190-2-git-send-email-silvio.fricke@gmail.com \
    --to=silvio.fricke@gmail.com \
    --cc=daeseok.youn@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=silvio@port1024.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®