[sheepdog] [PATCH 2/2] dog: duplicate value which is passed via command line for simplyfing cleaning

Ruoyu liangry at ucweb.com
Wed Aug 20 14:28:37 CEST 2014


Reviewed-by: Ruoyu <liangry at ucweb.com>

On 2014年08月20日 17:07, Hitoshi Mitake wrote:
> With this change, vdi_setattr() duplicates value which is passed via
> command line with xstrdup(). With this change, dog can free() the
> value unconditionally. It makes the intention of the code clear.
>
> Reported-by: Ruoyu <liangry at ucweb.com>
> Cc: Ruoyu <liangry at ucweb.com>
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
>   dog/vdi.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/dog/vdi.c b/dog/vdi.c
> index 84715b3..cd85b65 100644
> --- a/dog/vdi.c
> +++ b/dog/vdi.c
> @@ -1286,7 +1286,8 @@ static int vdi_setattr(int argc, char **argv)
>   		goto out;
>   	}
>   
> -	value = argv[optind++];
> +	value = argv[optind] ? xstrdup(argv[optind]) : NULL;
> +	optind++;
>   	if (!value && !vdi_cmd_data.delete) {
>   		value = xmalloc(SD_MAX_VDI_ATTR_VALUE_LEN);
>   





More information about the sheepdog mailing list