diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..d9e4eec2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Declare files that will always have LF line endings on checkout. +*.sh test eol=lf diff --git a/examples/PutObject.cc b/examples/PutObject.cc index 14071d38..0857b2ad 100644 --- a/examples/PutObject.cc +++ b/examples/PutObject.cc @@ -13,7 +13,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include +#include +#include + +#include "args.h" #include "client.h" +#include "providers.h" +#include "request.h" +#include "response.h" int main() { // Create S3 base URL. diff --git a/examples/PutObjectProgress.cc b/examples/PutObjectProgress.cc index aae1cc8d..48c99f1d 100644 --- a/examples/PutObjectProgress.cc +++ b/examples/PutObjectProgress.cc @@ -13,7 +13,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include +#include +#include + +#include "args.h" #include "client.h" +#include "http.h" +#include "providers.h" +#include "request.h" +#include "response.h" int main() { // Create S3 base URL. diff --git a/include/args.h b/include/args.h index 227595c4..6421ca97 100644 --- a/include/args.h +++ b/include/args.h @@ -16,10 +16,17 @@ #ifndef _MINIO_S3_ARGS_H #define _MINIO_S3_ARGS_H +#include +#include +#include +#include +#include + +#include "error.h" #include "http.h" -#include "signer.h" #include "sse.h" #include "types.h" +#include "utils.h" namespace minio { namespace s3 { diff --git a/include/baseclient.h b/include/baseclient.h index 3ceb1a50..ac9b4b03 100644 --- a/include/baseclient.h +++ b/include/baseclient.h @@ -16,11 +16,18 @@ #ifndef _MINIO_S3_BASE_CLIENT_H #define _MINIO_S3_BASE_CLIENT_H +#include +#include +#include + #include "args.h" #include "config.h" +#include "error.h" +#include "http.h" +#include "providers.h" #include "request.h" #include "response.h" -#include "select.h" +#include "utils.h" namespace minio { namespace s3 { diff --git a/include/client.h b/include/client.h index b13be18b..b9169c87 100644 --- a/include/client.h +++ b/include/client.h @@ -16,11 +16,13 @@ #ifndef _MINIO_S3_CLIENT_H #define _MINIO_S3_CLIENT_H -#include +#include +#include #include "args.h" #include "baseclient.h" -#include "config.h" +#include "error.h" +#include "providers.h" #include "request.h" #include "response.h" diff --git a/include/credentials.h b/include/credentials.h index 49594b82..039f860a 100644 --- a/include/credentials.h +++ b/include/credentials.h @@ -16,6 +16,10 @@ #ifndef _MINIO_CREDS_CREDENTIALS_H #define _MINIO_CREDS_CREDENTIALS_H +#include +#include + +#include "error.h" #include "utils.h" namespace minio { @@ -34,6 +38,30 @@ struct Credentials { utils::UtcTime expiration = {}; Credentials() = default; + explicit Credentials(error::Error err) : err(std::move(err)) {} + + explicit Credentials(error::Error err, std::string access_key, + std::string secret_key) + : err(std::move(err)), + access_key(std::move(access_key)), + secret_key(std::move(secret_key)) {} + + explicit Credentials(error::Error err, std::string access_key, + std::string secret_key, std::string session_token) + : err(std::move(err)), + access_key(std::move(access_key)), + secret_key(std::move(secret_key)), + session_token(std::move(session_token)) {} + + explicit Credentials(error::Error err, std::string access_key, + std::string secret_key, std::string session_token, + utils::UtcTime expiration) + : err(std::move(err)), + access_key(std::move(access_key)), + secret_key(std::move(secret_key)), + session_token(std::move(session_token)), + expiration(std::move(expiration)) {} + ~Credentials() = default; bool IsExpired() const { return expired(expiration); } diff --git a/include/error.h b/include/error.h index d8035d13..d8666df9 100644 --- a/include/error.h +++ b/include/error.h @@ -18,6 +18,7 @@ #include #include +#include namespace minio { namespace error { @@ -32,9 +33,9 @@ class Error { Error(const Error&) = default; Error& operator=(const Error&) = default; - Error(Error&& v) : msg_(std::move(v.msg_)) {} + Error(Error&& v) noexcept : msg_(std::move(v.msg_)) {} - Error& operator=(Error&& v) { + Error& operator=(Error&& v) noexcept { if (this != &v) { msg_ = std::move(v.msg_); } diff --git a/include/http.h b/include/http.h index 30e45bee..441f6d48 100644 --- a/include/http.h +++ b/include/http.h @@ -16,16 +16,15 @@ #ifndef _MINIO_HTTP_H #define _MINIO_HTTP_H -#ifdef _WIN32 -#include -#else -#include -#endif - #include #include -#include +#include +#include +#include +#include +#include +#include "error.h" #include "utils.h" namespace minio { @@ -65,6 +64,13 @@ struct Url { std::string query_string; Url() = default; + explicit Url(bool https, std::string host, unsigned int port, + std::string path, std::string query_string) + : https(https), + host(std::move(host)), + port(port), + path(std::move(path)), + query_string(std::move(query_string)) {} ~Url() = default; explicit operator bool() const { return !host.empty(); } @@ -91,6 +97,16 @@ struct DataFunctionArgs { void* userdata = nullptr; DataFunctionArgs() = default; + explicit DataFunctionArgs(curlpp::Easy* handle, Response* response, + void* userdata) + : handle(handle), response(response), userdata(userdata) {} + explicit DataFunctionArgs(curlpp::Easy* handle, Response* response, + std::string datachunk, void* userdata) + : handle(handle), + response(response), + datachunk(std::move(datachunk)), + userdata(userdata) {} + ~DataFunctionArgs() = default; }; // struct DataFunctionArgs diff --git a/include/providers.h b/include/providers.h index 2c36a473..c896548e 100644 --- a/include/providers.h +++ b/include/providers.h @@ -16,11 +16,13 @@ #ifndef _MINIO_CREDS_PROVIDERS_H #define _MINIO_CREDS_PROVIDERS_H -#include - +#include +#include #include +#include #include "credentials.h" +#include "error.h" #include "http.h" #define DEFAULT_DURATION_SECONDS (60 * 60 * 24) // 1 day. @@ -34,6 +36,8 @@ struct Jwt { unsigned int expiry = 0; Jwt() = default; + explicit Jwt(std::string token, unsigned int expiry) + : token(std::move(token)), expiry(expiry) {} ~Jwt() = default; explicit operator bool() const { return !token.empty(); } diff --git a/include/request.h b/include/request.h index 30cdb51c..d9f78034 100644 --- a/include/request.h +++ b/include/request.h @@ -16,9 +16,13 @@ #ifndef _MINIO_REQUEST_H #define _MINIO_REQUEST_H -#include "credentials.h" +#include +#include + +#include "error.h" +#include "http.h" #include "providers.h" -#include "signer.h" +#include "utils.h" namespace minio { namespace s3 { diff --git a/include/response.h b/include/response.h index e14b0827..a58c2b36 100644 --- a/include/response.h +++ b/include/response.h @@ -16,9 +16,14 @@ #ifndef _MINIO_S3_RESPONSE_H #define _MINIO_S3_RESPONSE_H -#include +#include +#include +#include +#include +#include "error.h" #include "types.h" +#include "utils.h" namespace minio { namespace s3 { diff --git a/include/select.h b/include/select.h index e1da0a5b..1040f0a6 100644 --- a/include/select.h +++ b/include/select.h @@ -16,8 +16,11 @@ #ifndef _MINIO_S3_SELECT_H #define _MINIO_S3_SELECT_H -#include +#include +#include +#include +#include "error.h" #include "http.h" #include "types.h" diff --git a/include/signer.h b/include/signer.h index 9aae4ec9..836c4d03 100644 --- a/include/signer.h +++ b/include/signer.h @@ -16,9 +16,10 @@ #ifndef _MINIO_SIGNER_H #define _MINIO_SIGNER_H -#include +#include #include "http.h" +#include "utils.h" namespace minio { namespace signer { diff --git a/include/sse.h b/include/sse.h index 3edeb7b9..c28111e4 100644 --- a/include/sse.h +++ b/include/sse.h @@ -16,6 +16,8 @@ #ifndef _MINIO_S3_SSE_H #define _MINIO_S3_SSE_H +#include + #include "utils.h" namespace minio { diff --git a/include/types.h b/include/types.h index 9a220b06..e5487e7f 100644 --- a/include/types.h +++ b/include/types.h @@ -16,10 +16,17 @@ #ifndef _MINIO_S3_TYPES_H #define _MINIO_S3_TYPES_H +#include +#include #include -#include +#include +#include +#include #include +#include +#include +#include "error.h" #include "utils.h" namespace minio { @@ -310,6 +317,8 @@ struct Bucket { utils::UtcTime creation_date; Bucket() = default; + explicit Bucket(std::string name, utils::UtcTime creation_date) + : name(std::move(name)), creation_date(std::move(creation_date)) {} ~Bucket() = default; }; // struct Bucket @@ -320,6 +329,8 @@ struct Part { size_t size = 0; Part() = default; + explicit Part(unsigned int number, std::string etag) + : number(number), etag(std::move(etag)) {} ~Part() = default; }; // struct Part diff --git a/include/utils.h b/include/utils.h index d3e339a9..82095679 100644 --- a/include/utils.h +++ b/include/utils.h @@ -20,34 +20,23 @@ #include #endif -#include -#include -#include -#include - -#include -#include -#include -#include #include -#include -#include -#include +#include #include #include -#include -#include #include -#include +#include +#include +#include #include "error.h" namespace minio { namespace utils { -inline constexpr unsigned int kMaxMultipartCount = 10000; // 10000 parts -inline constexpr unsigned long long kMaxObjectSize = 5497558138880ULL; // 5TiB -inline constexpr unsigned long long kMaxPartSize = 5368709120UL; // 5GiB -inline constexpr unsigned int kMinPartSize = 5 * 1024 * 1024; // 5MiB +inline constexpr unsigned int kMaxMultipartCount = 10000; // 10000 parts +inline constexpr uint64_t kMaxObjectSize = 5'497'558'138'880; // 5TiB +inline constexpr uint64_t kMaxPartSize = 5'368'709'120; // 5GiB +inline constexpr unsigned int kMinPartSize = 5 * 1024 * 1024; // 5MiB // GetEnv copies the environment variable name into var bool GetEnv(std::string& var, const char* name); @@ -72,7 +61,7 @@ inline const char* BoolToString(bool b) { return b ? "true" : "false"; } // Trim trims leading and trailing character of a string. std::string Trim(std::string_view str, char ch = ' '); -// CheckNonemptystring checks whether string is not empty after trimming +// CheckNonEmptyString checks whether string is not empty after trimming // whitespaces. bool CheckNonEmptyString(std::string_view str); diff --git a/src/args.cc b/src/args.cc index dc7c9582..ed797f9d 100644 --- a/src/args.cc +++ b/src/args.cc @@ -15,8 +15,21 @@ #include "args.h" +#include +#include #include +#include +#include #include +#include +#include +#include + +#include "error.h" +#include "http.h" +#include "signer.h" +#include "types.h" +#include "utils.h" minio::error::Error minio::s3::BucketArgs::Validate() const { return utils::CheckBucketName(bucket); @@ -346,7 +359,7 @@ minio::error::Error minio::s3::ComposeSource::BuildHeaders( size_t minio::s3::ComposeSource::ObjectSize() const { if (object_size_ == -1) { std::cerr << "ABORT: ComposeSource::BuildHeaders() must be called prior to " - "this method invocation. This shoud not happen." + "this method invocation. This should not happen." << std::endl; std::terminate(); } @@ -357,7 +370,7 @@ size_t minio::s3::ComposeSource::ObjectSize() const { minio::utils::Multimap minio::s3::ComposeSource::Headers() const { if (!headers_) { std::cerr << "ABORT: ComposeSource::BuildHeaders() must be called prior to " - "this method invocation. This shoud not happen." + "this method invocation. This should not happen." << std::endl; std::terminate(); } @@ -441,7 +454,7 @@ minio::error::Error minio::s3::ListenBucketNotificationArgs::Validate() const { return err; } if (func == nullptr) { - error::Error("notification records function must be set"); + return error::Error("notification records function must be set"); } return error::SUCCESS; } diff --git a/src/baseclient.cc b/src/baseclient.cc index 3b51baa5..0925ce32 100644 --- a/src/baseclient.cc +++ b/src/baseclient.cc @@ -15,6 +15,32 @@ #include "baseclient.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "args.h" +#include "config.h" +#include "credentials.h" +#include "error.h" +#include "http.h" +#include "providers.h" +#include "request.h" +#include "response.h" +#include "select.h" +#include "signer.h" +#include "types.h" +#include "utils.h" + minio::utils::Multimap minio::s3::GetCommonListObjectsQueryParams( const std::string& delimiter, const std::string& encoding_type, unsigned int max_keys, const std::string& prefix) { @@ -955,7 +981,7 @@ minio::s3::BaseClient::GetPresignedPostFormData(PostPolicy policy) { if (provider_ == nullptr) { return error::Error( - "Anonymous access does not require presigned post form-data"); + "Anonymous access does not require pre-signed post form-data"); } std::string region; diff --git a/src/client.cc b/src/client.cc index 373984ee..5c0e4c40 100644 --- a/src/client.cc +++ b/src/client.cc @@ -15,6 +15,26 @@ #include "client.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "args.h" +#include "baseclient.h" +#include "error.h" +#include "http.h" +#include "providers.h" +#include "request.h" +#include "response.h" +#include "sse.h" +#include "types.h" +#include "utils.h" + minio::s3::ListObjectsResult::ListObjectsResult(error::Error err) : failed_(true) { this->resp_.contents.push_back(Item(std::move(err))); @@ -284,7 +304,7 @@ minio::s3::ComposeObjectResponse minio::s3::Client::ComposeObject( upc_args.part_number = part_number; UploadPartCopyResponse resp = UploadPartCopy(upc_args); if (!resp) return resp; - parts.push_back(Part{part_number, resp.etag}); + parts.push_back(Part(part_number, std::move(resp.etag))); } else { while (size > 0) { part_number++; @@ -306,10 +326,11 @@ minio::s3::ComposeObjectResponse minio::s3::Client::ComposeObject( upc_args.headers = headerscopy; upc_args.upload_id = upload_id; upc_args.part_number = part_number; - UploadPartCopyResponse resp = UploadPartCopy(upc_args); - if (!resp) return resp; - parts.push_back(Part{part_number, resp.etag}); - + { + UploadPartCopyResponse resp = UploadPartCopy(upc_args); + if (!resp) return resp; + parts.push_back(Part(part_number, std::move(resp.etag))); + } offset = start_bytes; size -= (end_bytes - start_bytes); } @@ -475,7 +496,7 @@ minio::s3::PutObjectResponse minio::s3::Client::PutObject( actual_args.userdata = args.progress_userdata; args.progressfunc(actual_args); } - parts.push_back(Part{part_number, resp.etag}); + parts.push_back(Part(part_number, std::move(resp.etag))); } else { return resp; } diff --git a/src/credentials.cc b/src/credentials.cc index 085ccf6d..9795b93d 100644 --- a/src/credentials.cc +++ b/src/credentials.cc @@ -16,6 +16,11 @@ #include "credentials.h" #include +#include +#include + +#include "error.h" +#include "utils.h" bool minio::creds::expired(const utils::UtcTime& expiration) { if (!expiration) return false; @@ -44,6 +49,7 @@ minio::creds::Credentials minio::creds::Credentials::ParseXML( text = credentials.node().select_node("Expiration/text()"); auto expiration = utils::UtcTime::FromISO8601UTC(text.node().value()); - return Credentials{error::SUCCESS, access_key, secret_key, session_token, - expiration}; + return Credentials(error::SUCCESS, std::move(access_key), + std::move(secret_key), std::move(session_token), + expiration); } diff --git a/src/http.cc b/src/http.cc index c4647dd7..f229442e 100644 --- a/src/http.cc +++ b/src/http.cc @@ -13,9 +13,37 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "http.h" +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#include // NOTE needed for AF_INET6 +#include // NOTE needed for sockaddr_in6 +#include +#else +#include +#endif + +#include "error.h" +#include "http.h" +#include "utils.h" std::string minio::http::Url::String() const { if (host.empty()) return {}; @@ -105,7 +133,8 @@ minio::http::Url minio::http::Url::Parse(std::string value) { if (!https && port == 80) port = 0; if (https && port == 443) port = 0; - return Url{https, host, port, path, query_string}; + return Url(https, std::move(host), port, std::move(path), + std::move(query_string)); } minio::error::Error minio::http::Response::ReadStatusCode() { @@ -248,7 +277,8 @@ size_t minio::http::Response::ResponseCallback(curlpp::Multi* const requests, // If data function is set and the request is successful, send data. if (datafunc != nullptr && status_code >= 200 && status_code <= 299) { - DataFunctionArgs args{request, this, response_, userdata}; + DataFunctionArgs args(request, this, std::string(this->response_), + userdata); if (!datafunc(args)) requests->remove(request); } else { body = response_; @@ -259,7 +289,7 @@ size_t minio::http::Response::ResponseCallback(curlpp::Multi* const requests, // If data function is set and the request is successful, send data. if (datafunc != nullptr && status_code >= 200 && status_code <= 299) { - DataFunctionArgs args{request, this, std::string(buffer, length), userdata}; + DataFunctionArgs args(request, this, std::string(buffer, length), userdata); if (!datafunc(args)) requests->remove(request); } else { body.append(buffer, length); @@ -368,9 +398,9 @@ minio::http::Response minio::http::Request::execute() { while (!requests.perform(&left)) { } while (left) { - fd_set fdread; - fd_set fdwrite; - fd_set fdexcep; + fd_set fdread{}; + fd_set fdwrite{}; + fd_set fdexcep{}; int maxfd = 0; FD_ZERO(&fdread); diff --git a/src/providers.cc b/src/providers.cc index 73882d5b..2fe2a1ad 100644 --- a/src/providers.cc +++ b/src/providers.cc @@ -17,22 +17,32 @@ #define _WINSOCK_DEPRECATED_NO_WARNINGS #endif -#include "providers.h" - #include #include +#include +#include #include +#include +#include -#include "signer.h" -#include "utils.h" - -#ifndef _WIN32 +#ifdef _WIN32 +#include +#include +#include +#else #include #include #include #endif +#include "credentials.h" +#include "error.h" +#include "http.h" +#include "providers.h" +#include "signer.h" +#include "utils.h" + minio::error::Error minio::creds::checkLoopbackHost(const std::string& host) { struct addrinfo hints = {}; hints.ai_family = AF_INET; @@ -82,8 +92,8 @@ minio::creds::Credentials minio::creds::ChainedProvider::Fetch() { minio::creds::StaticProvider::StaticProvider(std::string access_key, std::string secret_key, std::string session_token) { - this->creds_ = Credentials{error::SUCCESS, std::move(access_key), - std::move(secret_key), std::move(session_token)}; + this->creds_ = Credentials(error::SUCCESS, std::move(access_key), + std::move(secret_key), std::move(session_token)); } minio::creds::StaticProvider::~StaticProvider() {} @@ -105,8 +115,8 @@ minio::creds::EnvAwsProvider::EnvAwsProvider() { } utils::GetEnv(session_token, "AWS_SESSION_TOKEN"); - this->creds_ = - Credentials{error::SUCCESS, access_key, secret_key, session_token}; + this->creds_ = Credentials(error::SUCCESS, std::move(access_key), + std::move(secret_key), std::move(session_token)); } minio::creds::EnvAwsProvider::~EnvAwsProvider() {} @@ -121,7 +131,8 @@ minio::creds::EnvMinioProvider::EnvMinioProvider() { utils::GetEnv(access_key, "MINIO_ACCESS_KEY"); utils::GetEnv(secret_key, "MINIO_SECRET_KEY"); - this->creds_ = Credentials{error::SUCCESS, access_key, secret_key}; + this->creds_ = + Credentials(error::SUCCESS, std::move(access_key), std::move(secret_key)); } minio::creds::EnvMinioProvider::~EnvMinioProvider() {} @@ -379,7 +390,7 @@ minio::creds::Credentials minio::creds::IamAwsProvider::Fetch() { std::ifstream ifs(token_file); nlohmann::json json = nlohmann::json::parse(ifs); ifs.close(); - return Jwt{json["access_token"], json["expires_in"]}; + return Jwt(std::move(json["access_token"]), json["expires_in"]); }, url, 0, "", role_arn_, role_session_name_); creds_ = provider.Fetch(); diff --git a/src/request.cc b/src/request.cc index d07aaaf9..30ead666 100644 --- a/src/request.cc +++ b/src/request.cc @@ -15,6 +15,23 @@ #include "request.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "credentials.h" +#include "error.h" +#include "http.h" +#include "providers.h" +#include "signer.h" +#include "utils.h" + #define EMPTY_SHA256 \ "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" @@ -199,7 +216,8 @@ minio::error::Error minio::s3::BaseUrl::BuildUrl( return error::Error("empty bucket name for object name " + object_name); } - url = http::Url{https, host, port, "/", query_params.ToQueryString()}; + url = http::Url(https, std::string(this->host), port, "/", + query_params.ToQueryString()); if (bucket_name.empty()) { this->BuildListBucketsUrl(url, region); diff --git a/src/response.cc b/src/response.cc index c922d92c..e40a145f 100644 --- a/src/response.cc +++ b/src/response.cc @@ -15,6 +15,18 @@ #include "response.h" +#include +#include +#include +#include +#include +#include +#include + +#include "error.h" +#include "types.h" +#include "utils.h" + minio::s3::Response::Response() {} minio::s3::Response::~Response() {} @@ -90,7 +102,7 @@ minio::s3::ListBucketsResponse minio::s3::ListBucketsResponse::ParseXML( creation_date = utils::UtcTime::FromISO8601UTC(value.c_str()); } - buckets.push_back(Bucket{name, creation_date}); + buckets.push_back(Bucket(std::move(name), std::move(creation_date))); } return buckets; diff --git a/src/select.cc b/src/select.cc index 40d3f219..691dfa26 100644 --- a/src/select.cc +++ b/src/select.cc @@ -15,6 +15,15 @@ #include "select.h" +#include +#include +#include + +#include "error.h" +#include "http.h" +#include "types.h" +#include "utils.h" + void minio::s3::SelectHandler::Reset() { prelude_.clear(); prelude_read_ = false; diff --git a/src/signer.cc b/src/signer.cc index f33af171..227554da 100644 --- a/src/signer.cc +++ b/src/signer.cc @@ -15,6 +15,17 @@ #include "signer.h" +#include +#include + +#include +#include +#include +#include + +#include "http.h" +#include "utils.h" + const char* SIGN_V4_ALGORITHM = "AWS4-HMAC-SHA256"; std::string minio::signer::GetScope(const utils::UtcTime& time, diff --git a/src/sse.cc b/src/sse.cc index c47377f7..b3e07285 100644 --- a/src/sse.cc +++ b/src/sse.cc @@ -15,6 +15,10 @@ #include "sse.h" +#include + +#include "utils.h" + minio::s3::Sse::Sse() {} minio::s3::Sse::~Sse() {} diff --git a/src/types.cc b/src/types.cc index e8048b93..4c26a302 100644 --- a/src/types.cc +++ b/src/types.cc @@ -15,6 +15,16 @@ #include "types.h" +#include +#include +#include +#include +#include +#include +#include + +#include "error.h" + minio::s3::RetentionMode minio::s3::StringToRetentionMode( std::string_view str) noexcept { if (str == "GOVERNANCE") return RetentionMode::kGovernance; diff --git a/src/utils.cc b/src/utils.cc index 6cadbcfd..b821580d 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -15,12 +15,45 @@ #ifdef _WIN32 #define _CRT_SECURE_NO_WARNINGS +#include #endif +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "error.h" #include "utils.h" -#include - const std::string WEEK_DAYS[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; const std::string MONTHS[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", @@ -370,7 +403,7 @@ minio::utils::UtcTime minio::utils::UtcTime::FromISO8601UTC(const char* value) { std::time_t secs = std::mktime(&t); unsigned long ul = 0; - sscanf(rv, ".%lu", &ul); + static_cast(sscanf(rv, ".%lu", &ul)); long usecs = (long)ul; return UtcTime(secs, usecs); @@ -563,7 +596,7 @@ minio::error::Error minio::utils::CalcPartInfo(long object_size, } if (object_size >= 0) { - if (static_cast(object_size) > kMaxObjectSize) { + if (static_cast(object_size) > kMaxObjectSize) { return error::Error("object size " + std::to_string(object_size) + " is not supported; maximum allowed 5TiB"); } diff --git a/tests/tests.cc b/tests/tests.cc index dcef9eb5..f836dbe3 100644 --- a/tests/tests.cc +++ b/tests/tests.cc @@ -12,11 +12,33 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include +#include +#include "args.h" #include "client.h" +#include "http.h" +#include "providers.h" +#include "request.h" +#include "response.h" +#include "types.h" +#include "utils.h" thread_local static std::mt19937 rg{std::random_device{}()}; @@ -534,7 +556,9 @@ class Tests { args.bucket = bucket_name_; args.object = object_name; minio::s3::PutObjectResponse resp = client_.PutObject(args); - if (!resp) std::runtime_error("PutObject(): " + resp.Error().String()); + if (!resp) { + throw std::runtime_error("PutObject(): " + resp.Error().String()); + } object_names.push_back(object_name); } RemoveObjects(object_names);