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

peng.liang5 at zte.com.cn peng.liang5 at zte.com.cn
Thu Oct 13 06:30:00 UTC 2016


Hello Bart,

Thanks for your attention. I don't think it is necessary to do that.
Whatever returning 1 or ENOMEM it will reply "fail\n" and set the 
returning to 1.

The executed code in uxsock_trigger as follows.
        if (r > 0) {
                if (r == ETIMEDOUT)
                        *reply = STRDUP("timeout\n");
                else
                        *reply = STRDUP("fail\n");
                *len = strlen(*reply) + 1;
                r = 1;
        } 




发件人:         Bart Van Assche <bart.vanassche at sandisk.com>
收件人:         <peng.liang5 at zte.com.cn>, 
<christophe.varoqui at opensvc.com>, 
抄送:   <tang.junhui at zte.com.cn>, <zhang.kai16 at zte.com.cn>, 
<dm-devel at redhat.com>
日期:   2016/10/12 22:44
主题:   Re: [dm-devel] [PATCH] multipathd: fix issue in 'map $map 
getprstatus' reply



On 10/11/16 20:03, peng.liang5 at zte.com.cn wrote:
> 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);

Hello Peng,

Sorry but returning 1 looks somewhat inconsistent to me. This function
is called indirectly by uxsock_trigger() and that function expects that
cli_getprstatus() either returns a positive error code (E...) or a
negative error code. Please change this patch such that ENOMEM is
returned instead of 1 if asprintf() fails.

Thanks,

Bart.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20161013/4c2850aa/attachment.htm>


More information about the dm-devel mailing list