[CinCV TNG] [PATCH] Fixed compiler warnings in filesystem.C

Johannes Sixt j6t at kdbg.org
Sun Jul 2 23:13:53 CEST 2017


Am 02.07.2017 um 17:40 schrieb Einar Rünkaru:
> 
> 
> On 07/02/2017 02:46 PM, Johannes Sixt wrote:
>> Am 30.06.2017 um 22:03 schrieb Einar Rünkaru:
>>> Fixed warnings about ignored return value.
>>> ---
>>>   guicast/filesystem.C | 7 +++++--
>>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/guicast/filesystem.C b/guicast/filesystem.C
>>> index be4e3d9..8d84cec 100644
>>> --- a/guicast/filesystem.C
>>> +++ b/guicast/filesystem.C
>>> @@ -101,8 +101,11 @@ int FileItem::set_name(char *name)
>>>   FileSystem::FileSystem()
>>>   {
>>>       reset_parameters();
>>> -    getcwd(current_dir, BCTEXTLEN);
>>> -
>>> +    if(!getcwd(current_dir, BCTEXTLEN))
>>> +    {
>>> +        perror("get current working directory");
>>> +        abort();
>>> +    }
>>>   }
>>>   FileSystem::~FileSystem()
>>
>> We need a different solution for this case. You can't abort here. It 
>> is well possible to remove a parent director of the current directory. 
>> Then getcwd() will fail. This would crash Cinelerra.
>>
>> Without this patch, current_dir remains unchanged when getcwd() fails. 
>> It basically leaves random stuff in current_dir. A possible solution 
>> is to set current_dir to an empty string so that there is at the least 
>> some predictable value.
> 
> getcwd fails if there is a serious error in Cinelerra or filesystem got 
> corrupted during the run of cinelerra. The safest way on both situations 
> is to quit immediately.

No, it is absolutely not a sign of corruption when getcwd() fails. Try it:

mkdir -p /tmp/temporary
cd /tmp/temporary
cinelerra &
# wait until it is up and running
cd /tmp
rmdir /tmp/temporary

Now open the Preferences dialog and watch the firework.

It is a situation that can happen to a user.

> Current_dir is used in path completition. Then files are not found or 
> saved in unexpected locations.

It is a different question how to best treat the situation. As I said, 
it is probably the safest to clear current_dir.

-- Hannes


More information about the Cinelerra mailing list