2003-07-03 08:25:13

by Junio C Hamano

[permalink] [raw]
Subject: [PATCH] (trivial 2.5.74) compilation fix drivers/mtd/mtd_blkdevs.c

C does not let us declar variables in the middle of a block (yet).

--- 2.5.74/drivers/mtd/mtd_blkdevs.c 2003-07-03 01:32:27.000000000 -0700
+++ 2.5.74/drivers/mtd/mtd_blkdevs.c 2003-07-03 01:32:56.000000000 -0700
@@ -211,9 +211,10 @@
case HDIO_GETGEO:
if (tr->getgeo) {
struct hd_geometry g;
+ int ret;

memset(&g, 0, sizeof(g));
- int ret = tr->getgeo(dev, &g);
+ ret = tr->getgeo(dev, &g);
if (ret)
return ret;




2003-07-03 09:43:00

by Juan Quintela

[permalink] [raw]
Subject: Re: [PATCH] (trivial 2.5.74) compilation fix drivers/mtd/mtd_blkdevs.c

>>>>> "junkio" == junkio <[email protected]> writes:

junkio> C does not let us declar variables in the middle of a block (yet).

It depends what do you call C :)

C99 does.

Later, Juan.

--
In theory, practice and theory are the same, but in practice they
are different -- Larry McVoy

2003-07-03 09:47:04

by Russell King

[permalink] [raw]
Subject: Re: [PATCH] (trivial 2.5.74) compilation fix drivers/mtd/mtd_blkdevs.c

On Thu, Jul 03, 2003 at 11:57:22AM +0200, Juan Quintela wrote:
> >>>>> "junkio" == junkio <[email protected]> writes:
>
> junkio> C does not let us declar variables in the middle of a block (yet).
>
> It depends what do you call C :)
>
> C99 does.

Unfortunately gcc 2.95.x does not allow it, so we shouldn't be using it
in the kernel (yet).

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

2003-07-03 10:27:52

by Junio C Hamano

[permalink] [raw]
Subject: Re: [PATCH] (trivial 2.5.74) compilation fix drivers/mtd/mtd_blkdevs.c

>>>>> "JQ" == Juan Quintela <[email protected]> writes:

>>>>> "junkio" == junkio <[email protected]> writes:
junkio> C does not let us declare variables in the middle of a block (yet).

JQ> It depends what do you call C :)
JQ> C99 does.

That is an inappropriate comment in this list. As far as the
kernel code is concerned, Documentation/Changes defines what C
is :-), and it says "GCC 2.95.3 or later".

Since 2.95.3 does not support declaration-in-the-middle,
decl-in-the-middle is not a valid C (yet). On the other hand,
other C99 extentions that compiler can grok (e.g. '.FIELDNAME ='
style initializer) is now already part of valid C :-).