minio / minio-cpp

MinIO C++ Client SDK for Amazon S3 Compatible Cloud Storage
https://minio-cpp.min.io/
Apache License 2.0
136 stars 56 forks source link

Rework entire code for correctness and potential bug fixes #111

Closed piotr-topnotch closed 7 months ago

piotr-topnotch commented 8 months ago

Reworked minio-cpp to in order to:

  1. Fix all the bugs caused by implicit conversions to bool.
  2. Defaulted constructors and destructors.
  3. Explicit override indicators of virtual functions.
  4. Enhanced copy elision and enabled move construction.
  5. Improved const correctness. Only the functions that mutate objects take mutable references.
  6. NULL => nullptr transition, as the required language level is C++17 already.
  7. Fixed a number of the lack of default initialization value bugs.
  8. Enforced -Wall -Wextra -Wconversion and fixed the relevant uncompilable sites.

The scope of the changes is limited to what is allowed by the requirement to leave the API unchanged. Nonetheless, a follow-up pass removing converting constructors is highly recommended.

kobalicek commented 8 months ago

@piotr-topnotch I think this needs Windows fixes as well.

I assume this is the first PR that doesn't introduce API breaks? Because all the passing of stuff via value (like std::string, etc...) that has to go away. I would suggest std::string_view for everything that doesn't need to be retained (that would be a good start) and then I guess we will have to evaluate the API one by one to make it nicer.

Thinking of jumping into this after I finish the stuff I'm working on.

piotr-topnotch commented 8 months ago

I assume this is the first PR that doesn't introduce API breaks?

Except for the explicit operator bool() which is the root of most problems here, that's precisely the goal here. More fixes are pending, but let's do it one step at a time.

Moreover, I spoke to @kannappanr and he agreed to treat the removal of all the implicit conversions as bugfixes, even if these changes would break comparability at the user end. As the user experience has priority, this enables much deeper rework.

piotr-topnotch commented 8 months ago

But I'm in no position to predict the impact on upstream projects that use this repo.

Thank you, @HJLebbink. @kannappanr authorized breaking changes if that improves user experience and can help fix bugs. There shouldn't be many in this PR, but there are more issues requiring our attention, e.g. implicit conversions.

piotr-topnotch commented 8 months ago

Please fix CI failures.

Sure; I didn't know we have a linter in the CI loop. It's good news and the fixes will be promptly delivered.

astrocox commented 8 months ago

Not sure if you have easy access to a Windows dev environment. If not, lmk, I might be able to take a look at the CI failures this weekend.

HJLebbink commented 8 months ago

Not sure if you have easy access to a Windows dev environment. If not, lmk, I might be able to take a look at the CI failures this weekend.

@astrocox I wanted to contact you: have you been able to compile and link this project in the past on WSL2 or on native Windows? I and @piotr-topnotch have such win boxes, but use WSL most of the time. For community support, windows native support would be a very good thing to have.

astrocox commented 8 months ago

Not sure if you have easy access to a Windows dev environment. If not, lmk, I might be able to take a look at the CI failures this weekend.

@astrocox I wanted to contact you: have you been able to compile and link this project in the past on WSL2 or on native Windows? I and @piotr-topnotch have such win boxes, but use WSL most of the time. For community support, windows native support would be a very good thing to have.

Native windows, after my changes from #108 ! You can check the windows build pipeline for the steps to install dependencies. Locally I have tested it with cl.exe and clang-cl.exe, but the GH actions build is using the regular MSVC cl.exe compiler. If you're using an IDE like Clion, it's pretty easy to set up two different cmake profiles that use Visual Studio and WSL as their respective toolchain.

There are still a lot of compiler warnings to clean up on windows, but I think some Windows support is better than none 🙂

kobalicek commented 8 months ago

I can extend GH actions workflow to use a much larger matrix of various configurations (OS / compiler)

piotr-topnotch commented 8 months ago

There are still a lot of compiler warnings to clean up on windows, but I think some Windows support is better than none 🙂

Build support for MSVC is now confirmed. The Windows warnings you can see will be fixed as a part of this PR.