make buffer head argument of buffer_##name "const"
PATCH 1/1 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 -----------------------------------
include/linux/buffer_head.h renamed from include/linux/buffer_head.h.orig +1 -1
@@ -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); \ }
Signature · 3 lines
_________________________________________________________________________ / Werner Almesberger, Buenos Aires, Argentina [email protected] / /_http://www.almesberger.net/____________________________________________/
Quoted 12 lines · Werner Almesberger
--- 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.hTue Oct 26 02:21:04 2004
@@ -76,7 +76,7 @@
{ \
clear_bit(BH_##bit, &(bh)->b_state); \
} \
-static inline int buffer_##name(structbuffer_head*bh) \
+static inline int buffer_##name(const structbuffer_head*bh) \
{ \
returntest_bit(BH_##bit, &(bh)->b_state); \
}
OK, but why? Does it generate better code or something?
Quoted 1 line · Andrew Morton
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
Signature · 3 lines
_________________________________________________________________________ / Werner Almesberger, Buenos Aires, Argentina [email protected] / /_http://www.almesberger.net/____________________________________________/