From: "Richard W.M. Jones" <rjones(a)redhat.com>
(cherry picked from commit 52188f1ea308225ab948141b1f23e0b47f7dcf4f)
(cherry picked from commit b36a3c3f064edfd7f5f36523d46a4bdc97fa4a38)
---
daemon/md.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/daemon/md.c b/daemon/md.c
index b302a8c..e9a3f09 100644
--- a/daemon/md.c
+++ b/daemon/md.c
@@ -202,18 +202,21 @@ do_list_md_devices (void)
}
for (size_t i = 0; i < mds.gl_pathc; i++) {
- size_t len = strlen (mds.gl_pathv[i]) - strlen (PREFIX) - strlen (SUFFIX);
+ size_t len;
+ char *dev, *n;
+
+ len = strlen (mds.gl_pathv[i]) - strlen (PREFIX) - strlen (SUFFIX);
#define DEV "/dev/md"
- char *dev = malloc (strlen(DEV) + len + 1);
+ dev = malloc (strlen (DEV) + len + 1);
if (NULL == dev) {
- reply_with_perror("malloc");
+ reply_with_perror ("malloc");
goto error;
}
- char *n = dev;
- n = mempcpy(n, DEV, strlen(DEV));
- n = mempcpy(n, &mds.gl_pathv[i][strlen(PREFIX)], len);
+ n = dev;
+ n = mempcpy (n, DEV, strlen (DEV));
+ n = mempcpy (n, &mds.gl_pathv[i][strlen(PREFIX)], len);
*n = '\0';
if (add_string_nodup (&ret, dev) == -1) goto error;
--
1.8.3.1