[dm-devel] [PATCH] multipathd: fix issue in 'map $map getprstatus' reply

peng.liang5 at zte.com.cn peng.liang5 at zte.com.cn
Wed Oct 12 03:03:46 UTC 2016


Please have a review for this patch, hope for your comments.

Thanks


发件人:         peng.liang5 at zte.com.cn
收件人:         christophe varoqui <christophe.varoqui at free.fr>, 
抄送:   zhang.kai16 at zte.com.cn, dm-devel at redhat.com, peng liang 
<peng.liang5 at zte.com.cn>
日期:   2016-08-04 15:31
主题:   [dm-devel] [PATCH] multipathd: fix issue in 'map $map getprstatus' 
reply
发件人: dm-devel-bounces at redhat.com



From: peng liang <peng.liang5 at zte.com.cn>

-add missing newline to 'map|multipath $map getprstatus' reply
-use asprintf instead of sprintf

Signed-off-by: peng liang <peng.liang5 at zte.com.cn>
---
 multipathd/cli_handlers.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 8ff4362..16445ea 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -1,6 +1,9 @@
 /*
  * Copyright (c) 2005 Christophe Varoqui
  */
+#define _GNU_SOURCE
+
+#include <stdio.h>
 #include "checkers.h"
 #include "memory.h"
 #include "vector.h"
@@ -1285,14 +1288,9 @@ cli_getprstatus (void * v, char ** reply, int * 
len, void * data)
 
                 condlog(3, "%s: prflag = %u", param, (unsigned 
int)mpp->prflag);
 
-                *reply =(char *)malloc(2);
-                *len = 2;
-                memset(*reply,0,2);
-
-
-                sprintf(*reply,"%d",mpp->prflag);
-                (*reply)[1]='\0';
-
+                *len = asprintf(reply, "%d\n", mpp->prflag);
+                if (*len < 0)
+                                return 1;
 
                 condlog(3, "%s: reply = %s", param, *reply);
 
-- 
2.8.1.windows.1

--
dm-devel mailing list
dm-devel at redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20161012/5d11dae5/attachment.htm>


More information about the dm-devel mailing list