[10] Buld warnings from GCC 7.1 on Fedora 26
Vladimir Ivanov
vladimir.x.ivanov at oracle.com
Wed Jul 12 17:37:19 UTC 2017
> I tried to build jdk10-hs on Fedora 26 with gcc-7.1.1-3.fc26.x86_64,
> then I encountered some build warnings.
> I want to fix them. Can I file it to JBS and send review request for 10?
Sure, feel free to take care of them.
Suggested fixes look reasonable.
Best regards,
Vladimir Ivanov
> details:
>
> 1-warning:
> /home/ysuenaga/OpenJDK/jdk10-hs/hotspot/src/share/vm/code/dependencies.cpp:
> In static member function 'static void
> Dependencies::write_dependency_to(xmlStream*, Dependencies::DepType,
> GrowableArray<Dependencies::DepArgument>*, Klass*)':
> /home/ysuenaga/OpenJDK/jdk10-hs/hotspot/src/share/vm/code/dependencies.cpp:714:6:
> warning: '%d' directive writing between 1 and 10 bytes into a region
> of size 9 [-Wformat-overflow=]
> void Dependencies::write_dependency_to(xmlStream* xtty,
> ^~~~~~~~~~~~
> /home/ysuenaga/OpenJDK/jdk10-hs/hotspot/src/share/vm/code/dependencies.cpp:714:6:
> note: directive argument in the range [0, 2147483647]
> /home/ysuenaga/OpenJDK/jdk10-hs/hotspot/src/share/vm/code/dependencies.cpp:745:27:
> note: 'sprintf' output between 3 and 12 bytes into a destination of
> size 10
> char xn[10]; sprintf(xn, "x%d", j);
> ~~~~~~~^~~~~~~~~~~~~~
>
> 1-patch:
> diff -r 9c54cd2cdf09 src/share/vm/code/dependencies.cpp
> --- a/src/share/vm/code/dependencies.cpp Mon Jul 10 23:28:25 2017 +0200
> +++ b/src/share/vm/code/dependencies.cpp Wed Jul 12 10:32:20 2017 +0900
> @@ -742,7 +742,7 @@
> xtty->object("x", arg.metadata_value());
> }
> } else {
> - char xn[10]; sprintf(xn, "x%d", j);
> + char xn[12]; sprintf(xn, "x%d", j);
> if (arg.is_oop()) {
> xtty->object(xn, Handle(thread, arg.oop_value()));
> } else {
>
>
> 2-warning:
> /home/ysuenaga/OpenJDK/jdk10-hs/hotspot/src/share/vm/compiler/methodMatcher.cpp:
> In static member function 'static bool
> MethodMatcher::canonicalize(char*, const char*&)':
> /home/ysuenaga/OpenJDK/jdk10-hs/hotspot/src/share/vm/compiler/methodMatcher.cpp:99:22:
> warning: comparison between pointer and zero character constant
> [-Wpointer-compare]
> if (colon + 2 != '\0') {
> ^~~~
> /home/ysuenaga/OpenJDK/jdk10-hs/hotspot/src/share/vm/compiler/methodMatcher.cpp:99:22:
> note: did you mean to dereference the pointer?
>
> 2-patch:
> diff -r 9c54cd2cdf09 src/share/vm/compiler/methodMatcher.cpp
> --- a/src/share/vm/compiler/methodMatcher.cpp Mon Jul 10 23:28:25 2017 +0200
> +++ b/src/share/vm/compiler/methodMatcher.cpp Wed Jul 12 10:32:20 2017 +0900
> @@ -96,7 +96,7 @@
> bool have_colon = (colon != NULL);
> if (have_colon) {
> // Don't allow multiple '::'
> - if (colon + 2 != '\0') {
> + if (colon[2] != '\0') {
> if (strstr(colon+2, "::")) {
> error_msg = "Method pattern only allows one '::' allowed";
> return false;
>
>
> 3-warning:
> /home/ysuenaga/OpenJDK/jdk10-hs/hotspot/src/share/vm/logging/logFileOutput.cpp:
> In static member function 'static void
> LogFileOutput::set_file_name_parameters(jlong)':
> /home/ysuenaga/OpenJDK/jdk10-hs/hotspot/src/share/vm/logging/logFileOutput.cpp:61:99:
> warning: format not a string literal, format string not checked
> [-Wformat-nonliteral]
> res = (int)strftime(_vm_start_time_str, sizeof(_vm_start_time_str),
> TimestampFormat, &local_time);
>
> ^
>
> 3-patch:
> diff -r 9c54cd2cdf09 src/share/vm/logging/logFileOutput.cpp
> --- a/src/share/vm/logging/logFileOutput.cpp Mon Jul 10 23:28:25 2017 +0200
> +++ b/src/share/vm/logging/logFileOutput.cpp Wed Jul 12 10:32:20 2017 +0900
> @@ -51,6 +51,8 @@
> _file_name = make_file_name(name + strlen(Prefix), _pid_str,
> _vm_start_time_str);
> }
>
> +PRAGMA_DIAG_PUSH
> +PRAGMA_FORMAT_NONLITERAL_IGNORED
> void LogFileOutput::set_file_name_parameters(jlong vm_start_time) {
> int res = jio_snprintf(_pid_str, sizeof(_pid_str), "%d",
> os::current_process_id());
> assert(res > 0, "PID buffer too small");
> @@ -61,6 +63,7 @@
> res = (int)strftime(_vm_start_time_str, sizeof(_vm_start_time_str),
> TimestampFormat, &local_time);
> assert(res > 0, "VM start time buffer too small.");
> }
> +PRAGMA_DIAG_POP
>
> LogFileOutput::~LogFileOutput() {
> if (_stream != NULL) {
>
>
> Thanks,
>
> Yasumasa
>
More information about the hotspot-dev
mailing list