* [Cluster-devel] [GFS2] Add consts to various bits of rgrp.c
@ 2008-01-29 14:32 Steven Whitehouse
2008-01-29 20:26 ` Bob Peterson
0 siblings, 1 reply; 2+ messages in thread
From: Steven Whitehouse @ 2008-01-29 14:32 UTC (permalink / raw)
To: cluster-devel.redhat.com
From 15792c4b1735f6859edb81a2038af39c298250d1 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <swhiteho@redhat.com>
Date: Tue, 29 Jan 2008 13:30:20 +0000
Subject: [PATCH] [GFS2] Add consts to various bits of rgrp.c
There are a couple of routines which scan bitmaps where we can
mark the bitmaps const, plus a couple of call sites that can
be updated too.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index da60ce8..5fd8710 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -126,23 +126,24 @@ static unsigned char gfs2_testbit(struct gfs2_rgrpd *rgd, unsigned char *buffer,
* Return: the block number (bitmap buffer scope) that was found
*/
-static u32 gfs2_bitfit(unsigned char *buffer, unsigned int buflen, u32 goal,
- unsigned char old_state)
+static u32 gfs2_bitfit(const u8 *buffer, unsigned int buflen, u32 goal,
+ u8 old_state)
{
- unsigned char *byte;
+ const u8 *byte;
u32 blk = goal;
unsigned int bit, bitlong;
- unsigned long *plong, plong55;
+ const unsigned long *plong;
+#if BITS_PER_LONG == 32
+ const unsigned long plong55 = 0x55555555;
+#else
+ const unsigned long plong55 = 0x5555555555555555;
+#endif
byte = buffer + (goal / GFS2_NBBY);
- plong = (unsigned long *)(buffer + (goal / GFS2_NBBY));
+ plong = (const unsigned long *)(buffer + (goal / GFS2_NBBY));
bit = (goal % GFS2_NBBY) * GFS2_BIT_SIZE;
bitlong = bit;
-#if BITS_PER_LONG == 32
- plong55 = 0x55555555;
-#else
- plong55 = 0x5555555555555555;
-#endif
+
while (byte < buffer + buflen) {
if (bitlong == 0 && old_state == 0 && *plong == plong55) {
@@ -179,14 +180,14 @@ static u32 gfs2_bitfit(unsigned char *buffer, unsigned int buflen, u32 goal,
* Returns: The number of bits
*/
-static u32 gfs2_bitcount(struct gfs2_rgrpd *rgd, unsigned char *buffer,
- unsigned int buflen, unsigned char state)
+static u32 gfs2_bitcount(struct gfs2_rgrpd *rgd, const u8 *buffer,
+ unsigned int buflen, u8 state)
{
- unsigned char *byte = buffer;
- unsigned char *end = buffer + buflen;
- unsigned char state1 = state << 2;
- unsigned char state2 = state << 4;
- unsigned char state3 = state << 6;
+ const u8 *byte = buffer;
+ const u8 *end = buffer + buflen;
+ const u8 state1 = state << 2;
+ const u8 state2 = state << 4;
+ const u8 state3 = state << 6;
u32 count = 0;
for (; byte < end; byte++) {
@@ -1327,12 +1328,11 @@ static u32 rgblk_search(struct gfs2_rgrpd *rgd, u32 goal,
for (x = 0; x <= length; x++) {
/* The GFS2_BLKST_UNLINKED state doesn't apply to the clone
bitmaps, so we must search the originals for that. */
+ const u8 *buffer = bi->bi_bh->b_data + bi->bi_offset;
if (old_state != GFS2_BLKST_UNLINKED && bi->bi_clone)
- blk = gfs2_bitfit(bi->bi_clone + bi->bi_offset,
- bi->bi_len, goal, old_state);
- else
- blk = gfs2_bitfit(bi->bi_bh->b_data + bi->bi_offset,
- bi->bi_len, goal, old_state);
+ buffer = bi->bi_clone + bi->bi_offset;
+
+ blk = gfs2_bitfit(buffer, bi->bi_len, goal, old_state);
if (blk != BFITNOENT)
break;
--
1.5.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Cluster-devel] [GFS2] Add consts to various bits of rgrp.c
2008-01-29 14:32 [Cluster-devel] [GFS2] Add consts to various bits of rgrp.c Steven Whitehouse
@ 2008-01-29 20:26 ` Bob Peterson
0 siblings, 0 replies; 2+ messages in thread
From: Bob Peterson @ 2008-01-29 20:26 UTC (permalink / raw)
To: cluster-devel.redhat.com
On Tue, 2008-01-29 at 14:32 +0000, Steven Whitehouse wrote:
> >From 15792c4b1735f6859edb81a2038af39c298250d1 Mon Sep 17 00:00:00 2001
> From: Steven Whitehouse <swhiteho@redhat.com>
> Date: Tue, 29 Jan 2008 13:30:20 +0000
> Subject: [PATCH] [GFS2] Add consts to various bits of rgrp.c
>
> There are a couple of routines which scan bitmaps where we can
> mark the bitmaps const, plus a couple of call sites that can
> be updated too.
>
> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
>
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
ACK fwiw
Regards,
Bob Peterson
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-01-29 20:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-29 14:32 [Cluster-devel] [GFS2] Add consts to various bits of rgrp.c Steven Whitehouse
2008-01-29 20:26 ` Bob Peterson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).