Re: [PATCH v2 rebased 3/3] kvm tools: Allow piping debug output to file descriptor

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

 



On Sun, Oct 16, 2011 at 10:57 PM, Sasha Levin <levinsasha928@xxxxxxxxx> 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux