[LTP] [PATCH 04/19] Unify error handling in lib/safe_file_ops.c

Martin Doucha mdoucha@suse.cz
Thu Oct 29 17:05:34 CET 2020


On 29. 10. 20 17:02, Cyril Hrubis wrote:
> Hi!
>>> diff --git a/lib/safe_file_ops.c b/lib/safe_file_ops.c
>>> index e06d399fa..a63368875 100644
>>> --- a/lib/safe_file_ops.c
>>> +++ b/lib/safe_file_ops.c
>>> @@ -84,9 +84,8 @@ int file_scanf(const char *file, const int lineno,
>>>  	f = fopen(path, "r");
>>>  
>>>  	if (f == NULL) {
>>> -		tst_resm(TWARN,
>>> -			"Failed to open FILE '%s' at %s:%d",
>>> -			 path, file, lineno);
>>> +		tst_resm_(file, lineno, TWARN, "Failed to open FILE '%s'",
>>> +			path);
>>>  		return 1;
>>
>> scanf() returns negative value on error, I guess it would make more
>> sense to return -1 here and in many cases below.
> 
> That's true for printf() scanf returns EOF instead. But I guess that
> anything < 0 would work better than 1 which means that one input item
> was matched successfuly...

These safe file functions could use some additional improvements but
changing the return value is out of scope of my patchset. That would
probably require reviewing and modifying some test code as well. The
patchset is over 4000 lines long as is.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


More information about the ltp mailing list