Fix warnings

This commit is contained in:
badaix 2025-02-09 22:15:53 +01:00
parent f6b1e3f5d4
commit 6f03576270
16 changed files with 33 additions and 23 deletions

View file

@ -76,7 +76,7 @@ jobs:
mkdir -p build/doxygen mkdir -p build/doxygen
doxygen 2>&1 | tee build/doxygen.log doxygen 2>&1 | tee build/doxygen.log
WARNINGS=$(cat build/doxygen.log | sort | uniq | grep -e ": warning: " | wc -l) WARNINGS=$(cat build/doxygen.log | sort | uniq | grep -e ": warning: " | wc -l)
MAX_ALLOWED=437 MAX_ALLOWED=431
echo "Doxygen finished with $WARNINGS warnings, max allowed: $MAX_ALLOWED" echo "Doxygen finished with $WARNINGS warnings, max allowed: $MAX_ALLOWED"
if [ "$WARNINGS" -gt "$MAX_ALLOWED" ]; then exit $WARNINGS; else exit 0; fi; if [ "$WARNINGS" -gt "$MAX_ALLOWED" ]; then exit $WARNINGS; else exit 0; fi;

View file

@ -580,7 +580,7 @@ ssl_websocket& ClientConnectionWss::getWs()
// In this example we will simply print the certificate's subject name. // In this example we will simply print the certificate's subject name.
std::array<char, 256> subject_name; std::array<char, 256> subject_name;
X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle()); X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle());
X509_NAME_oneline(X509_get_subject_name(cert), subject_name.data(), subject_name.size()); X509_NAME_oneline(X509_get_subject_name(cert), subject_name.data(), static_cast<int>(subject_name.size()));
LOG(INFO, LOG_TAG) << "Verifying cert: '" << subject_name.data() << "', pre verified: " << preverified << "\n"; LOG(INFO, LOG_TAG) << "Verifying cert: '" << subject_name.data() << "', pre verified: " << preverified << "\n";
return preverified; return preverified;
@ -692,7 +692,7 @@ boost::system::error_code ClientConnectionWss::doConnect(boost::asio::ip::basic_
if (!SSL_set_tlsext_host_name(getWs().next_layer().native_handle(), server_.host.c_str())) if (!SSL_set_tlsext_host_name(getWs().next_layer().native_handle(), server_.host.c_str()))
{ {
LOG(ERROR, LOG_TAG) << "Failed to set SNI Hostname\n"; LOG(ERROR, LOG_TAG) << "Failed to set SNI Hostname\n";
return boost::system::error_code(static_cast<int>(::ERR_get_error()), boost::asio::error::get_ssl_category()); return {static_cast<int>(::ERR_get_error()), boost::asio::error::get_ssl_category()};
} }
// Perform the SSL handshake // Perform the SSL handshake

View file

@ -25,9 +25,13 @@
*/ */
// prototype/interface header file
#include "base64.h" #include "base64.h"
// standard headers
#include <algorithm> #include <algorithm>
#include <array>
static std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" static std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
@ -43,8 +47,8 @@ std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len)
{ {
std::string ret; std::string ret;
int i = 0; int i = 0;
unsigned char char_array_3[3]; std::array<unsigned char, 3> char_array_3;
unsigned char char_array_4[4]; std::array<unsigned char, 4> char_array_4;
while ((in_len--) != 0u) while ((in_len--) != 0u)
{ {
@ -93,7 +97,8 @@ std::string base64_decode(const std::string& encoded_string)
size_t in_len = encoded_string.size(); size_t in_len = encoded_string.size();
int i = 0; int i = 0;
int in_ = 0; int in_ = 0;
unsigned char char_array_4[4], char_array_3[3]; std::array<unsigned char, 4> char_array_4;
std::array<unsigned char, 3> char_array_3;
std::string ret; std::string ret;
while (((in_len--) != 0) && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) while (((in_len--) != 0) && (encoded_string[in_] != '=') && is_base64(encoded_string[in_]))

View file

@ -18,8 +18,10 @@
#pragma once #pragma once
// standard headers
#include <string> #include <string>
std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len); std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len);
std::string base64_encode(const std::string& text); std::string base64_encode(const std::string& text);
std::string base64_decode(const std::string& encoded_string); std::string base64_decode(const std::string& encoded_string);

View file

@ -109,6 +109,7 @@ std::string trim_copy(const std::string& s)
std::string urlEncode(const std::string& str) std::string urlEncode(const std::string& str)
{ {
std::ostringstream os; std::ostringstream os;
// NOLINTNEXTLINE
for (std::string::const_iterator ci = str.begin(); ci != str.end(); ++ci) for (std::string::const_iterator ci = str.begin(); ci != str.end(); ++ci)
{ {
if ((*ci >= 'a' && *ci <= 'z') || (*ci >= 'A' && *ci <= 'Z') || (*ci >= '0' && *ci <= '9')) if ((*ci >= 'a' && *ci <= 'z') || (*ci >= 'A' && *ci <= 'Z') || (*ci >= '0' && *ci <= '9'))

View file

@ -94,7 +94,7 @@ const std::error_category& category()
std::error_code make_error_code(AuthErrc errc) std::error_code make_error_code(AuthErrc errc)
{ {
return std::error_code(static_cast<int>(errc), snapcast::error::auth::category()); return {static_cast<int>(errc), snapcast::error::auth::category()};
} }

View file

@ -49,7 +49,7 @@ static void checkParams(const jsonrpcpp::request_ptr& request, const std::vector
} }
Request::Request(const Server& server, const std::string& method) : server_(server), method_(method) Request::Request(const Server& server, std::string method) : server_(server), method_(std::move(method))
{ {
} }

View file

@ -46,7 +46,7 @@ public:
Request() = delete; Request() = delete;
/// c'tor /// c'tor
explicit Request(const Server& server, const std::string& method); explicit Request(const Server& server, std::string method);
/// d'tor /// d'tor
virtual ~Request() = default; virtual ~Request() = default;

View file

@ -1,6 +1,6 @@
/*** /***
This file is part of snapcast This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl Copyright (C) 2014-2025 Johannes Pohl
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -146,6 +146,7 @@ void FlacEncoder::encode(const msg::PcmChunk& chunk)
} }
// NOLINTNEXTLINE
FLAC__StreamEncoderWriteStatus FlacEncoder::write_callback(const FLAC__StreamEncoder* /*encoder*/, const FLAC__byte buffer[], size_t bytes, unsigned samples, FLAC__StreamEncoderWriteStatus FlacEncoder::write_callback(const FLAC__StreamEncoder* /*encoder*/, const FLAC__byte buffer[], size_t bytes, unsigned samples,
unsigned current_frame) unsigned current_frame)
{ {
@ -168,6 +169,7 @@ FLAC__StreamEncoderWriteStatus FlacEncoder::write_callback(const FLAC__StreamEnc
namespace callback namespace callback
{ {
// NOLINTNEXTLINE
FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder* encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder* encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples,
unsigned current_frame, void* client_data) unsigned current_frame, void* client_data)
{ {

View file

@ -46,8 +46,8 @@ static constexpr auto LOG_TAG = "Server";
Server::Server(boost::asio::io_context& io_context, const ServerSettings& serverSettings) Server::Server(boost::asio::io_context& io_context, ServerSettings serverSettings)
: io_context_(io_context), config_timer_(io_context), settings_(serverSettings), request_factory_(*this) : io_context_(io_context), config_timer_(io_context), settings_(std::move(serverSettings)), request_factory_(*this)
{ {
} }

View file

@ -54,7 +54,7 @@ class Server : public StreamMessageReceiver, public ControlMessageReceiver, publ
public: public:
/// c'tor /// c'tor
Server(boost::asio::io_context& io_context, const ServerSettings& serverSettings); Server(boost::asio::io_context& io_context, ServerSettings serverSettings);
/// d'tor /// d'tor
virtual ~Server() = default; virtual ~Server() = default;

View file

@ -57,14 +57,14 @@ void StreamServer::cleanup()
} }
void StreamServer::addSession(std::shared_ptr<StreamSession> session) void StreamServer::addSession(const std::shared_ptr<StreamSession>& session)
{ {
session->setMessageReceiver(this); session->setMessageReceiver(this);
session->setBufferMs(settings_.stream.bufferMs); session->setBufferMs(settings_.stream.bufferMs);
session->start(); session->start();
std::lock_guard<std::recursive_mutex> mlock(sessionsMutex_); std::lock_guard<std::recursive_mutex> mlock(sessionsMutex_);
sessions_.emplace_back(std::move(session)); sessions_.emplace_back(session);
cleanup(); cleanup();
} }

View file

@ -67,7 +67,7 @@ public:
// void send(const msg::BaseMessage* message); // void send(const msg::BaseMessage* message);
/// Add a new stream session /// Add a new stream session
void addSession(std::shared_ptr<StreamSession> session); void addSession(const std::shared_ptr<StreamSession>& session);
/// Callback for chunks that are ready to be sent /// Callback for chunks that are ready to be sent
void onChunkEncoded(const PcmStream* pcmStream, bool isDefaultStream, const std::shared_ptr<msg::PcmChunk>& chunk, double duration); void onChunkEncoded(const PcmStream* pcmStream, bool isDefaultStream, const std::shared_ptr<msg::PcmChunk>& chunk, double duration);

View file

@ -1,6 +1,6 @@
/*** /***
This file is part of snapcast This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl Copyright (C) 2014-2025 Johannes Pohl
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -87,5 +87,5 @@ const std::error_category& category()
std::error_code make_error_code(ControlErrc errc) std::error_code make_error_code(ControlErrc errc)
{ {
return std::error_code(static_cast<int>(errc), snapcast::error::control::category()); return {static_cast<int>(errc), snapcast::error::control::category()};
} }

View file

@ -1,6 +1,6 @@
/*** /***
This file is part of snapcast This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl Copyright (C) 2014-2025 Johannes Pohl
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -46,9 +46,9 @@ using namespace std;
namespace streamreader namespace streamreader
{ {
StreamManager::StreamManager(PcmStream::Listener* pcmListener, boost::asio::io_context& ioc, const ServerSettings& settings) StreamManager::StreamManager(PcmStream::Listener* pcmListener, boost::asio::io_context& ioc, ServerSettings settings)
// const std::string& defaultSampleFormat, const std::string& defaultCodec, size_t defaultChunkBufferMs) // const std::string& defaultSampleFormat, const std::string& defaultCodec, size_t defaultChunkBufferMs)
: pcmListener_(pcmListener), settings_(settings), io_context_(ioc) : pcmListener_(pcmListener), settings_(std::move(settings)), io_context_(ioc)
{ {
} }

View file

@ -1,6 +1,6 @@
/*** /***
This file is part of snapcast This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl Copyright (C) 2014-2025 Johannes Pohl
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -42,7 +42,7 @@ class StreamManager
{ {
public: public:
/// C'tor /// C'tor
StreamManager(PcmStream::Listener* pcmListener, boost::asio::io_context& ioc, const ServerSettings& settings); StreamManager(PcmStream::Listener* pcmListener, boost::asio::io_context& ioc, ServerSettings settings);
/// Construct and add a stream from @p uri /// Construct and add a stream from @p uri
/// @return the created stream /// @return the created stream