-
Enhancement
-
Resolution: Fixed
-
P4
-
17
-
b10
After JDK-8254702, SonarCloud instance complains about blocks like these: "Change this loop body so that it can be executed more than once."
int initJvmlLauncherData(JvmlLauncherData* ptr) const {
// Store path to JLI library just behind JvmlLauncherData header.
char* curPtr = reinterpret_cast<char*>(ptr + 1);
do {
const size_t count = sizeof(char)
* (jliLibPath.size() + 1 /* trailing zero */);
if (ptr) {
std::memcpy(curPtr, jliLibPath.c_str(), count);
ptr->jliLibPath = curPtr;
}
curPtr += count;
} while (false); // <---- here
There is no sense in having "while(false)" here, where the syntactic "{}" block would do. There are also other uses in the jpackage code that employ "while(0)" for this, and then they also trigger the inspection about the implicit conversion of zero int to boolean.
int initJvmlLauncherData(JvmlLauncherData* ptr) const {
// Store path to JLI library just behind JvmlLauncherData header.
char* curPtr = reinterpret_cast<char*>(ptr + 1);
do {
const size_t count = sizeof(char)
* (jliLibPath.size() + 1 /* trailing zero */);
if (ptr) {
std::memcpy(curPtr, jliLibPath.c_str(), count);
ptr->jliLibPath = curPtr;
}
curPtr += count;
} while (false); // <---- here
There is no sense in having "while(false)" here, where the syntactic "{}" block would do. There are also other uses in the jpackage code that employ "while(0)" for this, and then they also trigger the inspection about the implicit conversion of zero int to boolean.
- relates to
-
JDK-8254702 jpackage app launcher crashes on CentOS
-
- Resolved
-