svn commit: r303146 - head/usr.bin/sed

Bruce Evans brde at optusnet.com.au
Fri Jul 22 07:45:59 UTC 2016


On Fri, 22 Jul 2016, Alexey Dokuchaev wrote:

>> Log:
>>   sed(1): Appease older GCC.

"Appease" actually seems to be the correct wording here since gcc's detection
of a variable that might be used unitialized seems to report one that is
not used uninitialized.

> Isn't it also being dictated by style(9) and common sense? :)

You missed that this combines a style fix in previous gcc appeasement
(or just excessive paranoia) in one variable with appeasement for
another variable, since copying the previous appeasement would copy
its style bug.  The 2 variables are used in exactly the same limited
way.

>> Modified:
>>   head/usr.bin/sed/process.c
>>
>> @@ -97,11 +97,12 @@ process(void)
>>  {
>>  	struct s_command *cp;
>>  	SPACE tspace;
>> -	size_t oldpsl = 0;
>> +	size_t oldpsl;
>>  	char *p;
>>  	int oldpsanl;
>>
>>  	p = NULL;
>> +	oldpsanl = oldpsl = 0;

Multiple assignments on a single line is not very good style and is probably
not KNF.  Here it is further from being good style since the variables
have different types.  Since both types are integral and the value is 0
the implicit type conversions don't change the value.  However, compilers
should warn about down-converting a size_t to an int unless they do the
analysis that this is safe because the value in the size_t is known to
fit in the int.

Bruce



More information about the svn-src-all mailing list