qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [PATCH] block: Don't forget to delete temporary file


From: Dunrong Huang
Subject: Re: [Qemu-trivial] [PATCH] block: Don't forget to delete temporary file
Date: Wed, 5 Sep 2012 23:51:34 +0800

Hi, thanks for you reply.
2012/9/5 Paolo Bonzini <address@hidden>:
> Il 05/09/2012 15:26, address@hidden ha scritto:
>> From: Dunrong Huang <address@hidden>
>>
>> The caller would not delete temporary file after failed get_tmp_filename().
>>
>> Signed-off-by: Dunrong Huang <address@hidden>
>> ---
>>  block.c | 6 +++++-
>>  1 个文件被修改,插入 5 行(+),删除 1 行(-)
>>
>> diff --git a/block.c b/block.c
>> index 074987e..2bc9f75 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -433,7 +433,11 @@ int get_tmp_filename(char *filename, int size)
>>          return -EOVERFLOW;
>>      }
>>      fd = mkstemp(filename);
>> -    if (fd < 0 || close(fd)) {
>> +    if (fd < 0) {
>> +        return -errno;
>> +    }
>> +    if (close(fd) != 0) {
>> +        unlink(filename);
>>          return -errno;
>>      }
>>      return 0;
>>
>
> Not necessary, mkstemp will not create a file if it returns an error.
>
If we call mkstemp() successfully, but failed to close(fd),
in this case, the temporafy file will not be deleted even if QEMU exits.
> Paolo



-- 
Best Regards,

Dunrong Huang



reply via email to

[Prev in Thread] Current Thread [Next in Thread]