Re: [PATCH] multipathd: fix issue in 'map $map getprstatus' reply

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/01/2016 06:27 PM, peng.liang5@xxxxxxxxxx wrote:
From: peng liang <peng.liang5@xxxxxxxxxx>

add missing newline to 'map|multipath $map getprstatus' reply

Signed-off-by: peng liang <peng.liang5@xxxxxxxxxx>
---
 multipathd/cli_handlers.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 8ff4362..0b04504 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -1285,13 +1285,13 @@ 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);
+	*reply =(char *)malloc(3);
+	*len = 3;
+	memset(*reply,0,3);


-	sprintf(*reply,"%d",mpp->prflag);
-	(*reply)[1]='\0';
+	sprintf(*reply,"%d\n",mpp->prflag);
+	(*reply)[2]='\0';

Hello Peng,

Please use asprintf() instead of malloc() + memset() + sprintf(). See also https://www.gnu.org/software/libc/manual/html_node/Dynamic-Output.html

Thanks,

Bart.

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



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux