On 12/15/2016 02:29 PM, Paolo Bonzini wrote:
>
> On 15/12/2016 12:34, Vlad Lungu wrote:
>>
>> On 12/15/2016 12:56 PM, Paolo Bonzini wrote:
>>> On 15/12/2016 11:03, Vlad Lungu wrote:
>>>>
>>>> if (initrd_filename) {
>>>> - char *next_initrd, not_last;
>>>> + char *next_initrd, not_last, tmpbuf[strlen(initrd_filename) + 1];
>>>>
>>>> mbs.offset_mods = mbs.mb_buf_size;
>>>>
>>>> @@ -299,22 +299,24 @@ int load_multiboot(FWCfgState *fw_cfg,
>>>> next_initrd = (char *)get_opt_value(NULL, 0, initrd_filename);
>>>> not_last = *next_initrd;
>>>> *next_initrd = '\0';
>>>> + /* Unescape the filename + eventual arguments */
>>>> + get_opt_value(tmpbuf, strlen(initrd_filename) + 1,
>>>> initrd_filename);
>>> No need to call get_opt_value twice; you can call it once since you have
>>> declared tmpbuf to hold the entire size of initrd_filename.
>> So what you're saying is to go with
>>
>> next_initrd = (char *)get_opt_value(tmpbuf, sizeof(tmpbuf),
>> initrd_filename);
>>
>> and delete the second call to get_opt_value().
>>
>> Is that right?
> Yes, thanks!
>
I'll delete
*next_initrd = '\0';
too, since we're operating on tmpbuf after get_opt_value(), and it's already
NUL-terminated.
Regards,
Vlad