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

Re: [Xen-devel] [PATCH] xenstore-client: Add option for raw in-/output



On Sat, Jul 21, 2018 at 04:35:37PM +0200, Marek Marczykowski-Górecki wrote:
> From: Simon Gaiser <simon@xxxxxxxxxxxxxxxxxxxxxx>
> 
> Parsing/generating the escape sequences used by xenstore-client is non
> trivial. So make scripting (for use in stubdom) easier by adding a raw
> option.
> 
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> ---
>  tools/xenstore/xenstore_client.c | 51 +++++++++++++++++++++++++-------
>  1 file changed, 41 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/xenstore/xenstore_client.c 
> b/tools/xenstore/xenstore_client.c
> index 3d14d37e62..904204bc2d 100644
> --- a/tools/xenstore/xenstore_client.c
> +++ b/tools/xenstore/xenstore_client.c
> @@ -68,6 +68,18 @@ output(const char *fmt, ...) {
>      output_pos += len;
>  }
>  
> +static void
> +output_raw(const char *data, int len) {

Please put '{' on a new line.

(And output() should be fixed too, but that's another patch)

> +    if (output_pos + len > output_size) {
> +        output_size += len + 1024;
> +     output_buf = realloc(output_buf, output_size);
> +     if (output_buf == NULL)
> +         err(1, "malloc");

Indentation is wrong.

> +    }

Also, this is repetitive. Please factor out a function (expand_buffer?
ensure_buffer?) and use it in output and output_raw.

Using expanding_buffer_ensure in xs.c will probably require a bit more
refactoring than necessary, so I wouldn't ask you to do that.

The code looks fine.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.