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

Fix sprintf deprecation warnings #240

Closed
wants to merge 1 commit into from
Closed

Conversation

mborland
Copy link

@mborland mborland commented Apr 7, 2023

Proposed changes

When building the b2 engine with Clang 16.0.1 a large number of warnings are issued for: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]

Types of changes

Replaces all instances of sprintf with snprintf

Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes
  • Other (please describe):

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I searched the discussions
  • I searched the closed and open issues
  • I read the contribution guidelines
  • I added myself to the copyright attributions for significant changes
  • I checked that tests pass locally with my changes
  • I added tests that prove my fix is effective or that my feature works
  • I added necessary documentation (if appropriate)

Further comments

With these changes the b2 engine builds without warnings. snprintf was introduced in C99, and std::snprintf was introduced in C++11. Since building the b2 engine requires C++11 I expect this won't cause significant breakage.

src/engine/regexp.cpp Outdated Show resolved Hide resolved
@mborland
Copy link
Author

@Kojoley It looks like the only CI failure here is on Azure's end. The runner timed out before finishing the configuration checks https://dev.azure.com/bfgroup/B2/_build/results?buildId=853&view=logs&j=a06d87d3-d37d-5246-e522-565455e28a93&t=543f527c-497a-5cfe-456d-c3cc14b7ee19&l=758.

@Kojoley
Copy link
Contributor

Kojoley commented Apr 18, 2023

I am not a maintainer, I cannot help you with that,

@mborland
Copy link
Author

@grafikrobot Can you please take a look at this? Thanks.

@grafikrobot grafikrobot added the enhancement New feature or request label Jun 5, 2023
Copy link
Member

@grafikrobot grafikrobot left a comment

Choose a reason for hiding this comment

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

Sorry foe the delay. The one thing I'm wondering about.. Why are all the changes guarded by OS_NT? This warning shows up in other builds. Like when building on Apple clang.

@mborland
Copy link
Author

Sorry foe the delay. The one thing I'm wondering about.. Why are all the changes guarded by OS_NT? This warning shows up in other builds. Like when building on Apple clang.

The changes are guarded by ifndef so that they only apply to non-OS_NT builds. The windows builds had a host of failures when using snprintf when the macros are removed. This fixes the warnings when building with Apple Clang (which was the compiler that started bugging me about this).

@grafikrobot grafikrobot mentioned this pull request Aug 28, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants