Skip to content

Commit ed90141

Browse files
authored
Merge pull request #10609 from Icinga/fix-misc-compiler-warnings
Fix misc compiler warnings
2 parents 9e6df06 + 11e83b6 commit ed90141

25 files changed

+77
-105
lines changed

lib/base/application.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Application : public ObjectImpl<Application> {
119119

120120
virtual void OnShutdown();
121121

122-
void ValidateName(const Lazy<String>& lvalue, const ValidationUtils& utils) final;
122+
void ValidateName(const Lazy<String>& lvalue, const ValidationUtils& utils) override final;
123123

124124
private:
125125
static Application::Ptr m_Instance; /**< The application instance. */

lib/base/debug.hpp

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,17 @@
88
#ifndef I2_DEBUG
99
# define ASSERT(expr) ((void)0)
1010
#else /* I2_DEBUG */
11-
# define ASSERT(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
11+
# define ASSERT(expr) ((expr) ? void(0) : icinga_assert_fail(#expr, __FILE__, __LINE__))
1212
#endif /* I2_DEBUG */
1313

14-
#define VERIFY(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
14+
#define VERIFY(expr) ((expr) ? void(0) : icinga_assert_fail(#expr, __FILE__, __LINE__))
1515

16-
#ifdef _MSC_VER
17-
# define NORETURNPRE __declspec(noreturn)
18-
#else /* _MSC_VER */
19-
# define NORETURNPRE
20-
#endif /* _MSC_VER */
16+
#define ABORT(expr) icinga_assert_fail(#expr, __FILE__, __LINE__)
2117

22-
#ifdef __GNUC__
23-
# define NORETURNPOST __attribute__((noreturn))
24-
#else /* __GNUC__ */
25-
# define NORETURNPOST
26-
#endif /* __GNUC__ */
27-
28-
NORETURNPRE int icinga_assert_fail(const char *expr, const char *file, int line) NORETURNPOST;
29-
30-
#ifdef _MSC_VER
31-
# pragma warning( push )
32-
# pragma warning( disable : 4646 ) /* function declared with __declspec(noreturn) has non-void return type */
33-
#endif /* _MSC_VER */
34-
35-
inline int icinga_assert_fail(const char *expr, const char *file, int line)
18+
[[noreturn]] inline void icinga_assert_fail(const char *expr, const char *file, int line) noexcept(true)
3619
{
3720
fprintf(stderr, "%s:%d: assertion failed: %s\n", file, line, expr);
3821
std::abort();
39-
40-
#if !defined(__GNUC__) && !defined(_MSC_VER)
41-
return 0;
42-
#endif /* !defined(__GNUC__) && !defined(_MSC_VER) */
4322
}
4423

45-
#ifdef _MSC_VER
46-
# pragma warning( pop )
47-
#endif /* _MSC_VER */
48-
4924
#endif /* DEBUG_H */

lib/base/exception.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ScriptError : virtual public user_error
3535
ScriptError(String message);
3636
ScriptError(String message, DebugInfo di, bool incompleteExpr = false);
3737

38-
const char *what(void) const throw() final;
38+
const char* what() const noexcept override final;
3939

4040
DebugInfo GetDebugInfo() const;
4141
bool IsIncompleteExpression() const;
@@ -59,7 +59,7 @@ class ValidationError : virtual public user_error
5959
ValidationError(const ConfigObject::Ptr& object, const std::vector<String>& attributePath, const String& message);
6060
~ValidationError() throw() override;
6161

62-
const char *what() const throw() override;
62+
const char *what() const noexcept override;
6363

6464
ConfigObject::Ptr GetObject() const;
6565
std::vector<String> GetAttributePath() const;
@@ -118,7 +118,7 @@ String DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose = tr
118118

119119
class posix_error : virtual public std::exception, virtual public boost::exception {
120120
public:
121-
const char* what() const noexcept final;
121+
const char* what() const noexcept override final;
122122

123123
private:
124124
mutable String m_Message;
@@ -153,7 +153,7 @@ class invalid_downtime_removal_error : virtual public std::exception, virtual pu
153153

154154
~invalid_downtime_removal_error() noexcept override;
155155

156-
const char *what() const noexcept final;
156+
const char* what() const noexcept override final;
157157

158158
private:
159159
String m_Message;

lib/base/io-engine.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ IoEngine::~IoEngine()
101101
boost::asio::post(m_IoContext, []() {
102102
throw TerminateIoThread();
103103
});
104-
}
105104

106-
for (auto& thread : m_Threads) {
107105
thread.join();
108106
}
109107
}

lib/base/logger.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Logger : public ObjectImpl<Logger>
8888
}
8989

9090
void SetSeverity(const String& value, bool suppress_events = false, const Value& cookie = Empty) override;
91-
void ValidateSeverity(const Lazy<String>& lvalue, const ValidationUtils& utils) final;
91+
void ValidateSeverity(const Lazy<String>& lvalue, const ValidationUtils& utils) override final;
9292

9393
protected:
9494
void Start(bool runtimeCreated) override;

lib/base/netstring.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ String NetString::ReadStringFromStream(const Shared<AsioTlsStream>::Ptr& stream,
167167
}
168168
}
169169

170-
if (maxMessageLength >= 0 && len > maxMessageLength) {
170+
if (maxMessageLength >= 0 && len > static_cast<std::size_t>(maxMessageLength)) {
171171
std::stringstream errorMessage;
172172
errorMessage << "Max data length exceeded: " << (maxMessageLength / 1024) << " KB";
173173

@@ -246,7 +246,7 @@ String NetString::ReadStringFromStream(const Shared<AsioTlsStream>::Ptr& stream,
246246
}
247247
}
248248

249-
if (maxMessageLength >= 0 && len > maxMessageLength) {
249+
if (maxMessageLength >= 0 && len > static_cast<std::size_t>(maxMessageLength)) {
250250
std::stringstream errorMessage;
251251
errorMessage << "Max data length exceeded: " << (maxMessageLength / 1024) << " KB";
252252

lib/base/object-packer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ static void PackAny(const Value& value, std::string& builder)
239239
*/
240240
String icinga::PackObject(const Value& value)
241241
{
242-
std::string builder;
243-
PackAny(value, builder);
242+
String builder;
243+
PackAny(value, builder.GetData());
244244

245245
return builder;
246246
}

lib/cli/clicommand.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,16 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
228228
typedef std::map<std::vector<String>, CLICommand::Ptr>::value_type CLIKeyValue;
229229

230230
std::vector<String> best_match;
231-
int arg_begin = 0;
232231
CLICommand::Ptr command;
233232

234233
for (const CLIKeyValue& kv : GetRegistry()) {
235234
const std::vector<String>& vname = kv.first;
236235

237-
arg_begin = 0;
238-
239236
std::vector<String>::size_type i;
240237
int k;
241238
for (i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
242239
if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0 || strcmp(argv[k], "--scm") == 0) {
243240
i--;
244-
arg_begin++;
245241
continue;
246242
}
247243

lib/config/configitem.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
444444
<< "Committing " << total << " new items.";
445445
#endif /* I2_DEBUG */
446446

447+
#ifdef I2_DEBUG
447448
int itemsCount {0};
449+
#endif /* I2_DEBUG */
448450

449451
for (auto& type : Type::GetConfigTypesSortedByLoadDependencies()) {
450452
std::atomic<int> committed_items(0);
@@ -475,9 +477,9 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
475477
}
476478
}
477479

480+
#ifdef I2_DEBUG
478481
itemsCount += committed_items;
479482

480-
#ifdef I2_DEBUG
481483
if (committed_items > 0)
482484
Log(LogDebug, "configitem")
483485
<< "Committed " << committed_items << " items of type '" << type->GetName() << "'.";

lib/config/expression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ ExpressionResult GetScopeExpression::DoEvaluate(ScriptFrame& frame, DebugHint *d
554554
else if (m_ScopeSpec == ScopeGlobal)
555555
return frame.GetGlobals();
556556
else
557-
VERIFY(!"Invalid scope.");
557+
ABORT("Invalid scope.");
558558
}
559559

560560
static inline

0 commit comments

Comments
 (0)