From owner-freebsd-current@freebsd.org Mon Apr 24 18:26:48 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8EBACD4EEB6 for ; Mon, 24 Apr 2017 18:26:48 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 62004A66 for ; Mon, 24 Apr 2017 18:26:48 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id 7AEE65A9F14; Mon, 24 Apr 2017 18:26:46 +0000 (UTC) Date: Mon, 24 Apr 2017 18:26:46 +0000 From: Brooks Davis To: Hamza Sheikh 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> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sm4nu43k4a2Rpi4c" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.0 (2017-02-23) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Apr 2017 18:26:48 -0000 --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--