From: Pierre Habouzit <madcoder@debian.org>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] for loops and variable declarations...
Date: Tue, 05 Jun 2007 11:37:21 +0000 [thread overview]
Message-ID: <20070605113721.GH10354@.intersec.eu> (raw)
In-Reply-To: <ab8e556c0706050422y1cf091a8n34313317a92a5afd@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1116 bytes --]
On Tue, Jun 05, 2007 at 06:22:40PM +0700, Kevin Jackson wrote:
> Hi all,
>
> I'm just looking at kernel code for basically the first time - so
> please be patient :)
>
> I'm seeing this style of code:
>
> uchar a
> ....
> ....
> ....
> ....
> ....
> ....(many lines later...)
> for(a=2; a< VALUE; a++)
>
>
> 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:
>
> for(uchar a=2; a<VALUE; a++)
This for is only allowed in C99, and is not well defined on some
compilers where a scope is not necessarily limited to the for loop as
common sense would suppose.
So IMHO, kernel do not uses such kind of code (but I may be wrong).
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 187 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
next prev parent reply other threads:[~2007-06-05 11:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-05 11:22 [KJ] for loops and variable declarations Kevin Jackson
2007-06-05 11:37 ` Pierre Habouzit [this message]
2007-06-05 11:59 ` John Anthony Kazos Jr.
2007-06-05 12:23 ` Matthew Wilcox
2007-06-05 13:07 ` Robert P. J. Day
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070605113721.GH10354@.intersec.eu \
--to=madcoder@debian.org \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.