On Sun, Oct 16, 2011 at 10:57 PM, Sasha Levin <[email protected]> wrote:
> @@ -47,6 +47,7 @@ void kvm_debug_help(void)
>
>  static int do_debug(const char *name, int sock)
>  {
> +       char buff[100];
>        struct debug_cmd cmd = {KVM_IPC_DEBUG, 0};
>        int r;
>
> @@ -54,6 +55,14 @@ static int do_debug(const char *name, int sock)
>        if (r < 0)
>                return r;
>
> +       do {
> +               r = read(sock, buff, 100);
> +               if (r < 0)
> +                       return 0;
> +               printf("%s", buff);
> +               memset(buff, 0, 100);
> +       } while (r > 0);

What's going on here?

  - ARRAY_SIZE is good for you. Use it.
  - You almost certainly want to use xread() for the read.
  - What is the memset() trying to do here?
  - What guarantees that 'buff' is zero terminated?
  - Shouldn't you use xwrite() to write out the data?

> +
>        return 0;
>  }
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to