From a1cb52a3ebe13f8e26a48e194e595e95c677de30 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 20 May 2013 14:35:10 +0200 Subject: [PATCH] darwin: task_info() cannot fail And if it does: assert, don't return errno. It's a mach function, it doesn't set errno. --- src/unix/darwin.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/unix/darwin.c b/src/unix/darwin.c index d8e0c62f7..77e662f4e 100644 --- a/src/unix/darwin.c +++ b/src/unix/darwin.c @@ -257,19 +257,21 @@ void uv_loadavg(double avg[3]) { uv_err_t uv_resident_set_memory(size_t* rss) { - struct task_basic_info t_info; - mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT; + mach_msg_type_number_t count; + task_basic_info_data_t info; + kern_return_t err; - int r = task_info(mach_task_self(), - TASK_BASIC_INFO, - (task_info_t)&t_info, - &t_info_count); - - if (r != KERN_SUCCESS) { - return uv__new_sys_error(errno); - } - - *rss = t_info.resident_size; + count = TASK_BASIC_INFO_COUNT; + err = task_info(mach_task_self(), + TASK_BASIC_INFO, + (task_info_t) &info, + &count); + (void) &err; + /* task_info(TASK_BASIC_INFO) cannot really fail. Anything other than + * KERN_SUCCESS implies a libuv bug. + */ + assert(err == KERN_SUCCESS); + *rss = info.resident_size; return uv_ok_; }