From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pierre Habouzit Date: Tue, 05 Jun 2007 11:37:21 +0000 Subject: Re: [KJ] for loops and variable declarations... Message-Id: <20070605113721.GH10354@.intersec.eu> MIME-Version: 1 Content-Type: multipart/mixed; boundary="===============5662731947364591878==" List-Id: References: In-Reply-To: To: kernel-janitors@vger.kernel.org --===============5662731947364591878== Content-Type: multipart/signed; boundary="Fnm8lRGFTVS/3GuM"; protocol="application/pgp-signature"; micalg=SHA1 Content-Disposition: inline --Fnm8lRGFTVS/3GuM Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 05, 2007 at 06:22:40PM +0700, Kevin Jackson wrote: > Hi all, >=20 > I'm just looking at kernel code for basically the first time - so > please be patient :) >=20 > I'm seeing this style of code: >=20 > uchar a > .... > .... > .... > .... > .... > ....(many lines later...) > for(a=3D2; a< VALUE; a++) >=20 >=20 > Why are loop variables declared so far away from where they are used? because C forbigs in-code variable declarations (unlike C++). GNU C authorizes it though. > Is this advantageous in some way? It seems that the scope of the > variables is much larger than having them declared just as they are to > be used eg: >=20 > for(uchar a=3D2; a