Skip to content

Commit 43da805

Browse files
committed
fix compile error in gcc-4.8
Change-Id: I8e45c66db0ba08e739b6b5ba7ace85e4874e7f19
1 parent ac3c503 commit 43da805

File tree

512 files changed

+410
-83565
lines changed

Some content is hidden

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

512 files changed

+410
-83565
lines changed

LICENSE

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Files: test/tools/nbd/*
141141
Copyright: Copyright (c) 2020, NetEase Inc.
142142
License: GPL 2.0 (see LICENSE_GPL)
143143

144-
Files: thirdparties/aws-sdk/*
145-
Copyright: Copyright 2010-2017 Amazon.com, Inc.
144+
Files: thirdparties/aws/*
145+
common.bzl
146+
Copyright: Copyright 2019 The TensorFlow Authors
146147
License: Apache 2.0 (see LICENSE_APACHE)
147-

WORKSPACE

+44-6
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,52 @@ bind(
142142
actual = "@jsoncpp//:json",
143143
)
144144

145-
new_local_repository(
146-
name = "aws_sdk",
147-
build_file = "bazel/aws-sdk.BUILD",
148-
path = "thirdparties/aws-sdk/usr",
149-
)
150-
151145
new_local_repository(
152146
name = "etcdclient",
153147
build_file = "bazel/etcdclient.BUILD",
154148
path = "thirdparties/etcdclient",
155149
)
150+
151+
new_http_archive(
152+
name = "aws",
153+
urls = [
154+
"https://github.com/aws/aws-sdk-cpp/archive/1.7.340.tar.gz",
155+
"https://mirror.bazel.build/github.com/aws/aws-sdk-cpp/archive/1.7.340.tar.gz",
156+
],
157+
sha256 = "2e82517045efb55409cff1408c12829d9e8aea22c1e2888529cb769b7473b0bf",
158+
strip_prefix = "aws-sdk-cpp-1.7.340",
159+
build_file = "//:thirdparties/aws/aws.BUILD",
160+
)
161+
162+
new_http_archive(
163+
name = "aws_c_common",
164+
urls = [
165+
"https://github.com/awslabs/aws-c-common/archive/v0.4.29.tar.gz",
166+
"https://mirror.tensorflow.org/github.com/awslabs/aws-c-common/archive/v0.4.29.tar.gz",
167+
],
168+
sha256 = "01c2a58553a37b3aa5914d9e0bf7bf14507ff4937bc5872a678892ca20fcae1f",
169+
strip_prefix = "aws-c-common-0.4.29",
170+
build_file = "//:thirdparties/aws/aws-c-common.BUILD",
171+
)
172+
173+
new_http_archive(
174+
name = "aws_c_event_stream",
175+
urls = [
176+
"https://github.com/awslabs/aws-c-event-stream/archive/v0.1.4.tar.gz",
177+
"https://mirror.tensorflow.org/github.com/awslabs/aws-c-event-stream/archive/v0.1.4.tar.gz",
178+
],
179+
sha256 = "31d880d1c868d3f3df1e1f4b45e56ac73724a4dc3449d04d47fc0746f6f077b6",
180+
strip_prefix = "aws-c-event-stream-0.1.4",
181+
build_file = "//:thirdparties/aws/aws-c-event-stream.BUILD",
182+
)
183+
184+
new_http_archive(
185+
name = "aws_checksums",
186+
urls = [
187+
"https://github.com/awslabs/aws-checksums/archive/v0.1.5.tar.gz",
188+
"https://mirror.tensorflow.org/github.com/awslabs/aws-checksums/archive/v0.1.5.tar.gz",
189+
],
190+
sha256 = "6e6bed6f75cf54006b6bafb01b3b96df19605572131a2260fddaf0e87949ced0",
191+
strip_prefix = "aws-checksums-0.1.5",
192+
build_file = "//:thirdparties/aws/aws-checksums.BUILD",
193+
)

bazel/aws-sdk.BUILD

-15
This file was deleted.

common.bzl

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
# Rule for simple expansion of template files. This performs a simple
3+
# search over the template file for the keys in substitutions,
4+
# and replaces them with the corresponding values.
5+
#
6+
# Typical usage:
7+
# load("/tools/build_rules/template_rule", "expand_header_template")
8+
# template_rule(
9+
# name = "ExpandMyTemplate",
10+
# src = "my.template",
11+
# out = "my.txt",
12+
# substitutions = {
13+
# "$VAR1": "foo",
14+
# "$VAR2": "bar",
15+
# }
16+
# )
17+
#
18+
# Args:
19+
# name: The name of the rule.
20+
# template: The template file to expand
21+
# out: The destination of the expanded file
22+
# substitutions: A dictionary mapping strings to their substitutions
23+
24+
def template_rule_impl(ctx):
25+
ctx.actions.expand_template(
26+
template = ctx.file.src,
27+
output = ctx.outputs.out,
28+
substitutions = ctx.attr.substitutions,
29+
)
30+
31+
template_rule = rule(
32+
attrs = {
33+
"src": attr.label(
34+
mandatory = True,
35+
allow_single_file = True,
36+
),
37+
"substitutions": attr.string_dict(mandatory = True),
38+
"out": attr.output(mandatory = True),
39+
},
40+
# output_to_genfiles is required for header files.
41+
output_to_genfiles = True,
42+
implementation = template_rule_impl,
43+
)

mk-deb.sh

-5
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,6 @@ dpkg-deb -b build/curve-snapshotcloneserver .
430430
dpkg-deb -b build/curve-nginx .
431431
dpkg-deb -b build/nebd-package .
432432
dpkg-deb -b build/nbd-package .
433-
#aws-c-common(commit=0302570a3cbabd98293ee03971e0867f28355086)
434-
#aws-checksums(commit=78be31b81a2b0445597e60ecb2412bc44e762a99)
435-
#aws-c-event-stream(commit=ad9a8b2a42d6c6ef07ccf251b5038b89487eacb3)
436-
#aws-sdk-cpp(commit=2330d84a30ac32ad04d4fb9baf88cda4f8b9b190)
437-
dpkg-deb -b thirdparties/aws-sdk .
438433

439434
#step6 清理libetcdclient.so编译出现的临时文件
440435
cd ${dir}/thirdparties/etcdclient

mk-tar.sh

-18
Original file line numberDiff line numberDiff line change
@@ -309,24 +309,6 @@ if [ $? -ne 0 ]
309309
then
310310
exit
311311
fi
312-
# aws
313-
mkdir -p build/curve/aws-sdk
314-
if [ $? -ne 0 ]
315-
then
316-
exit
317-
fi
318-
cp -r thirdparties/aws-sdk/usr/include \
319-
build/curve/aws-sdk/
320-
if [ $? -ne 0 ]
321-
then
322-
exit
323-
fi
324-
cp -r thirdparties/aws-sdk/usr/lib \
325-
build/curve/aws-sdk/
326-
if [ $? -ne 0 ]
327-
then
328-
exit
329-
fi
330312
# ansible
331313
cp -r curve-ansible build/curve/
332314
if [ $? -ne 0 ]

replace-curve-repo.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ sed -i "s;https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f
2424
sed -i "s;https://github.com/apache/incubator-brpc;https://gitee.com/baidu/BRPC;g" WORKSPACE
2525

2626
# jsoncpp
27-
sed -i "s;https://github.com/open-source-parsers/jsoncpp.git;https://gitee.com/mirrors/jsoncpp;g" WORKSPACE
27+
sed -i "s;https://github.com/open-source-parsers/jsoncpp.git;https://gitee.com/mirrors/jsoncpp;g" WORKSPACE
28+
29+
# aws
30+
sed -i "s;https://github.com/aws/aws-sdk-cpp/archive/1.7.340.tar.gz;https://curve-build.nos-eastchina1.126.net/aws-sdk-cpp-1.7.340.tar.gz;g" WORKSPACE

src/chunkserver/datastore/chunkserver_chunkfile.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ CSErrorCode CSChunkFile::Open(bool createFile) {
184184
if (createFile
185185
&& !lfs_->FileExists(chunkFilePath)
186186
&& metaPage_.sn > 0) {
187-
char buf[pageSize_] = {0};
187+
char buf[pageSize_]; // NOLINT
188+
memset(buf, 0, sizeof(buf));
188189
metaPage_.encode(buf);
189190
int rc = chunkfilePool_->GetChunk(chunkFilePath, buf);
190191
// 并发创建文件时,可能前面线程已经创建成功,那么这里会返回-EEXIST
@@ -763,7 +764,8 @@ bool CSChunkFile::needCow(SequenceNum sn) {
763764
}
764765

765766
CSErrorCode CSChunkFile::updateMetaPage(ChunkFileMetaPage* metaPage) {
766-
char buf[pageSize_] = {0};
767+
char buf[pageSize_]; // NOLINT
768+
memset(buf, 0, sizeof(buf));
767769
metaPage->encode(buf);
768770
int rc = writeMetaPage(buf);
769771
if (rc < 0) {
@@ -776,7 +778,8 @@ CSErrorCode CSChunkFile::updateMetaPage(ChunkFileMetaPage* metaPage) {
776778
}
777779

778780
CSErrorCode CSChunkFile::loadMetaPage() {
779-
char buf[pageSize_] = {0};
781+
char buf[pageSize_]; // NOLINT
782+
memset(buf, 0, sizeof(buf));
780783
int rc = readMetaPage(buf);
781784
if (rc < 0) {
782785
LOG(ERROR) << "Error occured when reading metaPage_."

src/chunkserver/datastore/chunkserver_snapshot.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ CSErrorCode CSSnapshot::Open(bool createFile) {
143143
if (createFile
144144
&& !lfs_->FileExists(snapshotPath)
145145
&& metaPage_.sn > 0) {
146-
char buf[pageSize_] = {0};
146+
char buf[pageSize_]; // NOLINT
147+
memset(buf, 0, sizeof(buf));
147148
metaPage_.encode(buf);
148149
int ret = chunkfilePool_->GetChunk(snapshotPath, buf);
149150
if (ret != 0) {
@@ -234,7 +235,8 @@ CSErrorCode CSSnapshot::Flush() {
234235
}
235236

236237
CSErrorCode CSSnapshot::updateMetaPage(SnapshotMetaPage* metaPage) {
237-
char buf[pageSize_] = {0};
238+
char buf[pageSize_]; // NOLINT
239+
memset(buf, 0, sizeof(buf));
238240
metaPage->encode(buf);
239241
int rc = writeMetaPage(buf);
240242
if (rc < 0) {
@@ -247,7 +249,8 @@ CSErrorCode CSSnapshot::updateMetaPage(SnapshotMetaPage* metaPage) {
247249
}
248250

249251
CSErrorCode CSSnapshot::loadMetaPage() {
250-
char buf[pageSize_] = {0};
252+
char buf[pageSize_]; // NOLINT
253+
memset(buf, 0, sizeof(buf));
251254
int rc = readMetaPage(buf);
252255
if (rc < 0) {
253256
LOG(ERROR) << "Error occured when reading metaPage_."

src/common/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ cc_library(
8888
deps = [
8989
"//external:glog",
9090
"//src/common:curve_common",
91-
"@aws_sdk//:aws_sdk",
91+
"@aws",
9292
],
9393
)

src/common/string_util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <glog/logging.h>
3636
#include <string>
3737
#include <vector>
38+
#include <stdexcept>
3839

3940
namespace curve {
4041
namespace common {
@@ -87,4 +88,3 @@ static bool StringToUll(const std::string &value, uint64_t *out) {
8788
} // namespace curve
8889

8990
#endif // SRC_COMMON_STRING_UTIL_H_
90-

src/snapshotcloneserver/common/snapshot_reference.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ void SnapshotReference::IncrementSnapshotRef(const UUID &snapshotId) {
3535
if (it != refMap_.end()) {
3636
it->second++;
3737
} else {
38-
refMap_.emplace(snapshotId, 1);
38+
refMap_.emplace(std::piecewise_construct,
39+
std::forward_as_tuple(snapshotId),
40+
std::forward_as_tuple(1));
3941
}
4042
}
4143

src/tools/curve_meta_tool.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ int CurveMetaTool::PrintChunkMeta(const std::string& chunkFileName) {
117117
}
118118

119119
// 读取chunk头部
120-
char buf[FLAGS_pageSize] = {0};
120+
char buf[FLAGS_pageSize];
121+
memset(buf, 0, sizeof(buf));
121122
int rc = localFS_->Read(fd, buf, 0, FLAGS_pageSize);
122123
localFS_->Close(fd);
123124
if (rc != FLAGS_pageSize) {
@@ -152,7 +153,8 @@ int CurveMetaTool::PrintSnapshotMeta(const std::string& snapFileName) {
152153
}
153154

154155
// 读取快照文件头部
155-
char buf[FLAGS_pageSize] = {0};
156+
char buf[FLAGS_pageSize];
157+
memset(buf, 0, sizeof(buf));
156158
int rc = localFS_->Read(fd, buf, 0, FLAGS_pageSize);
157159
localFS_->Close(fd);
158160
if (rc != FLAGS_pageSize) {

test/chunkserver/clone/clone_core_test.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ TEST_F(CloneCoreTest, ReadChunkTest2) {
209209
.WillOnce(DoAll(SetArgPointee<1>(info),
210210
Return(CSErrorCode::Success)));
211211
// 读chunk文件
212-
char chunkData[length]= {0};
212+
char chunkData[length]; // NOLINT
213213
memset(chunkData, 'a', length);
214214
EXPECT_CALL(*datastore_, ReadChunk(_, _, _, offset, length))
215215
.WillOnce(DoAll(SetArrayArgument<2>(chunkData,
@@ -240,7 +240,7 @@ TEST_F(CloneCoreTest, ReadChunkTest2) {
240240
// 每次调HandleReadRequest后会被closure释放
241241
std::shared_ptr<ReadChunkRequest> readRequest
242242
= GenerateReadRequest(CHUNK_OP_TYPE::CHUNK_OP_READ, offset, length);
243-
char cloneData[length]= {0};
243+
char cloneData[length]; // NOLINT
244244
memset(cloneData, 'b', length);
245245
EXPECT_CALL(*copyer_, DownloadAsync(_))
246246
.WillOnce(Invoke([&](DownloadClosure* closure){
@@ -291,7 +291,7 @@ TEST_F(CloneCoreTest, ReadChunkTest2) {
291291
// 每次调HandleReadRequest后会被closure释放
292292
std::shared_ptr<ReadChunkRequest> readRequest
293293
= GenerateReadRequest(CHUNK_OP_TYPE::CHUNK_OP_READ, offset, length);
294-
char cloneData[length]= {0};
294+
char cloneData[length]; // NOLINT
295295
memset(cloneData, 'b', length);
296296
EXPECT_CALL(*copyer_, DownloadAsync(_))
297297
.WillOnce(Invoke([&](DownloadClosure* closure){
@@ -304,7 +304,7 @@ TEST_F(CloneCoreTest, ReadChunkTest2) {
304304
.WillRepeatedly(DoAll(SetArgPointee<1>(info),
305305
Return(CSErrorCode::Success)));
306306
// 读chunk文件
307-
char chunkData[3 * PAGE_SIZE]= {0};
307+
char chunkData[3 * PAGE_SIZE];
308308
memset(chunkData, 'a', 3 * PAGE_SIZE);
309309
EXPECT_CALL(*datastore_, ReadChunk(_, _, _, 0, 3 * PAGE_SIZE))
310310
.WillOnce(DoAll(SetArrayArgument<2>(chunkData,
@@ -400,7 +400,7 @@ TEST_F(CloneCoreTest, ReadChunkTest3) {
400400
std::shared_ptr<ReadChunkRequest> readRequest
401401
= GenerateReadRequest(CHUNK_OP_TYPE::CHUNK_OP_READ, offset, length);
402402
SetCloneParam(readRequest);
403-
char cloneData[length]= {0};
403+
char cloneData[length]; // NOLINT
404404
memset(cloneData, 'b', length);
405405
EXPECT_CALL(*copyer_, DownloadAsync(_))
406406
.WillOnce(Invoke([&](DownloadClosure* closure){
@@ -496,7 +496,7 @@ TEST_F(CloneCoreTest, ReadChunkErrorTest) {
496496
EXPECT_CALL(*datastore_, GetChunkInfo(_, _))
497497
.WillOnce(DoAll(SetArgPointee<1>(info),
498498
Return(CSErrorCode::Success)));
499-
char cloneData[length]= {0};
499+
char cloneData[length]; // NOLINT
500500
memset(cloneData, 'b', length);
501501
EXPECT_CALL(*copyer_, DownloadAsync(_))
502502
.WillOnce(Invoke([&](DownloadClosure* closure){
@@ -524,7 +524,7 @@ TEST_F(CloneCoreTest, ReadChunkErrorTest) {
524524
.Times(2)
525525
.WillRepeatedly(DoAll(SetArgPointee<1>(info),
526526
Return(CSErrorCode::Success)));
527-
char cloneData[length]= {0};
527+
char cloneData[length]; // NOLINT
528528
memset(cloneData, 'b', length);
529529
EXPECT_CALL(*copyer_, DownloadAsync(_))
530530
.WillOnce(Invoke([&](DownloadClosure* closure){
@@ -646,7 +646,7 @@ TEST_F(CloneCoreTest, RecoverChunkTest2) {
646646
// 每次调HandleReadRequest后会被closure释放
647647
std::shared_ptr<ReadChunkRequest> readRequest
648648
= GenerateReadRequest(CHUNK_OP_TYPE::CHUNK_OP_RECOVER, offset, length); //NOLINT
649-
char cloneData[length]= {0};
649+
char cloneData[length]; // NOLINT
650650
memset(cloneData, 'b', length);
651651
EXPECT_CALL(*copyer_, DownloadAsync(_))
652652
.WillOnce(Invoke([&](DownloadClosure* closure){
@@ -705,7 +705,7 @@ TEST_F(CloneCoreTest, DisablePasteTest) {
705705
// 每次调HandleReadRequest后会被closure释放
706706
std::shared_ptr<ReadChunkRequest> readRequest
707707
= GenerateReadRequest(CHUNK_OP_TYPE::CHUNK_OP_READ, offset, length);
708-
char cloneData[length]= {0};
708+
char cloneData[length]; // NOLINT
709709
memset(cloneData, 'b', length);
710710
EXPECT_CALL(*copyer_, DownloadAsync(_))
711711
.WillOnce(Invoke([&](DownloadClosure* closure){
@@ -744,7 +744,7 @@ TEST_F(CloneCoreTest, DisablePasteTest) {
744744
// 每次调HandleReadRequest后会被closure释放
745745
std::shared_ptr<ReadChunkRequest> readRequest
746746
= GenerateReadRequest(CHUNK_OP_TYPE::CHUNK_OP_RECOVER, offset, length); //NOLINT
747-
char cloneData[length]= {0};
747+
char cloneData[length]; // NOLINT
748748
memset(cloneData, 'b', length);
749749
EXPECT_CALL(*copyer_, DownloadAsync(_))
750750
.WillOnce(Invoke([&](DownloadClosure* closure){

0 commit comments

Comments
 (0)