92 lines
2.6 KiB
Diff
92 lines
2.6 KiB
Diff
From b3e9285865d1f62f63dff6587e2de32d0741eec9 Mon Sep 17 00:00:00 2001
|
|
From: fly_1997 <flylove7@outlook.com>
|
|
Date: Wed, 15 May 2024 10:49:16 +0800
|
|
Subject: [PATCH] fix warning message
|
|
|
|
---
|
|
thread_aware/CMakeLists.txt | 1 +
|
|
thread_aware/thread_aware.cpp | 13 +++++++------
|
|
thread_aware/thread_aware.h | 2 +-
|
|
3 files changed, 9 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/thread_aware/CMakeLists.txt b/thread_aware/CMakeLists.txt
|
|
index 6436942..2c4f756 100644
|
|
--- a/thread_aware/CMakeLists.txt
|
|
+++ b/thread_aware/CMakeLists.txt
|
|
@@ -1,5 +1,6 @@
|
|
cmake_minimum_required(VERSION 3.11)
|
|
project(thread_aware)
|
|
+add_compile_options(-O2 -fPIC -Wall -Wextra)
|
|
include_directories(../include)
|
|
add_library(thread_scenario SHARED
|
|
thread_aware.cpp
|
|
diff --git a/thread_aware/thread_aware.cpp b/thread_aware/thread_aware.cpp
|
|
index 8e0264b..2bdb744 100644
|
|
--- a/thread_aware/thread_aware.cpp
|
|
+++ b/thread_aware/thread_aware.cpp
|
|
@@ -13,12 +13,12 @@
|
|
#include "scenario.h"
|
|
#include <vector>
|
|
#include <fstream>
|
|
+#include <cstring>
|
|
|
|
-char *THREAD_SCENARIO = "thread_scenario";
|
|
-char *THREAD_DEPS = "thread_collector";
|
|
+char name[] = "thread_scenario";
|
|
+char dep[] = "thread_collector";
|
|
const std::string CONFIG_PATH = "/usr/lib64/oeAware-plugin/scenario/thread_scenario.ini";
|
|
const int CYCLE_SIZE = 100;
|
|
-
|
|
static std::vector<ThreadInfo> thread_info(THREAD_NUM);
|
|
static DataHeader data_header;
|
|
static DataBuf data_buf;
|
|
@@ -41,7 +41,7 @@ char* get_version() {
|
|
}
|
|
|
|
char* get_name() {
|
|
- return THREAD_SCENARIO;
|
|
+ return name;
|
|
}
|
|
|
|
char* get_description() {
|
|
@@ -49,7 +49,7 @@ char* get_description() {
|
|
}
|
|
|
|
char* get_dep() {
|
|
- return THREAD_DEPS;
|
|
+ return dep;
|
|
}
|
|
|
|
int get_cycle() {
|
|
@@ -67,6 +67,7 @@ void disable() {
|
|
}
|
|
|
|
void aware(void *info[], int len) {
|
|
+ if (len != 1) return;
|
|
data_header.index++;
|
|
data_header.count++;
|
|
int index = data_header.count % data_header.buf_len;
|
|
@@ -76,7 +77,7 @@ void aware(void *info[], int len) {
|
|
ThreadInfo *data = (ThreadInfo*)buf.data;
|
|
int cnt = 0;
|
|
for (int i = 0; i < buf.len; ++i) {
|
|
- for (int j = 0; j < key_list.size(); ++j) {
|
|
+ for (size_t j = 0; j < key_list.size(); ++j) {
|
|
if (data[i].name == key_list[j] && cnt < THREAD_NUM) {
|
|
thread_info[cnt].name = data[i].name;
|
|
thread_info[cnt].tid = data[i].tid;
|
|
diff --git a/thread_aware/thread_aware.h b/thread_aware/thread_aware.h
|
|
index 80e3f31..97e5d79 100644
|
|
--- a/thread_aware/thread_aware.h
|
|
+++ b/thread_aware/thread_aware.h
|
|
@@ -37,4 +37,4 @@ struct DataHeader {
|
|
int buf_len;
|
|
};
|
|
|
|
-#endif // !THREAD_AWARE_H
|
|
\ No newline at end of file
|
|
+#endif // !THREAD_AWARE_H
|
|
--
|
|
2.33.0
|
|
|