On 07/22/16 02:13, Bruce Evans wrote:
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.
Yes, the first one is just a style fix while I was there.
The oldpsanl bogusness was breaking the build with gcc42. gcc48+, clang
and coverity all agree it was a false positive.
It was likely a side effect of raising the WARNS level to 5.
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.
Doing the multiple assignment seemed natural and readable as both are
(perhaps equally bogus) initializations.
I did notice the different types after committing. Perhaps swapping the
assignment would have been preferable? I suspect the compiler manages to
optimize out the casting.
Pedro.
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"