summaryrefslogtreecommitdiff
path: root/ext2fs
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-10-01 21:53:38 +0000
committerRoland McGrath <roland@gnu.org>1999-10-01 21:53:38 +0000
commit93028dc75b5c91d6d7194b0ee6479fd1b090cf6a (patch)
tree8c229d6edad0afecde657e0a1458783545c05325 /ext2fs
parenta994827b8de4e85f62fa85518bab59569213182a (diff)
1999-10-01 Roland McGrath <roland@baalperazim.frob.com>
* bitmap.c (memscan): Function removed. * ext2fs.h: Removed its decl. * balloc.c (memscan): New static function, defined using memchr.
Diffstat (limited to 'ext2fs')
-rw-r--r--ext2fs/balloc.c10
-rw-r--r--ext2fs/bitmap.c25
-rw-r--r--ext2fs/ext2fs.h4
3 files changed, 15 insertions, 24 deletions
diff --git a/ext2fs/balloc.c b/ext2fs/balloc.c
index 8cdfb79c..661894f6 100644
--- a/ext2fs/balloc.c
+++ b/ext2fs/balloc.c
@@ -43,6 +43,16 @@
#include <string.h>
#include "ext2fs.h"
+
+/* Returns a pointer to the first occurence of CH in the buffer BUF of len
+ LEN, or BUF + LEN if CH doesn't occur. */
+static inline void *
+memscan (void *buf, unsigned char ch, size_t len)
+{
+ return memchr (buf, ch, len) ?: buf + len;
+}
+
+
#define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
void
diff --git a/ext2fs/bitmap.c b/ext2fs/bitmap.c
index a983cab9..b6c91127 100644
--- a/ext2fs/bitmap.c
+++ b/ext2fs/bitmap.c
@@ -1,6 +1,6 @@
/* Bitmap perusing routines
- Copyright (C) 1995 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1999 Free Software Foundation, Inc.
Converted to work under the hurd by Miles Bader <miles@gnu.ai.mit.edu>
@@ -33,8 +33,8 @@ unsigned long count_free (char * map, unsigned int numchars)
{
unsigned int i;
unsigned long sum = 0;
-
- if (!map)
+
+ if (!map)
return (0);
for (i = 0; i < numchars; i++)
sum += nibblemap[map[i] & 0xf] +
@@ -89,7 +89,7 @@ find_next_zero_bit(void *addr, unsigned long size, unsigned long offset)
return size;
size -= result;
offset &= 31UL;
- if (offset)
+ if (offset)
{
tmp = *(p++);
tmp |= ~0UL >> (32-offset);
@@ -100,7 +100,7 @@ find_next_zero_bit(void *addr, unsigned long size, unsigned long offset)
size -= 32;
result += 32;
}
- while (size & ~31UL)
+ while (size & ~31UL)
{
if (~(tmp = *(p++)))
goto found_middle;
@@ -126,18 +126,3 @@ find_first_zero_bit(void *buf, unsigned len)
{
return find_next_zero_bit(buf, len, 0);
}
-
-/* ---------------------------------------------------------------- */
-
-/* Returns a pointer to the first occurence of CH in the buffer BUF of len
- LEN, or BUF + LEN if CH doesn't occur. */
-void *memscan(void *buf, unsigned char ch, unsigned len)
-{
- unsigned char *p = (unsigned char *)buf;
- while (len-- > 0)
- if (*p == ch)
- break;
- else
- p++;
- return (void *)p;
-}
diff --git a/ext2fs/ext2fs.h b/ext2fs/ext2fs.h
index 2066cd28..9a36e99c 100644
--- a/ext2fs/ext2fs.h
+++ b/ext2fs/ext2fs.h
@@ -156,10 +156,6 @@ extern int find_first_zero_bit(void * addr, unsigned size);
extern int find_next_zero_bit (void * addr, int size, int offset);
extern unsigned long ffz(unsigned long word);
-
-/* Returns a pointer to the first occurence of CH in the buffer BUF of len
- LEN, or BUF + LEN if CH doesn't occur. */
-void *memscan(void *buf, unsigned char ch, unsigned len);
/* ---------------------------------------------------------------- */