[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] vl.c: Fix Coverity complaining for vmstate_dump
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] vl.c: Fix Coverity complaining for vmstate_dump_file |
Date: |
Wed, 29 Oct 2014 14:05:16 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
On 10/29/2014 01:49 PM, address@hidden wrote:
> From: Gonglei <address@hidden>
>
> commit abfd9ce3(migration: dump vmstate info as a json
> file for static analysis) introduce a new command,
> '-dump-vmstate', that takes a filename
> as an argument. When executed, QEMU will dump the vmstate information
> for the machine type it's invoked with to the file, and quit.
>
> Apparently, it supports one '-dump-vmstate' option,
> otherwise, the vmstate_dump_file will be overwritten.
>
> Of course, the resource will be freed when Qemu quit, but The code logic
> is not good, it will make Coverity complaining.
>
> Signed-off-by: Gonglei <address@hidden>
> ---
> vl.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/vl.c b/vl.c
> index f6b3546..5ef3af9 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3746,6 +3746,11 @@ int main(int argc, char **argv, char **envp)
> configure_msg(opts);
> break;
> case QEMU_OPTION_dump_vmstate:
> + if (vmstate_dump_file) {
> + fprintf(stderr, "qemu: only one '-dump-vmstate' "
> + "option may be given\n");
> + exit(1);
> + }
> vmstate_dump_file = fopen(optarg, "w");
> if (vmstate_dump_file == NULL) {
> fprintf(stderr, "open %s: %s\n", optarg,
> strerror(errno));
>
Applied, thanks.
Paolo