Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor build errors, such as unnecessary copies from range enumeration. #775

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ stamp-h1
**/.deps/
**/.libs/
**/Makefile
aminclude_static.am

# Executables #
###############
Expand All @@ -66,3 +67,7 @@ sonic-db-cli/sonic-db-cli

# Bazel Build System #
/bazel-*

# Unit test generated files #
#############################
ut_dump_file.txt
r12f marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion common/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ EventSubscriber::init(bool use_cache, int recv_timeout,
RET_ON_ERR(rc == 0, "Fails to set option rc=%d", rc);
}
else {
for (const auto e: *subs_sources) {
for (const auto &e: *subs_sources) {
rc = zmq_setsockopt(sock, ZMQ_SUBSCRIBE, e.c_str(), e.size());
RET_ON_ERR(rc == 0, "Fails to set option rc=%d", rc);
}
Expand Down
6 changes: 4 additions & 2 deletions tests/events_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ parse_read_evt(string &source, internal_event_t &evt,
EXPECT_FALSE(source.empty());
EXPECT_EQ(4, evt.size());

for (const auto e: evt) {
for (const auto &e: evt) {
if (e.first == EVENT_STR_DATA) {
EXPECT_EQ(0, convert_from_json(e.second, key, params));
// cout << "EVENT_STR_DATA: " << e.second << "\n";
Expand Down Expand Up @@ -344,6 +344,7 @@ internal_event_t create_ev(const test_data_t &data)

event_data[EVENT_RUNTIME_ID] = data.rid;
event_data[EVENT_SEQUENCE] = data.seq;
event_data[EVENT_EPOCH] = "1";

return event_data;
}
Expand Down Expand Up @@ -590,7 +591,8 @@ void do_test_subscribe(bool wrap)
hsub = events_init_subscriber_wrap(true, 100);
}
else {
hsub = events_init_subscriber(true, 100);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

events_init_subscriber

You do not mention the reason of this change anywhere. Seems like it is not necessary.

std::vector<std::string> sources = {""};
hsub = events_init_subscriber(true, 100, &sources);
}
EXPECT_TRUE(NULL != hsub);
EXPECT_EQ(last_svc_code, EVENT_CACHE_STOP);
Expand Down
2 changes: 1 addition & 1 deletion tests/stringutility_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ TEST(STRINGUTILITY, join)

TEST(STRINGUTILITY, hex_to_binary)
{
std::array<std::uint8_t, 5> a;
std::array<std::uint8_t, 5> a = {0};

EXPECT_TRUE(swss::hex_to_binary("01020aff05", a.data(), a.size()));
EXPECT_EQ(a, (std::array<std::uint8_t, 5>{0x1, 0x2, 0x0a, 0xff, 0x5}));
Expand Down