Skip to content

Commit

Permalink
fix all compile waring in main program (alibaba#1480)
Browse files Browse the repository at this point in the history
* fix all compile waring in main program

* fix BoostRegexValidator compile errors
  • Loading branch information
yyuuttaaoo authored May 9, 2024
1 parent b4c238f commit f0bc509
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 14 deletions.
22 changes: 11 additions & 11 deletions core/common/BoostRegexValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ int main(int argc, char* argv[]) // argv is logFile,logBeginReg,logRegex
}
} else {
Json::Value jsonResult;
Json::FastWriter jsonWriter;
jsonResult["result"]["state"] = false;
jsonResult["result"]["content"] = "argument's format is not correct";
cout << jsonWriter.write(jsonResult);
Json::StreamWriterBuilder writerBuilder;
cout << Json::writeString(writerBuilder, jsonResult);
}
return 0;
}
void checkFilterRegex(const string& logFile, const string& logRegex) {
Json::Value jsonResult;
Json::Value jsonRoot;
Json::FastWriter jsonWriter;
Json::StreamWriterBuilder writerBuilder;
try {
boost::regex reg(logRegex);
boost::match_results<const char*> what;
Expand All @@ -111,20 +111,20 @@ void checkFilterRegex(const string& logFile, const string& logRegex) {
jsonRoot["content"] = what.str();
}
jsonResult["result"] = jsonRoot;
cout << jsonWriter.write(jsonResult);
cout << Json::writeString(writerBuilder, jsonResult);
} catch (boost::regex_error& e) {
jsonRoot["state"] = "error";
jsonRoot["content"] = "过滤正则表达式错误!";
jsonResult["result"] = jsonRoot;
cout << jsonWriter.write(jsonResult);
cout << Json::writeString(writerBuilder, jsonResult);
return;
}
}

void checkRegex(const string& logFile, const string& logBeginReg, const string& logRegex) {
Json::Value jsonResult;
Json::Value jsonRoot;
Json::FastWriter jsonWriter;
Json::StreamWriterBuilder writerBuilder;
try {
boost::regex reg(logRegex);
boost::match_results<const char*> what;
Expand All @@ -151,18 +151,18 @@ void checkRegex(const string& logFile, const string& logBeginReg, const string&
jsonRoot["content"] = content;
}
jsonResult["result"] = jsonRoot;
cout << jsonWriter.write(jsonResult);
cout << Json::writeString(writerBuilder, jsonResult);
} catch (boost::regex_error& e) {
jsonRoot["state"] = "error";
jsonRoot["content"] = "日志内容正则表达式错误!";
jsonResult["result"] = jsonRoot;
cout << jsonWriter.write(jsonResult);
cout << Json::writeString(writerBuilder, jsonResult);
return;
}
}

vector<string> checkLogBeginReg(const string& logFile, const string& logBeginReg, const bool display) {
Json::FastWriter jsonWriter;
Json::StreamWriterBuilder writerBuilder;
Json::Value jsonRoot;
Json::Value jsonResult;
Json::Value jsonPosition;
Expand Down Expand Up @@ -203,13 +203,13 @@ vector<string> checkLogBeginReg(const string& logFile, const string& logBeginReg
jsonRoot["result"]["position"] = jsonPosition;

if (display)
cout << jsonWriter.write(jsonRoot);
cout << Json::writeString(writerBuilder, jsonRoot);
return outputVector;
} catch (boost::regex_error& e) {
jsonRoot["state"] = "error";
jsonRoot["content"] = "日志起始匹配正则表达式错误!";
jsonResult["result"] = jsonRoot;
cout << jsonWriter.write(jsonResult);
cout << Json::writeString(writerBuilder, jsonResult);
return resultVector;
}
}
6 changes: 6 additions & 0 deletions core/common/Lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

#pragma once
#include <mutex>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <boost/concept_check.hpp>
#include <boost/range/algorithm/equal.hpp>
#include <boost/range/size.hpp>
#pragma GCC diagnostic pop
#include <boost/thread.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#ifdef _MSC_VER
Expand Down
7 changes: 7 additions & 0 deletions core/observer/metas/ConnectionMetaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ bool ExtractDiagMsg(const inet_diag_msg& msg,
.IPV4 = msg.id.idiag_dst[0],
}};
} else if (msg.idiag_family == AF_INET6) {
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
info->localAddr = SockAddress{.Type = SockAddressType_IPV6,
.Addr = SockAddressDetail{
.IPV6 = {((uint64_t*)msg.id.idiag_src)[0], ((uint64_t*)msg.id.idiag_src)[1]},
Expand All @@ -366,6 +370,9 @@ bool ExtractDiagMsg(const inet_diag_msg& msg,
.Addr = SockAddressDetail{
.IPV6 = {((uint64_t*)msg.id.idiag_dst)[0], ((uint64_t*)msg.id.idiag_dst)[1]},
}};
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
}
infos.insert(std::make_pair(inode, info));
return true;
Expand Down
5 changes: 4 additions & 1 deletion core/pipeline/PipelineManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ namespace logtail {
void logtail::PipelineManager::UpdatePipelines(ConfigDiff& diff) {
#ifndef APSARA_UNIT_TEST_MAIN
// 过渡使用
static bool isInputFileStarted = false, isInputObserverStarted = false, isInputStreamStarted = false;
static bool isInputFileStarted = false, isInputObserverStarted = false;
#if defined(__ENTERPRISE__) && defined(__linux__) && !defined(__ANDROID__)
static bool isInputStreamStarted = false;
#endif
bool isInputObserverChanged = false, isInputFileChanged = false, isInputStreamChanged = false;
for (const auto& name : diff.mRemoved) {
CheckIfInputUpdated(mPipelineNameEntityMap[name]->GetConfig()["inputs"][0],
Expand Down
5 changes: 4 additions & 1 deletion core/processor/ProcessorSPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
#include "processor/ProcessorSPL.h"

#include <curl/curl.h>
#ifdef FMT_HEADER_ONLY
#undef FMT_HEADER_ONLY
#endif
#include <spl/logger/Logger.h>
#include <spl/pipeline/SplPipeline.h>

#include <iostream>

#include "common/ParamExtractor.h"
#include "common/Flags.h"
#include "common/ParamExtractor.h"
#include "logger/Logger.h"
#include "monitor/MetricConstants.h"
#include "spl/PipelineEventGroupInput.h"
Expand Down
2 changes: 1 addition & 1 deletion core/sdk/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ namespace sdk {
}

static unsigned char FromHex(unsigned char x) {
unsigned char y;
unsigned char y = '\0';
if (x >= 'A' && x <= 'Z')
y = x - 'A' + 10;
else if (x >= 'a' && x <= 'z')
Expand Down
6 changes: 6 additions & 0 deletions core/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ if (MSVC)
add_definitions(-DNOMINMAX)
endif ()
add_library(${PROJECT_NAME} STATIC ${ALL_SOURCE_FILES})
if(MSVC)
# For MSVC, use /W4 for a high level of warnings, and treat warnings as errors.
# target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Werror)
endif()
link_jsoncpp(${PROJECT_NAME})
link_yamlcpp(${PROJECT_NAME})
link_boost(${PROJECT_NAME})
Expand Down

0 comments on commit f0bc509

Please # to comment.