Integrated: 8313889: Fix -Wconversion warnings in foreign benchmarks
Jorn Vernee
jvernee at openjdk.org
Tue Aug 8 14:02:42 UTC 2023
On Mon, 7 Aug 2023 14:40:42 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> Fix these -Wconversion warnings in the foreign benchmarks:
>
>
> ./test/micro/org/openjdk/bench/java/lang/foreign/libQSortJNI.c: In function ‘Java_org_openjdk_bench_java_lang_foreign_QSort_jni_1qsort_1optimized’:
> ./test/micro/org/openjdk/bench/java/lang/foreign/libQSortJNI.c:59:17: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘jsize’ {aka ‘int’} may change the sign of the result [-Wsign-conversion]
> 59 | qsort(ints, length, sizeof(jint), &comparator);
> | ^~~~~~
> ./test/micro/org/openjdk/bench/java/lang/foreign/libQSortJNI.c: In function ‘Java_org_openjdk_bench_java_lang_foreign_QSort_jni_1qsort_1naive’:
> ./test/micro/org/openjdk/bench/java/lang/foreign/libQSortJNI.c:87:17: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘jsize’ {aka ‘int’} may change the sign of the result [-Wsign-conversion]
> 87 | qsort(carr, length, sizeof(jint), java_cmp);
> |
>
>
> In this case the issue is that we're converting from a signed type to an unsigned type. So, if the source value is negative, it will be positive after conversion.
>
> Since the source value is a Java array length in both cases, the value can not be negative, so we simply fix this by casting to `size_t` explicitly.
This pull request has now been integrated.
Changeset: 509f80bb
Author: Jorn Vernee <jvernee at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/509f80bb047beb49fb8ecb62bffb0d0fd4fe75cb
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
8313889: Fix -Wconversion warnings in foreign benchmarks
Reviewed-by: pminborg, mcimadamore
-------------
PR: https://git.openjdk.org/jdk/pull/15179
More information about the core-libs-dev
mailing list