Skip to content

Commit b0b98ca

Browse files
authored
fix warnings (#239)
* Create overview.md * compilation passed. * feat: fix warnings in common/ * fix: agent-watchdog warnings. * fix: dtcagent warnings. * fix: dtcd warnings part 1 * fix: compilation warnings in hwcserver and connector/1 * fix: warnings in connector * fix: warning in dtcd * fix: warnings in utils
1 parent bfe3105 commit b0b98ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+488
-239
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
settings.json
66
*.o
77
.dep*
8-
build/
8+
build/
9+
.joycode

CMakeLists.txt

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
1-
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
1+
CMAKE_MINIMUM_REQUIRED (VERSION 3.10)
2+
3+
# Set modern CMake policies
4+
if(POLICY CMP0074)
5+
cmake_policy(SET CMP0074 NEW) # Find_package uses <PackageName>_ROOT variables
6+
endif()
7+
if(POLICY CMP0077)
8+
cmake_policy(SET CMP0077 NEW) # option() honors normal variables
9+
endif()
10+
211
PROJECT(dtc)
312

13+
# Set default build type if not specified
14+
if(NOT CMAKE_BUILD_TYPE)
15+
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type" FORCE)
16+
endif()
17+
18+
# Enable modern compiler features while maintaining GCC 4.9 compatibility
19+
set(CMAKE_CXX_STANDARD 11)
20+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
21+
set(CMAKE_CXX_EXTENSIONS OFF)
22+
23+
# Compiler-specific flags for modern GCC support
24+
if(CMAKE_COMPILER_IS_GNUCXX)
25+
# Add compiler version checks for better compatibility
26+
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "6.0")
27+
# Modern GCC flags
28+
add_compile_options(-Wno-misleading-indentation)
29+
add_compile_options(-Wno-address-of-packed-member)
30+
endif()
31+
32+
# Common flags for all GCC versions
33+
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fpermissive>")
34+
add_compile_options(-Wno-builtin-macro-redefined)
35+
36+
# Use old ABI for compatibility with bundled libraries
37+
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
38+
endif()
39+
440
#Use optional command `cmake -DCMAKE_TEST_OPTION=ON ..` to build test demo.
541
option(CMAKE_TEST_OPTION "option for test_demo" OFF)
642

conf/server.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rules:
2+
- !AUTHORITY
3+
users:
4+
- sharding@%:sharding
5+
provider:
6+
type: ALL_PERMITTED

src/agent-watchdog/CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ INCLUDE_DIRECTORIES(
22
${PROJECT_SOURCE_DIR}/src/daemons
33
${PROJECT_SOURCE_DIR}/src/libs/common
44
${PROJECT_SOURCE_DIR}/src/libs/stat
5-
${PROJECT_SOURCE_DIR}/src/core
65
${PROJECT_SOURCE_DIR}/src/libs/log4cplus/include
76
${PROJECT_SOURCE_DIR}/src/libs/yaml-cpp/include
7+
${PROJECT_SOURCE_DIR}/src/core
88
${PROJECT_SOURCE_DIR}/src/libs/mxml/include)
99

