You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to have amount < 0 ? Based on libuv codebase (at least on LINUX), the free mem (also total mem) is taken from /proc/meminfo, based on that, is it possible to have a negative amount?
Yeap, I think it is a possible "non-positive amount", in that case, don't you think that we should provide a better error handling on the implementation? I mean, at least use CHECK_GT or something like that...
I don't know, this is just a proposal because I don't know why we are dealing with invalid amount in this way.
Activity
gireeshpunathil commentedon Apr 12, 2020
@juanarbol - may be this, for example? https://github.com/libuv/libuv/blob/2ab3dc1567d67924b634be6f478d25f4528ce574/src/unix/darwin.c#L101
juanarbol commentedon Apr 12, 2020
Yeap, I think it is a possible "non-positive amount", in that case, don't you think that we should provide a better error handling on the implementation? I mean, at least use
CHECK_GTor something like that...I don't know, this is just a proposal because I don't know why we are dealing with invalid amount in this way.
gireeshpunathil commentedon Apr 12, 2020
@juanarbol - makes sense to me! but throw an exception that carries the original
libuverror message, with a doc update, instead ofCHECK_GT?juanarbol commentedon Apr 12, 2020
Yeap, it is a better approach, I think that:
But amm... the free memory method is
voidso that won't work, and I don't know how to throw an exception with a givenFunctionCallbackInfogireeshpunathil commentedon Apr 12, 2020
here is a recent PR which did a similar thing: you need to:
src/node_errors.hhttps://github.com/nodejs/node/pull/32344/files#diff-853c968290ed44d71c73689242b1fab4R648-R661
/cc @addaleax for a better suggestion!
bnoordhuis commentedon Apr 13, 2020
No, because the return type of
uv_get_free_memory()isuint64_t, i.e, an unsigned value. Those are always>= 0.src: remove validation of unreachable code
juanarbol commentedon Apr 13, 2020
Thanks for the support! I'm closing this issue now.
src: remove validation of unreachable code
src: remove validation of unreachable code
src: remove validation of unreachable code
src: remove validation of unreachable code