Date: Fri, 22 Jul 2016 09:52:04 -0500 From: Pedro Giffuni <pfg@FreeBSD.org> To: Bruce Evans <brde@optusnet.com.au>, Alexey Dokuchaev <danfe@freebsd.org> Cc: 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: <dee9732d-5cd6-6440-ad53-7fb184df7a71@FreeBSD.org> In-Reply-To: <20160722165435.C2805@besplex.bde.org> References: <201607211417.u6LEHaPR086378@repo.freebsd.org> <20160722043536.GB37437@FreeBSD.org> <20160722165435.C2805@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?dee9732d-5cd6-6440-ad53-7fb184df7a71>