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

Fix some warnings #3595

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

mathbunnyru
Copy link
Contributor

No description provided.

@Hind-M Hind-M added the release::bug_fixes For PRs fixing bugs label Nov 13, 2024
@@ -170,7 +170,7 @@ namespace mamba
{
public:

MessageLogger(const char* file, int line, log_level level);
MessageLogger(const char* file, log_level level);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why remove the line here?

Copy link
Contributor Author

@mathbunnyru mathbunnyru Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_line is not used anywhere, we're not logging the line number, so the compiler was warning that the class data member was unused.

Copy link
Member

@Hind-M Hind-M Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, ok. It seems to be the case for file as well.
No warning so far?

Copy link
Contributor Author

@mathbunnyru mathbunnyru Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't give a warning (now), but it's a good point, I will remove m_file as well - it is not used and doesn't change any behaviour.

@@ -58,7 +58,8 @@ namespace mamba::download
TEST_CASE("PassThroughMirror")
{
std::unique_ptr<Mirror> mir = make_mirror("");
CHECK_EQ(typeid(*mir), typeid(PassThroughMirror));
auto& ref = *mir;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the warning for this change? I believe this is more related to performance but we only dereference once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not about performance, compiler didn't like that there possibly was a call with side effects in typeid call (dereferencing might fail).
The easiest way to fix this is to dereference in a separate line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well in that case, it still doesn't solve the problem of dereferencing possible failure.
I suggest adding instead a static_assert before the CHECK_EQ:
static_assert(mir != nullptr);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't do it, because mir is not known in a compile-time, so static_assert won't work here

libmamba/src/api/list.cpp Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release::bug_fixes For PRs fixing bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants