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 compiler warnings #693

Merged
merged 1 commit into from
Dec 1, 2023
Merged

Fix compiler warnings #693

merged 1 commit into from
Dec 1, 2023

Conversation

argilo
Copy link
Member

@argilo argilo commented Nov 4, 2023

When building with -DCMAKE_BUILD_TYPE=ASAN a number of compiler warnings are shown. I've cleaned up most of them here.

@@ -188,6 +188,7 @@ void option_list::parse(int argc, char** argv)
} catch (std::exception& exc) {
throw std::exception();
};
break;
Copy link
Member Author

@argilo argilo Nov 4, 2023

Choose a reason for hiding this comment

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

The fall-through here was a bug; it caused a blank line to be printed if the -R, -j, or -p options were used with volk_profile.

Comment on lines -228 to -236
switch (help_line.size() / 8) {
case 0:
help_line += "\t";
case 1:
help_line += "\t";
case 2:
help_line += "\t";
case 3:
help_line += "\t";
Copy link
Member Author

Choose a reason for hiding this comment

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

This code is just meant to line up the tables that are displayed by volk_profile --help and volk_config-info --help. The new version gets rid of the fall-through warnings, and is simpler.

Comment on lines 84 to 85
(void)input;

Copy link
Member Author

Choose a reason for hiding this comment

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

It's intentional that input is unused, so I added (void)input to suppress the unused parameter warnings.

Copy link
Contributor

Choose a reason for hiding this comment

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

C23 provides something for this exact situation:
maybe_unused
I suggest to add a comment to the (void)input; lines because this will make it more verbose. Otherwise, someone may remove these lines in the future because the look superfluous.

Copy link
Member

@marcusmueller marcusmueller Nov 5, 2023

Choose a reason for hiding this comment

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

as to give a differing opinion: (void)input; is the canonical way of silencing this warning and thus of marking a variable as unused. It's as concise as it gets! (and pretty unambiguous; if there's a (void)input; in the code, and you are about to remove it, you would reasonably ask yourself why it is in the code, and stackoverflow has you covered.

Copy link
Member

Choose a reason for hiding this comment

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

(also, the goal here would be to enable -Werror -Wunused-parameter so that a removal of that line would become a build fail)

Copy link
Contributor

@jdemel jdemel left a comment

Choose a reason for hiding this comment

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

I found one little thing that could improve the code for future reference.

Signed-off-by: Clayton Smith <[email protected]>
Copy link
Contributor

@jdemel jdemel left a comment

Choose a reason for hiding this comment

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

LGTM.

@jdemel jdemel merged commit 5bc2ded into gnuradio:main Dec 1, 2023
32 checks passed
@argilo argilo deleted the compile-warnings branch December 2, 2023 16:47
Alesha72003 pushed a commit to Alesha72003/volk that referenced this pull request May 15, 2024
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

Successfully merging this pull request may close these issues.

3 participants