8036122: Fix warning 'format not a string literal'
Reviewed-by: mduigou, kvn
This commit is contained in:
parent
e8d4b7aee3
commit
4b9933a012
@ -260,7 +260,7 @@ ifeq ($(USE_CLANG), true)
|
|||||||
WARNINGS_ARE_ERRORS += -Wno-empty-body
|
WARNINGS_ARE_ERRORS += -Wno-empty-body
|
||||||
endif
|
endif
|
||||||
|
|
||||||
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2 -Wno-error=format-nonliteral
|
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2
|
||||||
|
|
||||||
ifeq ($(USE_CLANG),)
|
ifeq ($(USE_CLANG),)
|
||||||
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
|
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
|
||||||
|
@ -215,7 +215,7 @@ ifeq ($(USE_CLANG), true)
|
|||||||
WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
|
WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
|
||||||
endif
|
endif
|
||||||
|
|
||||||
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wno-error=format-nonliteral
|
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2
|
||||||
|
|
||||||
ifeq ($(USE_CLANG),)
|
ifeq ($(USE_CLANG),)
|
||||||
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
|
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
|
||||||
|
@ -118,7 +118,7 @@ endif
|
|||||||
# Compiler warnings are treated as errors
|
# Compiler warnings are treated as errors
|
||||||
WARNINGS_ARE_ERRORS = -Werror
|
WARNINGS_ARE_ERRORS = -Werror
|
||||||
# Enable these warnings. See 'info gcc' about details on these options
|
# Enable these warnings. See 'info gcc' about details on these options
|
||||||
WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2 -Wno-error=format-nonliteral
|
WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2
|
||||||
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
|
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
|
||||||
# Special cases
|
# Special cases
|
||||||
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
|
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
|
||||||
|
@ -5284,7 +5284,6 @@ jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
|||||||
|
|
||||||
static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
||||||
static bool proc_task_unchecked = true;
|
static bool proc_task_unchecked = true;
|
||||||
static const char *proc_stat_path = "/proc/%d/stat";
|
|
||||||
pid_t tid = thread->osthread()->thread_id();
|
pid_t tid = thread->osthread()->thread_id();
|
||||||
char *s;
|
char *s;
|
||||||
char stat[2048];
|
char stat[2048];
|
||||||
@ -5297,6 +5296,8 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
|||||||
long ldummy;
|
long ldummy;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
|
snprintf(proc_name, 64, "/proc/%d/stat", tid);
|
||||||
|
|
||||||
// The /proc/<tid>/stat aggregates per-process usage on
|
// The /proc/<tid>/stat aggregates per-process usage on
|
||||||
// new Linux kernels 2.6+ where NPTL is supported.
|
// new Linux kernels 2.6+ where NPTL is supported.
|
||||||
// The /proc/self/task/<tid>/stat still has the per-thread usage.
|
// The /proc/self/task/<tid>/stat still has the per-thread usage.
|
||||||
@ -5308,12 +5309,11 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
|||||||
proc_task_unchecked = false;
|
proc_task_unchecked = false;
|
||||||
fp = fopen("/proc/self/task", "r");
|
fp = fopen("/proc/self/task", "r");
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
proc_stat_path = "/proc/self/task/%d/stat";
|
snprintf(proc_name, 64, "/proc/self/task/%d/stat", tid);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(proc_name, proc_stat_path, tid);
|
|
||||||
fp = fopen(proc_name, "r");
|
fp = fopen(proc_name, "r");
|
||||||
if ( fp == NULL ) return -1;
|
if ( fp == NULL ) return -1;
|
||||||
statlen = fread(stat, 1, 2047, fp);
|
statlen = fread(stat, 1, 2047, fp);
|
||||||
|
@ -374,25 +374,8 @@ static void usage() {
|
|||||||
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
|
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
|
||||||
|
|
||||||
#define RANGE0 "[*" RANGEBASE "]"
|
#define RANGE0 "[*" RANGEBASE "]"
|
||||||
#define RANGEDOT "[*" RANGEBASE ".]"
|
|
||||||
#define RANGESLASH "[*" RANGEBASE "/]"
|
#define RANGESLASH "[*" RANGEBASE "/]"
|
||||||
|
|
||||||
|
|
||||||
// Accept several syntaxes for these patterns
|
|
||||||
// original syntax
|
|
||||||
// cmd java.lang.String foo
|
|
||||||
// PrintCompilation syntax
|
|
||||||
// cmd java.lang.String::foo
|
|
||||||
// VM syntax
|
|
||||||
// cmd java/lang/String[. ]foo
|
|
||||||
//
|
|
||||||
|
|
||||||
static const char* patterns[] = {
|
|
||||||
"%*[ \t]%255" RANGEDOT " " "%255" RANGE0 "%n",
|
|
||||||
"%*[ \t]%255" RANGEDOT "::" "%255" RANGE0 "%n",
|
|
||||||
"%*[ \t]%255" RANGESLASH "%*[ .]" "%255" RANGE0 "%n",
|
|
||||||
};
|
|
||||||
|
|
||||||
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
|
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
|
||||||
int match = MethodMatcher::Exact;
|
int match = MethodMatcher::Exact;
|
||||||
while (name[0] == '*') {
|
while (name[0] == '*') {
|
||||||
@ -421,12 +404,10 @@ static bool scan_line(const char * line,
|
|||||||
int* bytes_read, const char*& error_msg) {
|
int* bytes_read, const char*& error_msg) {
|
||||||
*bytes_read = 0;
|
*bytes_read = 0;
|
||||||
error_msg = NULL;
|
error_msg = NULL;
|
||||||
for (uint i = 0; i < ARRAY_SIZE(patterns); i++) {
|
if (2 == sscanf(line, "%*[ \t]%255" RANGESLASH "%*[ ]" "%255" RANGE0 "%n", class_name, method_name, bytes_read)) {
|
||||||
if (2 == sscanf(line, patterns[i], class_name, method_name, bytes_read)) {
|
*c_mode = check_mode(class_name, error_msg);
|
||||||
*c_mode = check_mode(class_name, error_msg);
|
*m_mode = check_mode(method_name, error_msg);
|
||||||
*m_mode = check_mode(method_name, error_msg);
|
return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown;
|
||||||
return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user