2004-10-26 06:32:53

by Werner Almesberger

[permalink] [raw]
Subject: [PATCH] make buffer head argument of buffer_##name "const"

This one is embarrassingly simple. Unfortunately, it doesn't meet
the requirements for the patch monkey, so here goes a "regular"
submission.

I've checked that the argument of test_bit is indeed "const" on
all architectures. The patch is for 2.6.9.

- Werner

---------------------------------- cut here -----------------------------------

Signed-off-by: Werner Almesberger <[email protected]>

--- linux-2.6.9/include/linux/buffer_head.h.orig Tue Oct 26 02:57:54 2004
+++ linux-2.6.9/include/linux/buffer_head.h Tue Oct 26 02:21:04 2004
@@ -76,7 +76,7 @@
{ \
clear_bit(BH_##bit, &(bh)->b_state); \
} \
-static inline int buffer_##name(struct buffer_head *bh) \
+static inline int buffer_##name(const struct buffer_head *bh) \
{ \
return test_bit(BH_##bit, &(bh)->b_state); \
}

--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina [email protected] /
/_http://www.almesberger.net/____________________________________________/


2004-10-26 07:25:44

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] make buffer head argument of buffer_##name "const"

Werner Almesberger <[email protected]> wrote:
>
> --- linux-2.6.9/include/linux/buffer_head.h.orig Tue Oct 26 02:57:54 2004
> +++ linux-2.6.9/include/linux/buffer_head.h Tue Oct 26 02:21:04 2004
> @@ -76,7 +76,7 @@
> { \
> clear_bit(BH_##bit, &(bh)->b_state); \
> } \
> -static inline int buffer_##name(struct buffer_head *bh) \
> +static inline int buffer_##name(const struct buffer_head *bh) \
> { \
> return test_bit(BH_##bit, &(bh)->b_state); \
> }

OK, but why? Does it generate better code or something?

2004-10-26 07:40:06

by Werner Almesberger

[permalink] [raw]
Subject: Re: [PATCH] make buffer head argument of buffer_##name "const"

Andrew Morton wrote:
> OK, but why? Does it generate better code or something?

I wouldn't expect this to change the resulting code. It's just
so that one can feed it a "const" pointer, which allows other
functions to use "const", etc.

- Werner

--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina [email protected] /
/_http://www.almesberger.net/____________________________________________/