Address compiler warnings #10
All checks were successful
BlockStorage/repertory_osx_builds/pipeline/head This commit looks good
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good

This commit is contained in:
2023-11-08 19:53:12 -06:00
parent a7209184c8
commit f2c1f64f02
30 changed files with 737 additions and 615 deletions

View File

@ -32,9 +32,9 @@ class curl_comm final : public i_http_comm {
public:
curl_comm() = delete;
explicit curl_comm(host_config hc);
explicit curl_comm(host_config cfg);
explicit curl_comm(s3_config s3);
explicit curl_comm(s3_config cfg);
private:
using write_callback = size_t (*)(char *, size_t, size_t, void *);
@ -57,9 +57,10 @@ private:
public:
[[nodiscard]] static auto construct_url(CURL *curl,
const std::string &relative_path,
const host_config &hc) -> std::string;
const host_config &cfg)
-> std::string;
[[nodiscard]] static auto create_host_config(const s3_config &config,
[[nodiscard]] static auto create_host_config(const s3_config &cfg,
bool use_s3_path_style)
-> host_config;
@ -68,7 +69,7 @@ public:
template <typename request_type>
[[nodiscard]] static auto
make_encrypted_request(const host_config &hc, const request_type &request,
make_encrypted_request(const host_config &cfg, const request_type &request,
long &response_code, stop_type &stop_requested)
-> bool {
response_code = 0;
@ -102,7 +103,7 @@ public:
};
encrypted_request.total_size = std::nullopt;
if (not make_request(hc, encrypted_request, response_code,
if (not make_request(cfg, encrypted_request, response_code,
stop_requested)) {
return api_error::comm_error;
}
@ -127,11 +128,12 @@ public:
template <typename request_type>
[[nodiscard]] static auto
make_request(const host_config &hc, const request_type &request,
make_request(const host_config &cfg, const request_type &request,
long &response_code, stop_type &stop_requested) -> bool {
if (request.decryption_token.has_value() &&
not request.decryption_token.value().empty()) {
return make_encrypted_request(hc, request, response_code, stop_requested);
return make_encrypted_request(cfg, request, response_code,
stop_requested);
}
response_code = 0;
@ -141,12 +143,12 @@ public:
return false;
}
if (not hc.agent_string.empty()) {
curl_easy_setopt(curl, CURLOPT_USERAGENT, hc.agent_string.c_str());
if (not cfg.agent_string.empty()) {
curl_easy_setopt(curl, CURLOPT_USERAGENT, cfg.agent_string.c_str());
}
if (request.allow_timeout && hc.timeout_ms) {
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, hc.timeout_ms);
if (request.allow_timeout && cfg.timeout_ms) {
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, cfg.timeout_ms);
}
std::string range_list{};
@ -169,16 +171,16 @@ public:
}
std::string parameters{};
for (const auto &kv : request.query) {
parameters += (parameters.empty() ? '?' : '&') + kv.first + '=' +
url_encode(curl, kv.second, false);
for (const auto &param : request.query) {
parameters += (parameters.empty() ? '?' : '&') + param.first + '=' +
url_encode(curl, param.second, false);
}
if (not hc.api_password.empty()) {
curl_easy_setopt(curl, CURLOPT_USERNAME, hc.api_user.c_str());
curl_easy_setopt(curl, CURLOPT_PASSWORD, hc.api_password.c_str());
} else if (not hc.api_user.empty()) {
curl_easy_setopt(curl, CURLOPT_USERNAME, hc.api_user.c_str());
if (not cfg.api_password.empty()) {
curl_easy_setopt(curl, CURLOPT_USERNAME, cfg.api_user.c_str());
curl_easy_setopt(curl, CURLOPT_PASSWORD, cfg.api_password.c_str());
} else if (not cfg.api_user.empty()) {
curl_easy_setopt(curl, CURLOPT_USERNAME, cfg.api_user.c_str());
}
if (request.aws_service.has_value()) {
@ -186,7 +188,7 @@ public:
request.aws_service.value().c_str());
}
auto url = construct_url(curl, request.get_path(), hc) + parameters;
auto url = construct_url(curl, request.get_path(), cfg) + parameters;
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
multi_request curl_request(curl, stop_requested);

View File

@ -26,6 +26,11 @@
namespace repertory::curl::requests {
struct http_get final : http_request_base {
http_get() = default;
http_get(const http_get &) = default;
http_get(http_get &&) = default;
auto operator=(const http_get &) -> http_get & = default;
auto operator=(http_get &&) -> http_get & = default;
~http_get() override = default;
[[nodiscard]] auto set_method(CURL *curl,

View File

@ -39,17 +39,23 @@ struct read_file_info final {
inline const auto read_file_data = static_cast<read_callback>(
[](char *buffer, size_t size, size_t nitems, void *instream) -> size_t {
auto *rd = reinterpret_cast<read_file_info *>(instream);
auto *read_info = reinterpret_cast<read_file_info *>(instream);
std::size_t bytes_read{};
auto ret =
rd->nf->read_bytes(buffer, size * nitems, rd->offset, bytes_read);
auto ret = read_info->nf->read_bytes(buffer, size * nitems,
read_info->offset, bytes_read);
if (ret) {
rd->offset += bytes_read;
read_info->offset += bytes_read;
}
return ret && not rd->stop_requested ? bytes_read : CURL_READFUNC_ABORT;
return ret && not read_info->stop_requested ? bytes_read
: CURL_READFUNC_ABORT;
});
struct http_request_base {
http_request_base() = default;
http_request_base(const http_request_base &) = default;
http_request_base(http_request_base &&) = default;
auto operator=(const http_request_base &) -> http_request_base & = default;
auto operator=(http_request_base &&) -> http_request_base & = default;
virtual ~http_request_base() = default;
bool allow_timeout{};