Skip to content

Commit e27a269

Browse files
committed
Fix several minor issues reported by GCC 7.2 and Clang
1 parent cab8270 commit e27a269

10 files changed

+22
-18
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ project(utxx VERSION 1.4.1)
55
#===============================================================================
66
# CMAKE options customization
77
#===============================================================================
8-
option(WITH_THRIFT "Enable to compile UTXX with Thrift" ON)
8+
option(WITH_THRIFT "Enable to compile UTXX with Thrift" OFF)
99
option(VERBOSE "Turn verbosity on|off" OFF)
1010
option(WITH_ENUM_SERIALIZATION "Turn enum serialization support on|off" OFF)
1111

@@ -164,7 +164,7 @@ set(Boost_USE_MULTITHREAD ON)
164164
set(Boost_NO_SYSTEM_PATHS ON)
165165
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build")
166166

167-
find_package(Boost 1.55.0 REQUIRED COMPONENTS
167+
find_package(Boost 1.58.0 REQUIRED COMPONENTS
168168
system filesystem date_time program_options thread regex
169169
unit_test_framework timer)
170170

config.h.in

+4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
#cmakedefine UTXX_HAVE_THRIFT_H
99

1010
// This is needed for Thrift:
11+
#ifndef HAVE_INTTYPES_H
1112
#cmakedefine HAVE_INTTYPES_H
13+
#endif
14+
#ifndef HAVE_NETINET_IN_H
1215
#cmakedefine HAVE_NETINET_IN_H
16+
#endif
1317

1418
// Define to 1 if enum.h and enumx.h should be friends of boost::serialization::access
1519
#cmakedefine UTXX_ENUM_SUPPORT_SERIALIZATION

include/utxx/bitmap.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class bitmap_high: protected bitmap_low<sizeof(long)*8, T> {
200200
std::ostream& print(std::ostream& out, const char* sep = "\n") const {
201201
std::stringstream s;
202202
for(int i=s_hi_dim-1; i >= 0; --i) {
203-
char buf[9];
203+
char buf[24];
204204
if (i != s_lo_dim-1 && (i+1)%8 != 0 && i != s_hi_dim-1) s << '-';
205205
if ((i+1)%8 == 0 || (s_hi_dim < 8 && i == (s_hi_dim-1))) {
206206
sprintf(buf, "%s%02d: ", sep, i+1);

include/utxx/delegate/event.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ namespace utxx
116116
TSink sink;
117117

118118
wrapper(int a_id, TSink a_sink) : id(a_id), sink(a_sink) {}
119-
void operator==(const wrapper& a_rhs) const { return id == a_rhs.id; }
119+
bool operator==(const wrapper& a_rhs) const { return id == a_rhs.id; }
120120
};
121121

122122
typedef std::list<wrapper> sink_list_type;

include/utxx/stream_io.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ bool read_values(std::istream& in, T* a_output, int* a_fields, int a_cnt,
109109
}
110110

111111
struct indent_t {
112-
indent_t(size_t a_level = 0) : m_level(a_level) {}
112+
indent_t(int a_level = 0) : m_level(a_level) {}
113113

114-
size_t level() const { return m_level; }
114+
int level() const { return m_level; }
115115
private:
116-
size_t m_level;
116+
int m_level;
117117
};
118118

119119
template <typename Stream = std::stringstream>
@@ -123,7 +123,7 @@ class indented_stream : public Stream {
123123
: m_level(0), m_indent_width(a_indent_width)
124124
{}
125125

126-
size_t level() const { return m_level; }
126+
int level() const { return m_level; }
127127
size_t indent_width() const { return m_indent_width; }
128128
void indent_width(size_t a_width) { m_indent_width = a_width; }
129129

@@ -150,8 +150,8 @@ class indented_stream : public Stream {
150150
indented_stream& operator<<(const T& t) { *((Stream*)this) << t; return *this; }
151151

152152
private:
153-
size_t m_level;
153+
int m_level;
154154
size_t m_indent_width;
155155
};
156156

157-
} // namespace utxx
157+
} // namespace utxx

include/utxx/test_helper.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,4 @@ template <class T> void dont_optimize_var(T&& v) { v = v; }
9696
template <class T> void dont_optimize_var(T&& v) { asm volatile("":"+r" (v)); }
9797
#endif
9898

99-
} // namespace utxx::test
99+
} // namespace utxx::test

src/config_validator.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,15 @@ void validator::validate
294294
void validator::internal_fill_fallback_defaults
295295
(stack_t& stack, option_map& a_scope, std::string const& a_def_branch)
296296
{
297-
auto thrower = [&, this](std::string const& a_opt, std::string const& a_path, int n) {
297+
auto thrower = [&](std::string const& a_opt, std::string const& a_path, int n) {
298298
auto joiner = [](auto& pair){ return pair.first; };
299299
auto path = join(stack, string("/"), joiner) + a_opt;
300300
throw runtime_error("Config option '", path,
301301
"' has invalid 'defaults' fallback branch (ref",
302302
n, "): ", a_path);
303303
};
304304

305-
auto get_def_branch = [&, this](std::string const& a_path, const option_map& a_scope) {
305+
auto get_def_branch = [&](std::string const& a_path, const option_map& a_scope) {
306306
const option* res = nullptr;
307307
if (a_path.empty()) return res;
308308

@@ -967,4 +967,4 @@ bool validator::has_required_child_options
967967

968968

969969
} // namespace config
970-
} // namespace utxx
970+
} // namespace utxx

test/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ XML_CFG(TEST_SRCS test_config_validator2.xml)
8989

9090
# This must be AFTER link_directories
9191
add_executable(test_utxx ${TEST_SRCS})
92-
target_compile_definitions(test_utxx PRIVATE -DBOOST_TEST_DYN_LINK)
92+
target_compile_definitions(test_utxx PRIVATE -DBOOST_ALL_DYN_LINK)
9393
target_include_directories(test_utxx PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
9494
target_link_libraries(
9595
test_utxx

test/test_thread_local.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE( test_thread_local_access_all_threads_counter ) {
245245
std::atomic<int> totalAtomic(0);
246246
std::vector<std::thread> threads;
247247
for (int i = 0; i < kNumThreads; ++i)
248-
threads.push_back(std::thread([&,i]() {
248+
threads.push_back(std::thread([&]() {
249249
stci.add(1);
250250
totalAtomic.fetch_add(1);
251251
while (run.load()) { usleep(100); }

test/test_timestamp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,15 @@ BOOST_AUTO_TEST_CASE( test_timestamp_format )
284284
auto v = timestamp::to_string(nsecs(1466441912363349876), utxx::DATE_TIME_WITH_NSEC, false, true);
285285
BOOST_CHECK_EQUAL("20160620-12:58:32.363349876", v);
286286

287-
sprintf(expected, "%d%02d%02d-%02d:%02d:%02d",
287+
sprintf(expected, "%d%02d%02d-%02ld:%02ld:%02ld",
288288
(unsigned short) now_local.date().year(),
289289
(unsigned short) now_local.date().month(),
290290
(unsigned short) now_local.date().day(),
291291
now_local.time_of_day().hours(),
292292
now_local.time_of_day().minutes(),
293293
now_local.time_of_day().seconds());
294294

295-
sprintf(expected_utc, "%d%02d%02d-%02d:%02d:%02d",
295+
sprintf(expected_utc, "%d%02d%02d-%02ld:%02ld:%02ld",
296296
(unsigned short) now_utc.date().year(),
297297
(unsigned short) now_utc.date().month(),
298298
(unsigned short) now_utc.date().day(),

0 commit comments

Comments
 (0)