Skip to content

Conversation

@galanCA
Copy link
Contributor

@galanCA galanCA commented Jun 15, 2022

Description

Replace Windows _snprintf for snprintf. This is a small PR because I was expecting more changes related to standard functions.

Author Progress Checklist:

  • Open draft pull request
    • Make title clearly understandable in a standalone change log context
    • Assign yourself the issue
    • Add at least one label (enhancement, bug, or maintenance)
    • Link the issue(s) addressed by this PR (under "Development" in the sidebar menu)
  • Make code changes (if you haven't already)
  • Self-review of code
    • My code follows the style guidelines of this project
    • I have added comments to my code, particularly in hard-to-understand areas
    • I have only committed the necessary changes for this fix or feature
    • I have made corresponding changes to the documentation
    • My changes generate no new warnings
    • I have ensured that my fix is effective or that my feature works as intended by:
      • exercising the code changes in the test framework, and/or
      • manually verifying the changes (as explained in the the pull request description above)
    • My changes pass all local tests
    • My changes successfully passes CI checks
    • Add any unit test for proof and documentation.
    • Merge in main branch and address resulting conflicts and/or test failures.
  • Move pull request out of draft mode and assign reviewers
  • Iterate with reviewers until all changes are approved
    • Make changes in response to reviewer comments
    • Merge in main branch and address resulting conflicts and/or test failures.
    • Re-request review in GitHub

Reviewer Checklist:

  • Read the pull request description
  • Perform a code review on GitHub
  • Confirm all CI checks pass and there are no build warnings
  • Pull, build, and run automated tests locally
  • Perform manual tests of the fix or feature locally
  • Add any review comments, if applicable
  • Submit review in GitHub as either
    • Request changes, or
    • Approve
  • Iterate with author until all changes are approved

@galanCA galanCA requested review from tanaya-mankad June 16, 2022 17:00
@galanCA galanCA self-assigned this Jun 16, 2022
@galanCA galanCA added maintenance multi-platform issues related to compiling / running on non-Windows platforms labels Jun 16, 2022
@galanCA galanCA marked this pull request as ready for review June 16, 2022 17:00
@galanCA galanCA requested a review from nealkruis June 20, 2022 22:02
Copy link
Contributor

@nealkruis nealkruis left a comment

Choose a reason for hiding this comment

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

@galanCA I think this is fairly safe, but I am curious why this function is necessary at all. Why can't we just use sprintf?

@galanCA
Copy link
Contributor Author

galanCA commented Jun 22, 2022

@nealkruis It looks like both perform the same function except that snprintf takes the size of the text. cplusplus.com mentions that snprintf is safer. Other than that we can use sprintf if we desire. I initially opted to use snprintf because it had the same functionality as the function it was replacing.

@tanaya-mankad
Copy link
Contributor

@nealkruis I don't know about clang or gcc but msvc has been yelling at me for years to not use sprintf or sscanf because of potential for buffer overruns.

@galanCA galanCA changed the title Change _snprintf for snprintf. Change _snprintf for snprintf Jul 7, 2022
@nealkruis
Copy link
Contributor

@galanCA my question is more about whether the distinction between the two functions is meaningful in this context. Will the behavior be the same either way? I'm not sure myself.

@nealkruis nealkruis merged commit e778e23 into master Jul 19, 2022
@nealkruis nealkruis deleted the use-standard-function branch July 19, 2022 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance multi-platform issues related to compiling / running on non-Windows platforms

Projects

Development

Successfully merging this pull request may close these issues.

4 participants