summaryrefslogtreecommitdiff
path: root/sys/src/9/port/fault.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-08-06 10:15:07 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-08-06 10:15:07 +0200
commit86eb8ea6bbbf031d71cf0fa58f468cd3ddc4e7f3 (patch)
treed1bce67f94620239e83258e7cc040b13702aac77 /sys/src/9/port/fault.c
parent8d196aeec728fea0450c0b42db114127e85d64e0 (diff)
kernel: change vmemchr() length argument to ulong and simplify
Diffstat (limited to 'sys/src/9/port/fault.c')
-rw-r--r--sys/src/9/port/fault.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/src/9/port/fault.c b/sys/src/9/port/fault.c
index 6565c670a..00c905b8c 100644
--- a/sys/src/9/port/fault.c
+++ b/sys/src/9/port/fault.c
@@ -332,18 +332,20 @@ validaddr(uintptr addr, ulong len, int write)
* &s[0] is known to be a valid address.
*/
void*
-vmemchr(void *s, int c, int n)
+vmemchr(void *s, int c, ulong n)
{
- int m;
uintptr a;
+ ulong m;
void *t;
a = (uintptr)s;
- while(PGROUND(a) != PGROUND(a+n-1)){
- /* spans pages; handle this page */
+ for(;;){
m = BY2PG - (a & (BY2PG-1));
+ if(n <= m)
+ break;
+ /* spans pages; handle this page */
t = memchr((void*)a, c, m);
- if(t)
+ if(t != nil)
return t;
a += m;
n -= m;