Re: [PATCH] Re: Linux 2.2.14pre16

Ingo Oeser (ingo.oeser@informatik.tu-chemnitz.de)
Wed, 22 Dec 1999 14:46:29 +0100 (CET)


On Tue, 21 Dec 1999, TenThumbs wrote:

> Since comparing unsigned quantites against zero doesn't work, I propose the
> attached patches against 2.2.14pre16. They seem to be harmless for me.

> --- linux.14p16/mm/memory.c.pre16 Tue Dec 21 08:00:18 1999
> +++ linux.14p16/mm/memory.c Tue Dec 21 09:30:37 1999
> @@ -392,7 +392,7 @@
> */
> if (mm->rss > 0) {

> mm->rss -= freed;
> - if (mm->rss < 0)
> + if ((long)mm->rss < 0)
> mm->rss = 0;
Just remove this check, because it is uncessary, or try this one
instead

if (freed < mm->rss)
mm->rss-=freed
else
mm->rss=0;

Which would be the correct (saturation) behavior for this
substraction.

PS: We do _NOT_ have to check "freed < 0", because that can't
happen according to the code path. I wonder why the
zap*-functions return "int" instead of "unsigned int"
anyway. Error conditions in future releases?

> }
> }
> --- linux.14p16/mm/slab.c.pre16 Tue Dec 21 09:30:55 1999
> +++ linux.14p16/mm/slab.c Tue Dec 21 09:31:17 1999
> @@ -714,7 +714,7 @@
> goto opps;
> }
>
> - if (offset < 0 || offset > size) {
> + if ((long)offset < 0 || offset > size) {

Unnecessary. The below line would be sufficient, because there is
no underflow in unsigned values, that is below 0 but is often
above the maximum value set (size in this case).

+ if (offset > size) {

That's why I prefer to use unsigned values whereever I can BTW,
because I can omit one bound check ;)

> printk("%sOffset weird %d - %s\n", func_nm, (int) offset, name);
> offset = 0;
> }

Regards

Ingo Oeser

-- 
Feel the power of the penguin - run linux@your.pc
<esc>:x

- 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/