Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Jul 2016 17:13:58 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Alexey Dokuchaev <danfe@freebsd.org>
Cc:        "Pedro F. Giffuni" <pfg@freebsd.org>, src-committers@freebsd.org,  svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r303146 - head/usr.bin/sed
Message-ID:  <20160722165435.C2805@besplex.bde.org>
In-Reply-To: <20160722043536.GB37437@FreeBSD.org>
References:  <201607211417.u6LEHaPR086378@repo.freebsd.org> <20160722043536.GB37437@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160722165435.C2805>