File 0058-config-Use-xcalloc-rather-than-xmalloc-memset.patch of Package mdadm.7129

From 6a674388f856068babaf2b9152571c56005e5cb4 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Date: Thu, 11 Aug 2016 15:32:34 -0400
Subject: [PATCH 286/359] config: Use xcalloc() rather than xmalloc()+memset()
References: bsc#1081910

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Coly Li <colyli@suse.de>

---
 config.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/config.c b/config.c
index b308b6c..563e24c 100644
--- a/config.c
+++ b/config.c
@@ -144,8 +144,7 @@ struct mddev_dev *load_partitions(void)
 		name = map_dev(major, minor, 1);
 		if (!name)
 			continue;
-		d = xmalloc(sizeof(*d));
-		memset(d, 0, sizeof(*d));
+		d = xcalloc(1, sizeof(*d));
 		d->devname = xstrdup(name);
 		d->next = rv;
 		rv = d;
@@ -169,8 +168,7 @@ struct mddev_dev *load_containers(void)
 		if (ent->metadata_version &&
 		    strncmp(ent->metadata_version, "external:", 9) == 0 &&
 		    !is_subarray(&ent->metadata_version[9])) {
-			d = xmalloc(sizeof(*d));
-			memset(d, 0, sizeof(*d));
+			d = xcalloc(1, sizeof(*d));
 			me = map_by_devnm(&map, ent->devnm);
 			if (me)
 				d->devname = xstrdup(me->path);
@@ -971,8 +969,8 @@ struct mddev_dev *conf_get_devs()
 	}
 	if (flags & GLOB_APPEND) {
 		for (i=0; i<globbuf.gl_pathc; i++) {
-			struct mddev_dev *t = xmalloc(sizeof(*t));
-			memset(t, 0, sizeof(*t));
+			struct mddev_dev *t;
+			t = xcalloc(1, sizeof(*t));
 			t->devname = xstrdup(globbuf.gl_pathv[i]);
 			t->next = dlist;
 			dlist = t;
-- 
2.16.1

openSUSE Build Service is sponsored by