Date: Mon, 24 Apr 2017 18:26:46 +0000 From: Brooks Davis <brooks@freebsd.org> To: Hamza Sheikh <fehrist@codeghar.com> Cc: freebsd-current@freebsd.org Subject: Re: buildworld fails with warning in usr.bin/diff/diffreg.c Message-ID: <20170424182646.GC11349@spindle.one-eyed-alien.net> In-Reply-To: <CABJ3qSNiUY7DrEcz_eN2AqHoNefHGdDe%2Bd%2BsXviNnp9kO7=Qmw@mail.gmail.com> References: <CABJ3qSNiUY7DrEcz_eN2AqHoNefHGdDe%2Bd%2BsXviNnp9kO7=Qmw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--sm4nu43k4a2Rpi4c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 24, 2017 at 10:04:15AM -0700, Hamza Sheikh wrote: > The error is: >=20 > --- all_subdir_usr.bin --- > cc1: warnings being treated as errors > /home/vagrant/src/usr.bin/diff/diffreg.c: In function 'change': > /home/vagrant/src/usr.bin/diff/diffreg.c:1085: warning: 'i' may be > used uninitialized in this function If I'm reading the code correctly, this is caused by this code at line 1217 and the analyzer being insufficiently smart (all prior uses include initialization in for() loops): if (diff_format !=3D D_GFORMAT) i =3D fetch(ixnew, c, d, f2, diff_format =3D=3D D_NORMAL ? = '>' : '\0', 0, *pflags); if (i !=3D 0 && diff_format =3D=3D D_EDIT) { Adding "i =3D 0;" above this fixes the warning for me and appears to preserve the intent. This variable should be named something other than i to avoid confusion. -- Brooks --sm4nu43k4a2Rpi4c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJY/kNlAAoJEKzQXbSebgfAuAQH/ReJ4qbcEOEUC1blHNE5iuEq fbIkfdnu+n3qHR47k6Bgm2u75FNdTNUfoQoO39wSJ3bUIIgbLCDXZFEEgEP4PQni A7dp9F5EmrbpC76h8QVR939pl7dJuIUt8Bo0DzgNppmz5xWVZ1ZcxSFNf1xKlBH3 xsc53nAbowHsgUUYAwAYQiX9Im600o5VLpqqHtYvrsUFpR6uPop5QgYKfiuma24R fDFwgntqKt0hBnXA7TqdpD2zViUnRIQLoy1ZGmV2XceqHq2ITq2piBje+w3c2pUa gMst7qKrb3gpSgOkfcRuaXBt3Yqr733+RLcCM6niAqsI52HClgDQD2I4KiYHTK4= =i0bQ -----END PGP SIGNATURE----- --sm4nu43k4a2Rpi4c--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170424182646.GC11349>