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

Clang tidy cleanup #276

Merged
merged 4 commits into from
Jan 8, 2024
Merged

Conversation

cgzones
Copy link
Contributor

@cgzones cgzones commented Dec 29, 2023

No description provided.

src/main.c Outdated
@@ -86,10 +86,12 @@ static void usage(void)

}

#define WARN_ON_INVALID_CHECK_ID(id, desc)\
Copy link
Member

Choose a reason for hiding this comment

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

I the do {} while(0) trick seems tolerable when the macro isn't already a block, but I'm not really clear why it adds value here rather than just increasing the indent. What exactly is clang-tidy upset about?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a clang-tidy lint, but while looking at the empty statements warnings I also looked for macros with control flow logic to protect them against potential dangling-else problems.

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't using the

if (condition) {
    code
}

style instead of

if(condition)
    code

already protect against dangling else problems?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does.

Copy link
Member

Choose a reason for hiding this comment

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

Then I think my preference would be to drop this commit. I'd love to take the rest of the PR if you want to push a version dropping this commit.

Not really relevant for single-threaded selint, but pleases clang-tidy.
Needed for size_t and strrchr(3) while processing with a LSP.
Drop unnecessary OOM check.
@dburgener dburgener merged commit 9b660eb into SELinuxProject:main Jan 8, 2024
3 checks passed
@dburgener
Copy link
Member

Merged, thanks!

@cgzones cgzones deleted the clang_tidy_cleanup branch January 8, 2024 16:20
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.

2 participants