summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamroot.jam1
-rw-r--r--libadhocutil/ctf-impl/printf-compat.h2
-rw-r--r--libadhocutil/curlHandle.cpp21
-rw-r--r--libadhocutil/curlHandle.h20
-rw-r--r--libadhocutil/curlStream.cpp2
-rw-r--r--libadhocutil/fileUtils.h2
-rw-r--r--libadhocutil/lexer-regex.h7
-rw-r--r--libadhocutil/lexer.h3
-rw-r--r--libadhocutil/nagios.cpp3
-rw-r--r--libadhocutil/nvpParse.ll1
-rw-r--r--libadhocutil/processPipes.cpp2
-rw-r--r--libadhocutil/resourcePool.impl.h2
-rw-r--r--libadhocutil/runtimeContext.cpp2
-rw-r--r--libadhocutil/unittests/Jamfile.jam1
-rw-r--r--libadhocutil/unittests/testCompileTimeFormatter.cpp7
-rw-r--r--libadhocutil/unittests/testLazyPointer.cpp4
-rw-r--r--libadhocutil/unittests/testLexer.cpp7
17 files changed, 36 insertions, 51 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 5e9bc15..527b990 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -17,6 +17,7 @@ project
<variant>release:<lto>on
<variant>debug:<warnings>extra
<variant>debug:<warnings-as-errors>on
+ <variant>debug:<cflags>-Wold-style-cast
<variant>coverage:<coverage>on
<toolset>tidy:<exclude>bin/sys.h
<toolset>tidy:<exclude>bin/net.h
diff --git a/libadhocutil/ctf-impl/printf-compat.h b/libadhocutil/ctf-impl/printf-compat.h
index 33223bf..f05ba30 100644
--- a/libadhocutil/ctf-impl/printf-compat.h
+++ b/libadhocutil/ctf-impl/printf-compat.h
@@ -73,7 +73,7 @@ namespace AdHoc {
static inline void
write(stream & s, Obj * const ptr, const Pn &... pn)
{
- s << std::showbase << std::hex << (long unsigned int)ptr;
+ s << std::showbase << std::hex << reinterpret_cast<long unsigned int>(ptr);
s.copyfmt(std::ios(nullptr));
StreamWriter::next(s, pn...);
}
diff --git a/libadhocutil/curlHandle.cpp b/libadhocutil/curlHandle.cpp
index b37b725..1df5f12 100644
--- a/libadhocutil/curlHandle.cpp
+++ b/libadhocutil/curlHandle.cpp
@@ -31,27 +31,6 @@ namespace AdHoc::Net {
curl_easy_cleanup(curl_handle);
}
- template<>
- void
- CurlHandle::setopt(CURLoption opt, const void * val)
- {
- curl_easy_setopt(curl_handle, opt, val);
- }
-
- template<>
- void
- CurlHandle::setopt(CURLoption opt, int val)
- {
- curl_easy_setopt(curl_handle, opt, val);
- }
-
- template<>
- void
- CurlHandle::setopt(CURLoption opt, long val)
- {
- curl_easy_setopt(curl_handle, opt, val);
- }
-
void
CurlHandle::getinfo(CURLINFO info, long & val) const
{
diff --git a/libadhocutil/curlHandle.h b/libadhocutil/curlHandle.h
index 6169ec1..1501080 100644
--- a/libadhocutil/curlHandle.h
+++ b/libadhocutil/curlHandle.h
@@ -24,7 +24,12 @@ namespace AdHoc {
virtual ~CurlHandle();
/** Set option wrapper. */
- template<typename T> void setopt(CURLoption opt, const T val);
+ template<typename T>
+ void
+ setopt(CURLoption opt, const T & val)
+ {
+ curl_easy_setopt(curl_handle, opt, val);
+ }
/** Get info for long values */
void getinfo(CURLINFO info, long & val) const;
/** Get info for int values (avoids ambiguous call errors for ease of use) */
@@ -54,19 +59,6 @@ namespace AdHoc {
/// @endcond
};
using CurlHandlePtr = std::shared_ptr<CurlHandle>;
-
- /// @cond
- template<> void CurlHandle::setopt(CURLoption opt, const void * val);
- template<> void CurlHandle::setopt(CURLoption opt, int val);
- template<> void CurlHandle::setopt(CURLoption opt, long val);
- template<typename T>
- void
- CurlHandle::setopt(CURLoption opt, const T val)
- {
- setopt(opt, (const void *)val);
- }
- /// @endcond
-
}
}
diff --git a/libadhocutil/curlStream.cpp b/libadhocutil/curlStream.cpp
index 3572136..be7f162 100644
--- a/libadhocutil/curlStream.cpp
+++ b/libadhocutil/curlStream.cpp
@@ -48,7 +48,7 @@ namespace AdHoc::Net {
size_t
CurlStreamSource::recv(void * data, size_t datalen)
{
- buf = (char *)data;
+ buf = static_cast<char *>(data);
buflen = datalen;
swapContext();
return datalen;
diff --git a/libadhocutil/fileUtils.h b/libadhocutil/fileUtils.h
index fd6ddf2..59bc41e 100644
--- a/libadhocutil/fileUtils.h
+++ b/libadhocutil/fileUtils.h
@@ -169,7 +169,7 @@ namespace AdHoc {
[[nodiscard]] auto
sv() const
{
- return std::basic_string_view<T>((const T *)data, st.st_size / sizeof(T));
+ return std::basic_string_view<T>(static_cast<const T *>(data), st.st_size / sizeof(T));
}
#endif
diff --git a/libadhocutil/lexer-regex.h b/libadhocutil/lexer-regex.h
index 2a087a3..33dbc77 100644
--- a/libadhocutil/lexer-regex.h
+++ b/libadhocutil/lexer-regex.h
@@ -1,10 +1,13 @@
#ifndef ADHOCUTIL_LEXER_REGEX_H
#define ADHOCUTIL_LEXER_REGEX_H
-#include "glibmm/ustring.h"
#include "lexer.h" // IWYU pragma: export
#include "visibility.h"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <glib.h>
+#include <glibmm/ustring.h>
+#pragma GCC diagnostic pop
namespace AdHoc {
namespace LexerMatchers {
@@ -16,7 +19,7 @@ namespace AdHoc {
* @return Pointer to the newly created pattern matcher.
*/
DLL_PUBLIC Lexer::PatternPtr regex(const Glib::ustring & regex,
- GRegexCompileFlags compile = (GRegexCompileFlags)0, GRegexMatchFlags match = (GRegexMatchFlags)0);
+ GRegexCompileFlags compile = GRegexCompileFlags {}, GRegexMatchFlags match = GRegexMatchFlags {});
}
};
diff --git a/libadhocutil/lexer.h b/libadhocutil/lexer.h
index 00c1d69..ea1718d 100644
--- a/libadhocutil/lexer.h
+++ b/libadhocutil/lexer.h
@@ -5,7 +5,10 @@
#include "visibility.h"
#include <cstddef>
#include <functional>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <glib.h>
+#pragma GCC diagnostic pop
#include <memory>
#include <optional>
#include <set>
diff --git a/libadhocutil/nagios.cpp b/libadhocutil/nagios.cpp
index 6c1b095..4350c35 100644
--- a/libadhocutil/nagios.cpp
+++ b/libadhocutil/nagios.cpp
@@ -27,7 +27,8 @@ namespace AdHoc {
struct utsname buf {
};
uname(&buf);
- NagiosPassiveServiceCheck::write(command_file, time(nullptr), buf.nodename, svc, (uint8_t)code, output);
+ NagiosPassiveServiceCheck::write(
+ command_file, time(nullptr), buf.nodename, svc, static_cast<uint8_t>(code), output);
command_file.flush();
}
return command_file.good();
diff --git a/libadhocutil/nvpParse.ll b/libadhocutil/nvpParse.ll
index cc3a0e8..9e8b87c 100644
--- a/libadhocutil/nvpParse.ll
+++ b/libadhocutil/nvpParse.ll
@@ -10,6 +10,7 @@
#include "nvpParse.h"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#if __clang__
#pragma GCC diagnostic ignored "-Wnull-conversion"
#endif
diff --git a/libadhocutil/processPipes.cpp b/libadhocutil/processPipes.cpp
index cc0b017..e50d0f1 100644
--- a/libadhocutil/processPipes.cpp
+++ b/libadhocutil/processPipes.cpp
@@ -134,7 +134,7 @@ namespace AdHoc::System {
getrlimit(RLIMIT_NOFILE, &lim);
std::vector<struct pollfd> fds;
fds.reserve(lim.rlim_max);
- for (int n = 3; n < (int)lim.rlim_max; n += 1) {
+ for (int n = 3; n < static_cast<int>(lim.rlim_max); n += 1) {
fds.push_back({n, 0, 0});
}
poll(&fds.front(), fds.size(), 0);
diff --git a/libadhocutil/resourcePool.impl.h b/libadhocutil/resourcePool.impl.h
index 9fb9d3a..fe77857 100644
--- a/libadhocutil/resourcePool.impl.h
+++ b/libadhocutil/resourcePool.impl.h
@@ -48,7 +48,7 @@ namespace AdHoc {
template<typename R> ResourceHandle<R>::operator bool() const noexcept
{
- return (bool)resource;
+ return resource.operator bool();
}
template<typename R>
diff --git a/libadhocutil/runtimeContext.cpp b/libadhocutil/runtimeContext.cpp
index 9eeee0d..9ac7cea 100644
--- a/libadhocutil/runtimeContext.cpp
+++ b/libadhocutil/runtimeContext.cpp
@@ -13,7 +13,7 @@ namespace AdHoc::System {
ctxCallback.uc_stack.ss_sp = &stack.front();
ctxCallback.uc_stack.ss_size = stacksize;
ctxCallback.uc_link = &ctxInitial;
- makecontext(&ctxCallback, (void (*)()) & RuntimeContext::callbackWrapper, 1, this);
+ makecontext(&ctxCallback, reinterpret_cast<void (*)()>(&RuntimeContext::callbackWrapper), 1, this);
}
void
diff --git a/libadhocutil/unittests/Jamfile.jam b/libadhocutil/unittests/Jamfile.jam
index 5ca476d..926c4cc 100644
--- a/libadhocutil/unittests/Jamfile.jam
+++ b/libadhocutil/unittests/Jamfile.jam
@@ -83,6 +83,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
<library>boost_utf
+ <library>..//curl
<library>stdc++fs
<implicit-dependency>..//adhocutil
:
diff --git a/libadhocutil/unittests/testCompileTimeFormatter.cpp b/libadhocutil/unittests/testCompileTimeFormatter.cpp
index 885a961..ce782fc 100644
--- a/libadhocutil/unittests/testCompileTimeFormatter.cpp
+++ b/libadhocutil/unittests/testCompileTimeFormatter.cpp
@@ -383,8 +383,8 @@ GLIBC_FMT_TEST(d051, "in %05d.", 123);
GLIBC_FMT_TEST(d0511, "in % 50d.", 123);
GLIBC_FMT_TEST(d05121, "in %0510d.", 123);
GLIBC_FMT_TEST(d2, "in %d.", 123456);
-GLIBC_FMT_TEST(d3, "in %hd.", (int16_t)-12345);
-GLIBC_FMT_TEST(d4, "in %hhd.", (int8_t)-123);
+GLIBC_FMT_TEST(d3, "in %hd.", static_cast<int16_t>(-12345));
+GLIBC_FMT_TEST(d4, "in %hhd.", static_cast<int8_t>(-123));
GLIBC_FMT_TEST(d5, "in %ld.", -123456L);
GLIBC_FMT_TEST(d6, "in %lld.", -123456LL);
GLIBC_FMT_TEST(i1, "in %i.", 123);
@@ -439,7 +439,8 @@ GLIBC_FMT_TEST(g6, "in %G.", -123.456789);
GLIBC_FMT_TEST(g7, "in %g.", 123456789.123);
GLIBC_FMT_TEST(g8, "in %g.", -123456789.123);
-GLIBC_FMT_TEST(fmtlibt_fmt, "%0.10f:%04d:%+g:%s:%p:%c:%%\n", 1.234, 42, 3.13, "str", (void *)1000, (int)'X');
+GLIBC_FMT_TEST(fmtlibt_fmt, "%0.10f:%04d:%+g:%s:%p:%c:%%\n", 1.234, 42, 3.13, "str", reinterpret_cast<void *>(1000),
+ static_cast<int>('X'));
AdHocFormatter(chars_written_fmt, "%n %s %n %d %n");
BOOST_AUTO_TEST_CASE(chars_written)
diff --git a/libadhocutil/unittests/testLazyPointer.cpp b/libadhocutil/unittests/testLazyPointer.cpp
index 48f0285..f2440bd 100644
--- a/libadhocutil/unittests/testLazyPointer.cpp
+++ b/libadhocutil/unittests/testLazyPointer.cpp
@@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(rawPointerNonNull)
BOOST_REQUIRE(value);
BOOST_REQUIRE(value.get());
BOOST_REQUIRE_EQUAL(*value, 3);
- int * x = (int *)value;
+ int * x = value.operator int *();
BOOST_REQUIRE_EQUAL(*x, 3);
delete x;
}
@@ -119,5 +119,5 @@ BOOST_AUTO_TEST_CASE(rawPointerFactory)
BOOST_REQUIRE(!value.hasValue());
BOOST_REQUIRE_EQUAL(*value, 4);
BOOST_REQUIRE(value.hasValue());
- delete (int *)value;
+ delete value.operator int *();
}
diff --git a/libadhocutil/unittests/testLexer.cpp b/libadhocutil/unittests/testLexer.cpp
index 28f98cb..6267dda 100644
--- a/libadhocutil/unittests/testLexer.cpp
+++ b/libadhocutil/unittests/testLexer.cpp
@@ -1,9 +1,12 @@
#define BOOST_TEST_MODULE Lexer
#include <boost/test/unit_test.hpp>
-#include "glibmm/ustring.h"
#include <functional>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <glib.h>
+#include <glibmm/ustring.h>
+#pragma GCC diagnostic pop
#include <lexer-regex.h>
#include <memory>
#include <optional>
@@ -79,7 +82,7 @@ BOOST_AUTO_TEST_CASE(multibyte)
AdHoc::Lexer::PatternPtr maskHead
= AdHoc::LexerMatchers::regex("^# ([^<\n]+)? ?(<(.+?@[^\n>]+)>?)? \\((\\d+ "
"*(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\\w* \\d+)\\)$",
- (GRegexCompileFlags)(G_REGEX_OPTIMIZE | G_REGEX_CASELESS | G_REGEX_UNGREEDY));
+ GRegexCompileFlags(G_REGEX_OPTIMIZE | G_REGEX_CASELESS | G_REGEX_UNGREEDY));
Glib::ustring input("# Michał Górny <mgorny@gentoo.org> (28 Mar 2015)");
BOOST_REQUIRE_GT(input.bytes(), input.length());
BOOST_REQUIRE(maskHead->matches(input.c_str(), input.bytes(), 0));