RFR: JDK-8319301: Static analysis warnings after JDK-8318016 [v3]
Thomas Stuefe
stuefe at openjdk.org
Wed Nov 15 10:51:53 UTC 2023
> Sonar reports two new troubles in compileOracle.cpp:
>
> 1) "left operand of '-' is a garbage value", when seeing that `line` might not be initialized properly:
>
>
> char* end;
> if (!parse_integer<size_t>(line, &end, &s)) {
> jio_snprintf(errorbuf, buf_size, "MemLimit: invalid value");
> }
> bytes_read = (int)(end - line); // <---- here
>
>
> 2) "3rd function call argument is an uninitialized value", because there is an early `return true` from parseMemLimit that does not initialize `value`:
>
>
> // Special handling for memlimit
> bool success = (option == CompileCommand::MemLimit) && parseMemLimit(line, value, bytes_read, errorbuf, buf_size);
> if (!success) {
> // Is it a raw number?
> success = sscanf(line, "" INTX_FORMAT "%n", &value, &bytes_read) == 1;
> }
> if (success) {
> total_bytes_read += bytes_read;
> line += bytes_read;
> register_command(matcher, option, value); // <---- here
>
>
> Patch fixes both instances and adds new regression test.
Thomas Stuefe has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains ten commits:
- Merge
- Fix bug number in test
- JDK-8319301-Static-analysis-warnings-after-JDK-8318016
- Merge branch 'master' into JDK-8318671-Potential-uninitialized-uintx-value-after-JDK-8317683
- Fix Windows build
- remove tab
- Make patch more palatable
- Merge branch 'openjdk:master' into JDK-8318671-Potential-uninitialized-uintx-value-after-JDK-8317683
- JDK-8318671-Potential-uninitialized-uintx-value-after-JDK-8317683
-------------
Changes: https://git.openjdk.org/jdk/pull/16631/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16631&range=02
Stats: 92 lines in 2 files changed: 87 ins; 1 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/16631.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16631/head:pull/16631
PR: https://git.openjdk.org/jdk/pull/16631
More information about the hotspot-compiler-dev
mailing list