fix warning message

(cherry picked from commit 29f80967105380f32119b40e7b8547ad104c3ff5)
This commit is contained in:
fly_1997 2024-05-15 14:29:50 +08:00 committed by openeuler-sync-bot
parent 5a11ed2f40
commit 35cf3e7c3f
2 changed files with 96 additions and 1 deletions

View File

@ -0,0 +1,91 @@
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

View File

@ -1,10 +1,11 @@
Name: oeAware-scenario
Version: v1.0.1
Release: 1
Release: 2
Summary: %{name} provides low-overhead scenario awareness
License: MulanPSL2
URL: https://gitee.com/openeuler/%{name}
Source0: %{name}-%{version}.tar.gz
Patch1: 0001-fix-warning-message.patch
BuildRequires: cmake make gcc-c++
@ -31,6 +32,9 @@ install -D -m 0640 ./thread_aware/thread_scenario.ini %{buildroot}%{_libdir}/oeA
%attr(0440, root, root) %{_libdir}/oeAware-plugin/scenario/*.so
%changelog
* Wed May 15 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-2
- fix warning message
* Sat May 11 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-1
- update version to v1.0.1