[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6] qemu-io: add pattern file for write command
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH v6] qemu-io: add pattern file for write command |
Date: |
Thu, 11 Jul 2019 15:07:46 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 27.06.19 17:26, Denis Plotnikov wrote:
>
>
> On 19.06.2019 13:09, Vladimir Sementsov-Ogievskiy wrote:
>> 10.06.2019 16:21, Denis Plotnikov wrote:
>>> The patch allows to provide a pattern file for write
>>> command. There was no similar ability before.
>>>
>>> Signed-off-by: Denis Plotnikov <address@hidden>
>>> ---
>>> v6:
>>> * the pattern file is read once to reduce io
>>>
>>> v5:
>>> * file name initiated with null to make compilers happy
>>>
>>> v4:
>>> * missing signed-off clause added
>>>
>>> v3:
>>> * missing file closing added
>>> * exclusive flags processing changed
>>> * buffer void* converted to char* to fix pointer arithmetics
>>> * file reading error processing added
>>> ---
>>> qemu-io-cmds.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++----
>>> 1 file changed, 82 insertions(+), 6 deletions(-)
[...]
>>> + if (l < len) {
>>> + char *file_buf = g_malloc(sizeof(char) * l);
Note that sizeof(char) is guaranteed to be 1.
(C1x standard, 6.5.3.4, paragraph 4.)
>>> + memcpy(file_buf, buf, l);
>>
>> I see no reason to copy it, you can just use buf_origin pointer
>> instead.
> I use buf_origin to save the beginning pointer to return it from the
> function avoiding later calculation of the beginning address since
> pointer of the buf is changed in the loop.
The point is that you don’t need file_buf. You can drop it, replace all
occurrences of file_buf by buf_origin, and probably use memmove instead
of memcpy.
Max
signature.asc
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [PATCH v6] qemu-io: add pattern file for write command,
Max Reitz <=