RE: [PATCH] serious (?) off-by one error in 2.0.36 sound card dri

BROWN Nick (Nick.BROWN@coe.int)
Thu, 29 Apr 1999 10:16:49 +0200


>If I understand what is going on, it looks as though there is an
>off-by one error in drivers/sound/dmabuf.c that could be pretty
>serious. A patch is attached.

In a previous life I had a colleague whose first instinct when debugging C
programs was to look for any "<=" or ">=" operators. He found a lot of bugs
that way, and also wrote very reliable code by making sure that he expressed
every comparison possible in terms of "<" or ">". He would have written
that code something like:

start_addr = (unsigned long) dmap->raw_buf;
past_end_addr = start_addr + dmap->buffsize;

for (i = MAP_NR(start_addr); i < MAP_NR(past_end_addr); i++)

This kind of approach seems to work best for "zero-based" languages like C.
In Fortran (don't laugh, some of us are over 35) by contrast, .LE. and .GE.
often seem more natural than .LT. and .GT., especially when dealing with
(1-based) arrays.

Another of this guy's tricks which I've adopted and used ever since is to
put a space between a function name and the parenthesis introducing its
parameters, in the declaration only. That way you can grep *.c for "foo ("
and easily find the declaration among all the calls.

Nick Brown, Strasbourg, France (Nick(dot)Brown(at)coe(dot)int)

__________________________________________________________

email address updates : @coe.int replaces @coe.fr
for more information, http://dct.coe.int/info/emfci001.htm
__________________________________________________________

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/