RFR: 8304836: Make MALLOC_MIN4 macro more robust
David Schlosnagle
duke at openjdk.org
Fri Apr 21 12:47:44 UTC 2023
On Thu, 20 Apr 2023 18:39:29 GMT, Naoto Sato <naoto at openjdk.org> wrote:
> The current macro assumes the argument is `jint` because all locations pass `jint`. However, this would not work if a wider type such as `jlong` is passed. Removing the `unsigned` cast and make the condition explicit would make the macro more robust.
src/java.base/share/native/libjava/jni_util.c line 42:
> 40: * that overflows into negative value.
> 41: */
> 42: #define MALLOC_MIN4(len) (len >= INT_MAX || len < 0 ? \
Should this keep the parentheses around `len` for explicit order of operations in case `len` is an expression?
Suggestion:
#define MALLOC_MIN4(len) ((len) >= INT_MAX || (len) < 0 ? \
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13564#discussion_r1173723228
More information about the core-libs-dev
mailing list