Skip to content

Assert bounds of tmp->tm_mon to address scan-build warnings #1178

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

Merged
merged 4 commits into from
Jan 12, 2023

Conversation

eramongodb
Copy link
Collaborator

Observed a surprise task failure during a patch build. I do not expect tmp->tm_mon < MONSPERYEAR to ever be violated given the context, but to satisfy scan-build, I elected to add the condition to the loop anyways. Verified by this patch.

@eramongodb eramongodb requested a review from kevinAlbs January 12, 2023 18:31
@eramongodb eramongodb self-assigned this Jan 12, 2023
@eramongodb
Copy link
Collaborator Author

eramongodb commented Jan 12, 2023

Reconsidered the initial solution and transformed the loop such that the precondition (it is a precondition) is asserted via BSON_ASSERT instead. Verified by this patch.

@eramongodb eramongodb changed the title Add bound to tmp->tm_mon to address scan-build warnings Assert bounds of tmp->tm_mon to address scan-build warnings Jan 12, 2023
@eramongodb eramongodb merged commit 2c17536 into mongodb:master Jan 12, 2023
@eramongodb eramongodb deleted the cdriver-scan-build branch January 12, 2023 21:41
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