Skip to content

Remove unused variables - #73925

Open
MaxKellermann wants to merge 33 commits into
ceph:mainfrom
MaxKellermann:unused_variables
Open

MaxKellermann wants to merge 33 commits into
ceph:mainfrom
MaxKellermann:unused_variables

Conversation

@MaxKellermann

Copy link
Copy Markdown
Member

Fix -Wunused-variable across the tree.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
The variable is only used to keep the object recorders locked until
the end of the scope.

Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Mark the variables which are only used with WITH_RADOSGW_RADOS
[[maybe_unused]] to avoid warnings when building
rgw-standalone-admin.

Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
@adamemerson

Copy link
Copy Markdown
Contributor

@chardan Please review RGW portions and common code for RGW.

@chardan chardan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 LGTM. I only had one small concern, take a peek and see what you think. Otherwise, looks great! It's really nice to see this sort of thing being done.

case SYNCLIENT_MODE_CREATESHARED:
{
string sarg1 = get_sarg(0);
get_sarg(0); // skip unused argument

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sadly, in C++23 there's not a great say to say "ignore the result", and it does look like get_sarg() is effectful on the object. The most idiomatic way I know of is to cast it to void:
static_cast(get_sarg(0)) or (void)get_sarg(0);

I think either is a bit better than a comment, and has additionally will suppress ignored-return warnings, which may fit in with the spirit of this warning-eliminating PR. Give it a thought!

@MaxKellermann MaxKellermann Nov 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's your call, I'll change this to whatever you believe is better, but:

  1. get_sarg() is not [[nodiscard]], thus adding a void cast does nothing at all; there's no warning to be suppressed; "ignore the result" is the compiler default for function calls where the result isn't used
  2. IMHO the comment is useful to explain why this call exists at all (since the method has a slightly confusing name; take_sarg would be less ambiguous, expressing that the method isn't just a "pure" getter)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1)You're right, as it's not marked [[nodiscard]] it's the same behavior we've had since the dawn of time. I should have read more carefully.

Nonetheless, I do prefer a cast to void over a comment as it is an explicit signal you intend to call a function and deliberately ignore the return value.

  1. Re-reading your comment, you were pointing at the side-effect anyway (as you've re-stated). So one option-- honestly probably better than any of this, other than the time involved-- would be to go maybe a little beyond the PR mandate (I'm cool with it, we have a clear purpose in mind) and split get_sarg() into two operations. Then there's no need for a comment or annotation at all.

I already approved the PR, you don't have to do any of those if you don't want to, I'm already ok with it.

@github-actions

Copy link
Copy Markdown

@MaxKellermann Thank you for reviewing this pull request! As a member of the Ceph organization, please add yourself to .githubmap in the main branch if you haven't already.

@MaxKellermann

Copy link
Copy Markdown
Member Author

@MaxKellermann Thank you for reviewing this pull request! As a member of the Ceph organization, please add yourself to .githubmap in the main branch if you haven't already.

See #72914

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

Comment thread src/client/Client.cc
unsigned i = 0;

if (trimmed_path == "") {
std::string trimmed_path = path.get_trimmed_path();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This trimmed_path is hiding the outer one. The correct change would be to just set trimmed_path here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Depends on your definition of "correct". What you suggest would change the behavior of this piece of code.
Yet I know what you mean; the current behavior is obviously buggy, not what the author intended to do.

@idryomov idryomov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ack from the RBD perspective

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants