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

Einar Rünkaru einarrunkaru at gmail.com
Sun Jul 2 17:40:47 CEST 2017



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.

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

Einar


More information about the Cinelerra mailing list