summaryrefslogtreecommitdiff
path: root/src/other_tools/utils
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-04-08 13:18:22 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-04-08 15:19:50 +0200
commit277be6dd08633dbebfda93afdfc6b5cb57e053e0 (patch)
tree6c86157c7f93636459361264054753a1dc9d33e9 /src/other_tools/utils
parent419a458ad9d4383eb47d51fe8e4408a0e240c2f1 (diff)
downloadjustbuild-277be6dd08633dbebfda93afdfc6b5cb57e053e0.tar.gz
Use properly included standard library types by default
Diffstat (limited to 'src/other_tools/utils')
-rw-r--r--src/other_tools/utils/curl_easy_handle.cpp12
-rw-r--r--src/other_tools/utils/curl_easy_handle.hpp9
-rw-r--r--src/other_tools/utils/curl_url_handle.cpp16
-rw-r--r--src/other_tools/utils/curl_url_handle.hpp5
4 files changed, 23 insertions, 19 deletions
diff --git a/src/other_tools/utils/curl_easy_handle.cpp b/src/other_tools/utils/curl_easy_handle.cpp
index 6939c6d1..2fcfb877 100644
--- a/src/other_tools/utils/curl_easy_handle.cpp
+++ b/src/other_tools/utils/curl_easy_handle.cpp
@@ -40,11 +40,11 @@ auto read_stream_data(gsl::not_null<std::FILE*> const& stream) noexcept
std::rewind(stream);
// create string buffer to hold stream content
- std::string content(static_cast<size_t>(size), '\0');
+ std::string content(static_cast<std::size_t>(size), '\0');
// read stream content into string buffer
auto n = std::fread(content.data(), 1, content.size(), stream);
- if (n != static_cast<size_t>(size)) {
+ if (n != static_cast<std::size_t>(size)) {
Logger::Log(LogLevel::Warning,
"Reading curl log from temporary file failed: read only {} "
"bytes while {} were expected",
@@ -87,8 +87,8 @@ auto CurlEasyHandle::Create(
}
auto CurlEasyHandle::EasyWriteToFile(gsl::owner<char*> data,
- size_t size,
- size_t nmemb,
+ std::size_t size,
+ std::size_t nmemb,
gsl::owner<void*> userptr)
-> std::streamsize {
auto actual_size = static_cast<std::streamsize>(size * nmemb);
@@ -98,8 +98,8 @@ auto CurlEasyHandle::EasyWriteToFile(gsl::owner<char*> data,
}
auto CurlEasyHandle::EasyWriteToString(gsl::owner<char*> data,
- size_t size,
- size_t nmemb,
+ std::size_t size,
+ std::size_t nmemb,
gsl::owner<void*> userptr)
-> std::streamsize {
size_t actual_size = size * nmemb;
diff --git a/src/other_tools/utils/curl_easy_handle.hpp b/src/other_tools/utils/curl_easy_handle.hpp
index 1a3d31c3..81bcbed8 100644
--- a/src/other_tools/utils/curl_easy_handle.hpp
+++ b/src/other_tools/utils/curl_easy_handle.hpp
@@ -15,6 +15,7 @@
#ifndef INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_EASY_HANDLE_HPP
#define INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_EASY_HANDLE_HPP
+#include <cstddef>
#include <filesystem>
#include <functional>
#include <memory>
@@ -83,16 +84,16 @@ class CurlEasyHandle {
/// \brief Overwrites write_callback to redirect to file instead of stdout.
[[nodiscard]] auto static EasyWriteToFile(gsl::owner<char*> data,
- size_t size,
- size_t nmemb,
+ std::size_t size,
+ std::size_t nmemb,
gsl::owner<void*> userptr)
-> std::streamsize;
/// \brief Overwrites write_callback to redirect to string instead of
/// stdout.
[[nodiscard]] auto static EasyWriteToString(gsl::owner<char*> data,
- size_t size,
- size_t nmemb,
+ std::size_t size,
+ std::size_t nmemb,
gsl::owner<void*> userptr)
-> std::streamsize;
};
diff --git a/src/other_tools/utils/curl_url_handle.cpp b/src/other_tools/utils/curl_url_handle.cpp
index 912691b4..142d1809 100644
--- a/src/other_tools/utils/curl_url_handle.cpp
+++ b/src/other_tools/utils/curl_url_handle.cpp
@@ -14,6 +14,7 @@
#include "src/other_tools/utils/curl_url_handle.hpp"
+#include <cstddef>
#include <regex>
#include <sstream>
@@ -68,7 +69,7 @@ namespace {
/// Returns the size of the key path if match successful, otherwise nullopt.
[[nodiscard]] auto PathMatchSize(std::string const& key_path,
std::string const& url_path) noexcept
- -> std::optional<size_t> {
+ -> std::optional<std::size_t> {
// split key path
std::vector<std::string> key_tokens{};
std::string token{};
@@ -495,8 +496,8 @@ auto CurlURLHandle::ParseConfigKey(std::string const& key) noexcept
// create regex to find all possible matches of the parsed host in the
// original key, where any '.' can also be a '*'
std::stringstream pattern{};
- size_t old_index{};
- size_t index{};
+ std::size_t old_index{};
+ std::size_t index{};
while ((index = parsed_host.find('.', old_index)) !=
std::string::npos) {
pattern << parsed_host.substr(old_index, index - old_index);
@@ -508,13 +509,14 @@ auto CurlURLHandle::ParseConfigKey(std::string const& key) noexcept
// for every match, replace the parsed host in the found position and
// try to parse as usual
- size_t host_len = parsed_host.length();
+ std::size_t host_len = parsed_host.length();
for (auto it = std::sregex_iterator(key.begin(), key.end(), re);
it != std::sregex_iterator();
++it) {
std::string new_key{key};
- new_key.replace(
- static_cast<size_t>(it->position()), host_len, parsed_host);
+ new_key.replace(static_cast<std::size_t>(it->position()),
+ host_len,
+ parsed_host);
// try to parse new key
auto try_config_key = GetConfigStructFromKey(new_key);
@@ -538,7 +540,7 @@ auto CurlURLHandle::ParseConfigKey(std::string const& key) noexcept
auto CurlURLHandle::MatchConfigKey(std::string const& key) noexcept
-> std::optional<ConfigKeyMatchDegree> {
try {
- size_t host_len{};
+ std::size_t host_len{};
bool user_matched{false};
// parse the given key
diff --git a/src/other_tools/utils/curl_url_handle.hpp b/src/other_tools/utils/curl_url_handle.hpp
index 3d1e6949..476277f3 100644
--- a/src/other_tools/utils/curl_url_handle.hpp
+++ b/src/other_tools/utils/curl_url_handle.hpp
@@ -15,6 +15,7 @@
#ifndef INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_URL_HANDLE_HPP
#define INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_URL_HANDLE_HPP
+#include <cstddef>
#include <filesystem>
#include <functional>
#include <memory>
@@ -56,10 +57,10 @@ struct ConfigKeyMatchDegree {
// if a matching happened;
bool matched{false};
// length of config key's host field if host was matched
- size_t host_len{};
+ std::size_t host_len{};
// length of config key's path field if path was matched;
// comparison ends on a '/' char or the end of the path
- size_t path_len{};
+ std::size_t path_len{};
// signals a match for the user field between config key and remote URL,
// only if user field exists in config key
bool user_matched{false};