Sonarcloud issues the following warning about various macros in src/hotspot/share/memory/metaspace.
“Move this #define/#undef to the global namespace.
Macros should not be #define'd or #undef'd within a block”
For example, in src/hotspot/share/memory/metaspace/blockTree.cpp
namespace metaspace {
// Needed to prevent linker errors on MacOS and AIX
const size_t BlockTree::MinWordSize;
#define NODE_FORMAT \
Move this #define/#undef to the global namespace.
"@" PTR_FORMAT \
": canary " INTPTR_FORMAT \
", parent " PTR_FORMAT \
", left " PTR_FORMAT \
", right " PTR_FORMAT \
", next " PTR_FORMAT \
", size " SIZE_FORMAT
#define NODE_FORMAT_ARGS(n) \
p2i(n), \
(n)->_canary, \
p2i((n)->_parent), \
p2i((n)->_left), \
p2i((n)->_right), \
p2i((n)->_next), \
(n)->_word_size
…
}
Macros should be defined outside of the metaspace namespace, since their scope is not actually restricted.
“Move this #define/#undef to the global namespace.
Macros should not be #define'd or #undef'd within a block”
For example, in src/hotspot/share/memory/metaspace/blockTree.cpp
namespace metaspace {
// Needed to prevent linker errors on MacOS and AIX
const size_t BlockTree::MinWordSize;
#define NODE_FORMAT \
Move this #define/#undef to the global namespace.
"@" PTR_FORMAT \
": canary " INTPTR_FORMAT \
", parent " PTR_FORMAT \
", left " PTR_FORMAT \
", right " PTR_FORMAT \
", next " PTR_FORMAT \
", size " SIZE_FORMAT
#define NODE_FORMAT_ARGS(n) \
p2i(n), \
(n)->_canary, \
p2i((n)->_parent), \
p2i((n)->_left), \
p2i((n)->_right), \
p2i((n)->_next), \
(n)->_word_size
…
}
Macros should be defined outside of the metaspace namespace, since their scope is not actually restricted.
- links to
-
Review(master) openjdk/jdk/20610