1010
LINK_DIRECTORIES(
@@ -16,8 +16,8 @@ LINK_DIRECTORIES(
1616

1717
include(../utils.cmake)
1818

19-
FILE(GLOB_RECURSE SRC_LIST1 ./*.cc ./*.c)
20-
19+
FILE(GLOB_RECURSE CXX_SRC_LIST ./*.cc)
20+
FILE(GLOB_RECURSE C_SRC_LIST ./*.c)
2121

2222
LINK_LIBRARIES(liblog4cplus.a)
2323
LINK_LIBRARIES(libcommon.a)
@@ -26,10 +26,13 @@ LINK_LIBRARIES(libstat.a)
2626
LINK_LIBRARIES(pthread)
2727
LINK_LIBRARIES(dl)
2828

29-
ADD_DEFINITIONS("-g -fPIC -fpermissive -std=gnu++11")
30-
ADD_DEFINITIONS(-Wno-builtin-macro-redefined)
29+
# Set properties for C++ files
30+
set_source_files_properties(${CXX_SRC_LIST} PROPERTIES COMPILE_FLAGS "-g -fPIC -fpermissive -std=gnu++11 -D_GLIBCXX_USE_CXX11_ABI=0 -Wno-builtin-macro-redefined")
31+
32+
# Set properties for C files
33+
set_source_files_properties(${C_SRC_LIST} PROPERTIES COMPILE_FLAGS "-g -fPIC -Wno-builtin-macro-redefined")
3134

32-
ADD_EXECUTABLE(agent-watchdog ${SRC_LIST1})
35+
ADD_EXECUTABLE(agent-watchdog ${CXX_SRC_LIST} ${C_SRC_LIST})
3336

3437
TARGET_LINK_LIBRARIES(agent-watchdog libstat.a libcommon.a libyaml-cpp.a liblog4cplus.a mxml)
3538
redefine_file_macro(agent-watchdog)

src/agent-watchdog/daemons.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ void close_sharding()
8888
p[0] = NULL;
8989
execv("../sharding/bin/stop.sh", p);
9090

91-
system("../sharding/bin/stop.sh");
91+
int result = system("../sharding/bin/stop.sh");
92+
(void)result; // Silence unused result warning
9293
}
9394

9495
void WatchDog::run_loop()

src/agent-watchdog/main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ std::map<std::string, std::string> map_dtc_conf; //key:value --> dtc addr:conf f
2626
#define DA_STRING(x) DA_STRING_HELPER(x)
2727

2828
#define DA_VERSION_STR \
29-
DA_STRING(DA_VERSION_MAJOR)"."DA_STRING(DA_VERSION_MINOR)"."\
29+
DA_STRING(DA_VERSION_MAJOR) "." DA_STRING(DA_VERSION_MINOR) "." \
3030
DA_STRING(DA_VERSION_BUILD)
3131

3232
static int show_help;
@@ -368,7 +368,7 @@ int get_all_dtc_confs()
368368
int content_len = 0;
369369
log4cplus_debug("addr:%s", addr.c_str());
370370
std::string str = send_select_dtcyaml((addr.substr(0, addr.find(':'))).c_str(), atoi((addr.substr(addr.find(':')+1)).c_str()));
371-
content = str.c_str();
371+
content = const_cast<char*>(str.c_str());
372372
content_len = str.length();
373373
log4cplus_debug("content:%s", content);
374374

src/agent-watchdog/sharding_entry.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void ShardingEntry::exec()
3939
{
4040
set_proc_title("agent_sharding");
4141
argv[0] = (char *)"../sharding/bin/start.sh";
42-
argv[1] = "3307";
43-
argv[2] = "../conf";
42+
argv[1] = const_cast<char*>("3307");
43+
argv[2] = const_cast<char*>("../conf");
4444
argv[3] = NULL;
4545
execv(argv[0], argv);
4646
}

src/agent/common/da_string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ int string_compare_nonsentive(const struct string *s1, const struct string *s2)
130130
return s1->len > s2->len ? 1 : -1;
131131
}
132132

133-
string_copy(&tmp1, s1, s1->len);
134-
string_copy(&tmp2, s2, s2->len);
133+
string_copy(&tmp1, s1->data, s1->len);
134+
string_copy(&tmp2, s2->data, s2->len);
135135
string_upper(&tmp1);
136136
string_upper(&tmp2);
137137
return da_strncmp(&tmp1.data, &tmp2.data, &tmp1.len);

src/agent/da_conn.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
#include <inttypes.h>
17+
#include <sys/uio.h>
1718
#include "da_mem_pool.h"
1819
#include "da_conn.h"
1920
#include "da_listener.h"

src/agent/da_listener.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "da_core.h"
2323
#include "da_event.h"
2424
#include "da_stats.h"
25+
#include "my/my_net_send.h"
2526
#include "da_msg.h"
2627

2728
void listener_ref(struct conn *l, void *owner)

0 commit comments

Comments
 (0)