From: Pan Nengyuan <pannengyuan@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.com>, <rth@twiddle.net>,
<ehabkost@redhat.com>
Cc: qemu-trivial@nongnu.org, euler.robot@huawei.com,
qemu-devel@nongnu.org, zhang.zhanghailiang@huawei.com
Subject: Re: [PATCH] target/i386/hax-posix: fix two 'format-truncation' compile warnings
Date: Tue, 3 Mar 2020 18:58:40 +0800 [thread overview]
Message-ID: <964455ff-100e-8fdc-a775-232b9e99a8a5@huawei.com> (raw)
In-Reply-To: <a6e307a4-a66d-2297-5d62-6be910353d67@redhat.com>
On 3/3/2020 6:47 PM, Paolo Bonzini wrote:
> On 24/02/20 07:51, pannengyuan@huawei.com wrote:
>> diff --git a/target/i386/hax-posix.c b/target/i386/hax-posix.c
>> index a5426a6dac..197d5bc0f9 100644
>> --- a/target/i386/hax-posix.c
>> +++ b/target/i386/hax-posix.c
>> @@ -121,7 +121,8 @@ static char *hax_vm_devfs_string(int vm_id)
>> return NULL;
>> }
>>
>> - snprintf(name, sizeof HAX_VM_DEVFS, "/dev/hax_vm/vm%02d", vm_id);
>> + int len = snprintf(name, sizeof HAX_VM_DEVFS, "/dev/hax_vm/vm%02d", vm_id);
>> + assert(len < sizeof HAX_VM_DEVFS);
>> return name;
>> }
>>
>> @@ -140,8 +141,9 @@ static char *hax_vcpu_devfs_string(int vm_id, int vcpu_id)
>> return NULL;
>> }
>>
>> - snprintf(name, sizeof HAX_VCPU_DEVFS, "/dev/hax_vm%02d/vcpu%02d",
>> - vm_id, vcpu_id);
>> + int len = snprintf(name, sizeof HAX_VCPU_DEVFS, "/dev/hax_vm%02d/vcpu%02d",
>> + vm_id, vcpu_id);
>> + assert(len < sizeof HAX_VCPU_DEVFS);
>> return name;
>> }
>>
>>
>
> Julio Faracco has posted a fix for the same bug. The best change is
> actually to switch to g_strdup_printf.
Okay, Thanks.
>
> Paolo
>
prev parent reply other threads:[~2020-03-03 10:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 6:51 [PATCH] target/i386/hax-posix: fix two 'format-truncation' compile warnings pannengyuan
2020-03-03 10:14 ` Laurent Vivier
2020-03-03 10:47 ` Paolo Bonzini
2020-03-03 10:58 ` Pan Nengyuan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=964455ff-100e-8fdc-a775-232b9e99a8a5@huawei.com \
--to=pannengyuan@huawei.com \
--cc=ehabkost@redhat.com \
--cc=euler.robot@huawei.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=rth@twiddle.net \
--cc=zhang.zhanghailiang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).