From 93028dc75b5c91d6d7194b0ee6479fd1b090cf6a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 1 Oct 1999 21:53:38 +0000 Subject: 1999-10-01 Roland McGrath * bitmap.c (memscan): Function removed. * ext2fs.h: Removed its decl. * balloc.c (memscan): New static function, defined using memchr. --- ext2fs/balloc.c | 10 ++++++++++ ext2fs/bitmap.c | 25 +++++-------------------- ext2fs/ext2fs.h | 4 ---- 3 files changed, 15 insertions(+), 24 deletions(-) (limited to 'ext2fs') 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 #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 @@ -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); /* ---------------------------------------------------------------- */ -- cgit v1.2.3