mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
Replace getorder() by ffsl()
This commit is contained in:
parent
cd177086ca
commit
9b72fcba03
20
nnn.c
20
nnn.c
|
@ -1609,22 +1609,6 @@ show_stats(char *fpath, char *fname, struct stat *sb)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the order of 2 for this size
|
|
||||||
* In brief - return the number of trailing zeroes
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
getorder(size_t size)
|
|
||||||
{
|
|
||||||
static int count, mask;
|
|
||||||
|
|
||||||
for (mask = 1, count = 0; count < 32; mask <<= 1, ++count)
|
|
||||||
if ((size & mask) != 0)
|
|
||||||
return count;
|
|
||||||
|
|
||||||
return 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
get_fs_free(const char *path)
|
get_fs_free(const char *path)
|
||||||
{
|
{
|
||||||
|
@ -1633,7 +1617,7 @@ get_fs_free(const char *path)
|
||||||
if (statvfs(path, &svb) == -1)
|
if (statvfs(path, &svb) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return svb.f_bavail << getorder(svb.f_frsize);
|
return svb.f_bavail << (ffsl(svb.f_frsize) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
|
@ -1644,7 +1628,7 @@ get_fs_capacity(const char *path)
|
||||||
if (statvfs(path, &svb) == -1)
|
if (statvfs(path, &svb) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return svb.f_blocks << getorder(svb.f_bsize);
|
return svb.f_blocks << (ffsl(svb.f_bsize) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in a new issue