2002-01-07 08:56:03

by Adam J. Richter

[permalink] [raw]
Subject: Patch?: linux-2.5.2-pre9/drivers/block/ll_rw_blk.c blk_rq_map_sg simplification

Hello Jens,

The following patch removes gotos from blk_rq_map_sg, making
it more readable and five lines shorter. I think the compiler should
generate the same code. I have not tested this other than to
verify that it compiles.

If it works and looks good to you, I would appreciate it if
you would forward it to Linus for integration. (I am also cc'ing this to
linux-kernel in case anyone spots a mistake on my part.)

Also, if there is some other way by which you would like
me to submit future bio patches (if any), please let me know.

--
Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104
[email protected] \ / San Jose, California 95129-1034
+1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."


Attachments:
(No filename) (836.00 B)
ll.diff (870.00 B)
Download all attachments

2002-01-07 09:03:54

by Jens Axboe

[permalink] [raw]
Subject: Re: Patch?: linux-2.5.2-pre9/drivers/block/ll_rw_blk.c blk_rq_map_sg simplification

On Mon, Jan 07 2002, Adam J. Richter wrote:
> Hello Jens,
>
> The following patch removes gotos from blk_rq_map_sg, making
> it more readable and five lines shorter. I think the compiler should
> generate the same code. I have not tested this other than to
> verify that it compiles.

Well, I really think the original is much more readable than the changed
version :-)

> Also, if there is some other way by which you would like
> me to submit future bio patches (if any), please let me know.

This is quite fine.

--
Jens Axboe

2002-01-07 13:02:50

by Dave Jones

[permalink] [raw]
Subject: Re: Patch?: linux-2.5.2-pre9/drivers/block/ll_rw_blk.c blk_rq_map_sg simplification

On Mon, 7 Jan 2002, Jens Axboe wrote:

> > The following patch removes gotos from blk_rq_map_sg, making
> > it more readable and five lines shorter. I think the compiler should
> > generate the same code. I have not tested this other than to
> > verify that it compiles.
> Well, I really think the original is much more readable than the changed
> version :-)

I agree. Upon seeing the patch, I was reminded of the monster
enormous conditional at http://gcc.gnu.org/projects/beginner.html
not quite _that_ bad, but getting there 8)

--
| Dave Jones. http://www.codemonkey.org.uk
| SuSE Labs

2002-01-07 13:27:01

by Dave Jones

[permalink] [raw]
Subject: Re: Patch?: linux-2.5.2-pre9/drivers/block/ll_rw_blk.c blk_rq_map_sg simplification

On Mon, 7 Jan 2002, Adam J. Richter wrote:

> The conditional is one level deep (it's just a list of
> "and" conjunctions) and has a single conceptual meaning, "are
> the segments joinable?" For what it's worth, I really could not
> understand the old version until I rewrote it without gotos.

whitespace == a good thing.

--
| Dave Jones. http://www.codemonkey.org.uk
| SuSE Labs

2002-01-07 13:27:02

by Adam J. Richter

[permalink] [raw]
Subject: Re: Patch?: linux-2.5.2-pre9/drivers/block/ll_rw_blk.c blk_rq_map_sg simplification

>>> = Adam Richter ([email protected])
>> = Jens Axboe ([email protected])
> = Dave Jones ([email protected])
>>> The following patch removes gotos from blk_rq_map_sg, making
>>> it more readable and five lines shorter. I think the compiler should
>>> generate the same code. I have not tested this other than to
>>> verify that it compiles.
>> Well, I really think the original is much more readable than the changed
>> version :-)

>I agree. Upon seeing the patch, I was reminded of the monster
>enormous conditional at http://gcc.gnu.org/projects/beginner.html
>not quite _that_ bad, but getting there 8)

The conditional is one level deep (it's just a list of
"and" conjunctions) and has a single conceptual meaning, "are
the segments joinable?" For what it's worth, I really could not
understand the old version until I rewrote it without gotos.

Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104
[email protected] \ / San Jose, California 95129-1034
+1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."