kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 886c3920dbab5af3e1d744a93b5f3dc9ffe8b874
parent 87d8fd784b078aafeb2603d51e6369e9101278ca
Author: Joris Vink <joris@coders.se>
Date:   Fri,  5 Jul 2013 22:17:56 +0200

sysconf() returns -1 on failure, cpu_count is an unsigned integer, failure would never have been caught.

from cremno via github

Diffstat:
src/linux.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/linux.c b/src/linux.c @@ -52,9 +52,13 @@ static struct epoll_event *events = NULL; void kore_platform_init(void) { - if ((cpu_count = sysconf(_SC_NPROCESSORS_ONLN)) == -1) { + long n; + + if ((n = sysconf(_SC_NPROCESSORS_ONLN)) == -1) { kore_debug("could not get number of cpu's falling back to 1"); cpu_count = 1; + } else { + cpu_count = (u_int16_t)n; } }