Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implicit conversion warnings #130

Open
kobalicek opened this issue Apr 5, 2024 · 0 comments
Open

Implicit conversion warnings #130

kobalicek opened this issue Apr 5, 2024 · 0 comments

Comments

@kobalicek
Copy link
Contributor

There is still bunch of warnings regarding implicit conversion. Let's keep track of these:

minio-cpp/src/signer.cc:71:8: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
   69 |   HMAC(EVP_sha256(), key.data(), static_cast<int>(key.size()),
      |   ~~~~
   70 |        reinterpret_cast<unsigned char const*>(data.data()),
   71 |        static_cast<int>(data.size()), hash.data(), &hash_len);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
minio-cpp/src/client.cc:397:21: warning: implicit conversion changes signedness: 'long' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
  397 |         part_size = object_size - uploaded_size;
      |                     ^~~~~~~~~~~ ~
minio-cpp/src/utils.cc:590:20: warning: implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'streamsize' (aka 'long') [-Wsign-conversion]
  590 |   stream.read(buf, size);
      |          ~~~~      ^~~~
minio-cpp/src/utils.cc:591:23: warning: implicit conversion changes signedness: 'streamsize' (aka 'long') to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
  591 |   bytes_read = stream.gcount();
      |              ~ ~~~~~~~^~~~~~~~
minio-cpp/src/utils.cc:630:63: warning: implicit conversion changes signedness: 'long' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
  630 |   if (static_cast<long>(part_size) > object_size) part_size = object_size;
      |                                                             ~ ^~~~~~~~~~~
minio-cpp/src/utils.cc:632:27: warning: implicit conversion changes signedness: 'long' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
  632 |       (part_size > 0) ? ((object_size + part_size - 1) / part_size) : 1);
      |                           ^~~~~~~~~~~ ~
1 warning generated.
minio-cpp/src/args.cc:301:21: warning: implicit conversion changes signedness: 'long' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
  301 |   this->part_size = part_size;
      |                   ~ ^~~~~~~~~
minio-cpp/src/args.cc:382:10: warning: implicit conversion changes signedness: 'const long' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
  382 |   return object_size_;
      |   ~~~~~~ ^~~~~~~~~~~~
minio-cpp/src/baseclient.cc:1870:35: warning: implicit conversion changes signedness: 'long' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
 1870 |   if (!value.empty()) resp.size = std::stol(value);

I have already removed some and these remain...

I'm not entirely sure whether it's great to use int where size_t would be more appropriate. I would like to review the code a bit before just adding a static_cast<>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant