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

Remove "redundant null check due to previous dereference" found in CodeQL scan #380

Merged
merged 1 commit into from
Nov 18, 2023

Conversation

esabol
Copy link
Member

@esabol esabol commented Nov 12, 2023

This PR fixes an "issue" reported by the CodeQL scan of the gearmand source code. The null check on line 179 of libtest/server.cc is redundant because it has already been dereferenced on line 177 in the condition of the for loop.
Screen Shot 2023-11-12 at 6 33 05 PM

I suppose the if (argv) { ... } around the for loop could also be removed since the new condition of the for loop will also test this, but it doesn't do any harm and arguably improves clarity. I'd be willing to remove it though if you think it should be removed, @SpamapS.

@esabol esabol added the codeql label Nov 13, 2023
@esabol esabol changed the title Remove redundant null check due to previous dereference found in CodeQL scan Remove "redundant null check due to previous dereference" found in CodeQL scan Nov 13, 2023
Copy link
Member

@SpamapS SpamapS left a comment

Choose a reason for hiding this comment

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

Wow sometimes maintaining gearmand feels like working on an archeological dig.

Agree with your assessment. Remove that extra check. It might even get optimized out in some cases.

Anyway, I looked at some of the calls to this and funny enough the only one I could find that uses the argv's was my own addition of --round-robin mode.

@esabol esabol force-pushed the fix-redundant-null-check branch from 86ad810 to a0ee78f Compare November 15, 2023 17:50
@esabol
Copy link
Member Author

esabol commented Nov 15, 2023

@SpamapS wrote:

Agree with your assessment. Remove that extra check. It might even get optimized out in some cases.

Yeah, I think it would be with any good compiler. OK, I've removed the if (argv) { ... } as well. Squashed and rebased.

@SpamapS SpamapS merged commit a00fb0e into gearman:master Nov 18, 2023
@esabol esabol deleted the fix-redundant-null-check branch November 18, 2023 18:12
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.

2 participants