gearman / gearmand

http://gearman.org/
Other
727 stars 138 forks source link

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

Closed esabol closed 7 months ago

esabol commented 7 months ago

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 commented 7 months ago

@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.