Use __arraycount(), and cast to u_int.

This commit is contained in:
christos 2012-11-24 07:16:04 +00:00
parent 5c26317391
commit bbd1e49222
1 changed files with 5 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: syncicache.c,v 1.1 2006/07/01 16:37:20 ross Exp $ */
/* $NetBSD: syncicache.c,v 1.2 2012/11/24 07:16:04 christos Exp $ */
/*
* Copyright (C) 1995-1997, 1999 Wolfgang Solfrank.
@ -74,17 +74,16 @@ __getcachelinesize(void)
if (_cachelinesize)
return _cachelinesize;
if (sysctl(cacheinfomib, sizeof(cacheinfomib) / sizeof(cacheinfomib[0]),
&_cache_info, &clen, NULL, 0) == 0) {
if (sysctl(cacheinfomib, (u_int)__arraycount(cacheinfomib),
&_cache_info, &clen, NULL, 0) == 0) {
_cachelinesize = _cache_info.dcache_line_size;
return _cachelinesize;
}
/* Try older deprecated sysctl */
clen = sizeof(_cachelinesize);
if (sysctl(cachemib, sizeof(cachemib) / sizeof(cachemib[0]),
&_cachelinesize, &clen, NULL, 0) < 0
|| !_cachelinesize)
if (sysctl(cachemib, (u_int)__arraycount(cachemib),
&_cachelinesize, &clen, NULL, 0) < 0 || !_cachelinesize)
abort();
_cache_info.dcache_size = _cachelinesize;